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 +4 -4
- data/.travis.yml +4 -2
- data/CHANGELOG +9 -0
- data/Gemfile.rails50 +5 -0
- data/README.md +4 -0
- data/lib/shopify_app/app_proxy_verification.rb +1 -1
- data/lib/shopify_app/scripttags_manager.rb +12 -6
- data/lib/shopify_app/scripttags_manager_job.rb +2 -2
- data/lib/shopify_app/sessions_concern.rb +42 -10
- data/lib/shopify_app/version.rb +1 -1
- data/lib/shopify_app/webhook_verification.rb +1 -1
- data/lib/shopify_app/webhooks_manager.rb +13 -7
- data/lib/shopify_app/webhooks_manager_job.rb +2 -2
- data/shopify_app.gemspec +3 -2
- metadata +6 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 01fd54b8c417c343000ff7831af46518aae171ea
|
4
|
+
data.tar.gz: e090401fe863bdef0f70cb41fd2c184332565439
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a857bf574d74edcf5820f253404ce863c3ca4b50d92026780e32060aedfe7b658865c86a92df0062f63f0894e21dd82f7d10a8f99987ad66ba06b1f5d62b4106
|
7
|
+
data.tar.gz: bdf917823af652bc3b6f340fd0c3a26c01320e12ae097f2b11e81031f606c54fc91b34a6918211e2c9027adaca11c027ac99e1d0ce306fdb2b5f6a552e30c0f0
|
data/.travis.yml
CHANGED
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
|
|
data/Gemfile.rails50
ADDED
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
|
@@ -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(
|
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
|
15
|
-
|
16
|
-
|
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
|
data/lib/shopify_app/version.rb
CHANGED
@@ -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(
|
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
|
data/shopify_app.gemspec
CHANGED
@@ -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.
|
11
|
+
s.required_ruby_version = ">= 2.2.4"
|
12
12
|
|
13
|
-
s.add_runtime_dependency('
|
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.
|
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-
|
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:
|
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:
|
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:
|
203
|
+
version: 2.2.4
|
203
204
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
204
205
|
requirements:
|
205
206
|
- - ">="
|