shopify_app 7.0.10 → 7.0.11

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1d6309c0a72b84c1a7643960b79466c21b9ab04c
4
- data.tar.gz: 79097e759876a3fcff79093b51796ba8d7d47266
3
+ metadata.gz: 01fd54b8c417c343000ff7831af46518aae171ea
4
+ data.tar.gz: e090401fe863bdef0f70cb41fd2c184332565439
5
5
  SHA512:
6
- metadata.gz: 405f3a3afadb611f2d160a94756061873b4bf324aadc32e0405eaf380818291d886b03455e37e28dc3295d90edb8b3dc7fe3aa1ade85429ff0d43d84df2e18dc
7
- data.tar.gz: d113dc8aa5e61eef97f79ad8cbc5f7e5bb23e2bd48cd5c3dcd38e64752970013a56afe216b9feb7d334806aaa5838b70f7d0166f6ea25ce2a77afca2b68b74a3
6
+ metadata.gz: a857bf574d74edcf5820f253404ce863c3ca4b50d92026780e32060aedfe7b658865c86a92df0062f63f0894e21dd82f7d10a8f99987ad66ba06b1f5d62b4106
7
+ data.tar.gz: bdf917823af652bc3b6f340fd0c3a26c01320e12ae097f2b11e81031f606c54fc91b34a6918211e2c9027adaca11c027ac99e1d0ce306fdb2b5f6a552e30c0f0
@@ -1,9 +1,11 @@
1
1
  language: ruby
2
+ cache: bundler
3
+ sudo: false
2
4
 
3
5
  rvm:
4
6
  - 2.2.4
7
+ - 2.3.1
5
8
 
6
9
  gemfile:
7
10
  - Gemfile
8
-
9
- script: "bundle exec rake test"
11
+ - Gemfile.rails50
data/CHANGELOG CHANGED
@@ -1,3 +1,12 @@
1
+ 7.0.11
2
+ ------
3
+ * Pass configured resources (like webhooks or scripttags) into the job rather than reading the config again. This allows for dynamically setting ShopifyApp config in a web request and having the job handle it correctly. This change does not affect the usage of webhooks or scripttags
4
+
5
+ 7.0.10
6
+ -----
7
+ * Loosen Rails dependency requirements to `>= 4.2.6` and allow Rails 5.0
8
+ * Add support for App Proxies
9
+
1
10
  7.0.9
2
11
  -----
3
12
 
@@ -0,0 +1,5 @@
1
+ source 'https://rubygems.org'
2
+ gemspec
3
+
4
+ gem 'rails', '~> 5.0'
5
+ gem 'activeresource', github: 'rails/activeresource'
data/README.md CHANGED
@@ -214,8 +214,12 @@ The engine provides a mixin for verifying incoming HTTP requests sent via an App
214
214
  # config/routes.rb
215
215
  namespace :app_proxy do
216
216
  # simple routes without a specified controller will go to AppProxyController
217
+ # GET '/app_proxy/basic' will be routed to AppProxyController#basic
217
218
  get :basic
218
219
 
220
+ # this will route GET /app_proxy to AppProxyController#main
221
+ root action: :main
222
+
219
223
  # more complex routes will go to controllers in the AppProxy namespace
220
224
  resources :reviews
221
225
  # GET /app_proxy/reviews will now be routed to
@@ -3,7 +3,7 @@ module ShopifyApp
3
3
  extend ActiveSupport::Concern
4
4
 
5
5
  included do
6
- skip_before_action :verify_authenticity_token
6
+ skip_before_action :verify_authenticity_token, raise: false
7
7
  before_action :verify_proxy_request
8
8
  end
9
9
 
@@ -2,8 +2,18 @@ module ShopifyApp
2
2
  class ScripttagsManager
3
3
  class CreationFailed < StandardError; end
4
4
 
5
- def self.queue(shop_domain, shop_token)
6
- ShopifyApp::ScripttagsManagerJob.perform_later(shop_domain: shop_domain, shop_token: shop_token)
5
+ def self.queue(shop_domain, shop_token, scripttags)
6
+ ShopifyApp::ScripttagsManagerJob.perform_later(
7
+ shop_domain: shop_domain,
8
+ shop_token: shop_token,
9
+ scripttags: scripttags
10
+ )
11
+ end
12
+
13
+ attr_reader :required_scripttags
14
+
15
+ def initialize(scripttags)
16
+ @required_scripttags = scripttags
7
17
  end
8
18
 
9
19
  def recreate_scripttags!
@@ -29,10 +39,6 @@ module ShopifyApp
29
39
 
30
40
  private
31
41
 
32
- def required_scripttags
33
- ShopifyApp.configuration.scripttags
34
- end
35
-
36
42
  def is_required_scripttag?(scripttag)
37
43
  required_scripttags.map{ |w| w[:src] }.include? scripttag.src
38
44
  end
@@ -1,8 +1,8 @@
1
1
  module ShopifyApp
2
2
  class ScripttagsManagerJob < ActiveJob::Base
3
- def perform(shop_domain:, shop_token:)
3
+ def perform(shop_domain:, shop_token:, scripttags:)
4
4
  ShopifyAPI::Session.temp(shop_domain, shop_token) do
5
- manager = ScripttagsManager.new
5
+ manager = ScripttagsManager.new(scripttags)
6
6
  manager.create_scripttags
7
7
  end
8
8
  end
@@ -11,16 +11,10 @@ module ShopifyApp
11
11
  end
12
12
 
13
13
  def callback
14
- if response = request.env['omniauth.auth']
15
- shop_name = response.uid
16
- token = response['credentials']['token']
17
-
18
- sess = ShopifyAPI::Session.new(shop_name, token)
19
- session[:shopify] = ShopifyApp::SessionRepository.store(sess)
20
- session[:shopify_domain] = shop_name
21
-
22
- WebhooksManager.queue(shop_name, token) if ShopifyApp.configuration.has_webhooks?
23
- ScripttagsManager.queue(shop_name, token) if ShopifyApp.configuration.has_scripttags?
14
+ if auth_hash
15
+ login_shop
16
+ install_webhooks
17
+ install_scripttags
24
18
 
25
19
  flash[:notice] = I18n.t('.logged_in')
26
20
  redirect_to_with_fallback return_address
@@ -47,6 +41,44 @@ module ShopifyApp
47
41
  end
48
42
  end
49
43
 
44
+ def login_shop
45
+ sess = ShopifyAPI::Session.new(shop_name, token)
46
+ session[:shopify] = ShopifyApp::SessionRepository.store(sess)
47
+ session[:shopify_domain] = shop_name
48
+ end
49
+
50
+ def auth_hash
51
+ request.env['omniauth.auth']
52
+ end
53
+
54
+ def shop_name
55
+ auth_hash.uid
56
+ end
57
+
58
+ def token
59
+ auth_hash['credentials']['token']
60
+ end
61
+
62
+ def install_webhooks
63
+ return unless ShopifyApp.configuration.has_webhooks?
64
+
65
+ WebhooksManager.queue(
66
+ shop_name,
67
+ token,
68
+ ShopifyApp.configuration.webhooks
69
+ )
70
+ end
71
+
72
+ def install_scripttags
73
+ return unless ShopifyApp.configuration.has_scripttags?
74
+
75
+ ScripttagsManager.queue(
76
+ shop_name,
77
+ token,
78
+ ShopifyApp.configuration.scripttags
79
+ )
80
+ end
81
+
50
82
  def return_address
51
83
  session.delete(:return_to) || main_app.root_url
52
84
  end
@@ -1,3 +1,3 @@
1
1
  module ShopifyApp
2
- VERSION = '7.0.10'
2
+ VERSION = '7.0.11'
3
3
  end
@@ -3,7 +3,7 @@ module ShopifyApp
3
3
  extend ActiveSupport::Concern
4
4
 
5
5
  included do
6
- skip_before_action :verify_authenticity_token
6
+ skip_before_action :verify_authenticity_token, raise: false
7
7
  before_action :verify_request
8
8
  end
9
9
 
@@ -2,8 +2,18 @@ module ShopifyApp
2
2
  class WebhooksManager
3
3
  class CreationFailed < StandardError; end
4
4
 
5
- def self.queue(shop_domain, shop_token)
6
- ShopifyApp::WebhooksManagerJob.perform_later(shop_domain: shop_domain, shop_token: shop_token)
5
+ def self.queue(shop_domain, shop_token, webhooks)
6
+ ShopifyApp::WebhooksManagerJob.perform_later(
7
+ shop_domain: shop_domain,
8
+ shop_token: shop_token,
9
+ webhooks: webhooks
10
+ )
11
+ end
12
+
13
+ attr_reader :required_webhooks
14
+
15
+ def initialize(webhooks)
16
+ @required_webhooks = webhooks
7
17
  end
8
18
 
9
19
  def recreate_webhooks!
@@ -29,10 +39,6 @@ module ShopifyApp
29
39
 
30
40
  private
31
41
 
32
- def required_webhooks
33
- ShopifyApp.configuration.webhooks
34
- end
35
-
36
42
  def is_required_webhook?(webhook)
37
43
  required_webhooks.map{ |w| w[:address] }.include? webhook.address
38
44
  end
@@ -40,7 +46,7 @@ module ShopifyApp
40
46
  def create_webhook(attributes)
41
47
  attributes.reverse_merge!(format: 'json')
42
48
  webhook = ShopifyAPI::Webhook.create(attributes)
43
- raise CreationFailed unless webhook.persisted?
49
+ raise CreationFailed, webhook.errors.full_messages.to_sentence unless webhook.persisted?
44
50
  webhook
45
51
  end
46
52
 
@@ -1,8 +1,8 @@
1
1
  module ShopifyApp
2
2
  class WebhooksManagerJob < ActiveJob::Base
3
- def perform(shop_domain:, shop_token:)
3
+ def perform(shop_domain:, shop_token:, webhooks:)
4
4
  ShopifyAPI::Session.temp(shop_domain, shop_token) do
5
- manager = WebhooksManager.new
5
+ manager = WebhooksManager.new(webhooks)
6
6
  manager.create_webhooks
7
7
  end
8
8
  end
@@ -8,9 +8,10 @@ Gem::Specification.new do |s|
8
8
  s.author = "Shopify"
9
9
  s.summary = %q{This gem is used to get quickly started with the Shopify API}
10
10
 
11
- s.add_dependency('rails', '>= 4.2.6')
11
+ s.required_ruby_version = ">= 2.2.4"
12
12
 
13
- s.add_runtime_dependency('shopify_api', '~> 4.2')
13
+ s.add_runtime_dependency('rails', '>= 4.2.6')
14
+ s.add_runtime_dependency('shopify_api', '~> 4.2.2')
14
15
  s.add_runtime_dependency('omniauth-shopify-oauth2', '~> 1.1.11')
15
16
 
16
17
  s.add_development_dependency('rake')
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shopify_app
3
3
  version: !ruby/object:Gem::Version
4
- version: 7.0.10
4
+ version: 7.0.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shopify
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-07-06 00:00:00.000000000 Z
11
+ date: 2016-07-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '4.2'
33
+ version: 4.2.2
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '4.2'
40
+ version: 4.2.2
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: omniauth-shopify-oauth2
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -132,6 +132,7 @@ files:
132
132
  - ".travis.yml"
133
133
  - CHANGELOG
134
134
  - Gemfile
135
+ - Gemfile.rails50
135
136
  - ISSUE_TEMPLATE.md
136
137
  - LICENSE
137
138
  - QUICKSTART.md
@@ -199,7 +200,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
199
200
  requirements:
200
201
  - - ">="
201
202
  - !ruby/object:Gem::Version
202
- version: '0'
203
+ version: 2.2.4
203
204
  required_rubygems_version: !ruby/object:Gem::Requirement
204
205
  requirements:
205
206
  - - ">="