shopify_app 8.6.1 → 9.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.travis.yml +1 -1
- data/CHANGELOG.md +5 -0
- data/README.md +56 -1
- data/app/controllers/shopify_app/callback_controller.rb +5 -1
- data/lib/generators/shopify_app/app_proxy_controller/templates/index.html.erb +2 -2
- data/lib/generators/shopify_app/home_controller/templates/index.html.erb +1 -1
- data/lib/generators/shopify_app/install/install_generator.rb +2 -0
- data/lib/generators/shopify_app/install/templates/embedded_app.html.erb +1 -1
- data/lib/generators/shopify_app/install/templates/shopify_app.rb +1 -0
- data/lib/generators/shopify_app/shop_model/templates/shop.rb +4 -0
- data/lib/shopify_app/configuration.rb +1 -0
- data/lib/shopify_app/controller_concerns/login_protection.rb +1 -1
- data/lib/shopify_app/jobs/scripttags_manager_job.rb +2 -1
- data/lib/shopify_app/jobs/webhooks_manager_job.rb +2 -1
- data/lib/shopify_app/session/session_storage.rb +13 -4
- data/lib/shopify_app/version.rb +1 -1
- data/package.json +1 -1
- data/shopify_app.gemspec +1 -1
- metadata +2 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f969c97f90fa13571a9e8af4b509148c1bd90a2f3c417e48c7beaa5d42f783c0
|
4
|
+
data.tar.gz: a99fd49067d47fd6362c79eeb92f7c3c904ac52e14f5c7b59cf77e12ae3fb9b1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 825cddcd43bb04d549a3ec295452283f55cccfda4d2608bb45f66c28548843af8c527a00ef2c49b1f9d44696634d669a6684909899f2012b0ed0e637a0559b9e
|
7
|
+
data.tar.gz: 8d4e54cef864888f554c64955feda1d03e9bfba3c2a237bbdb27f7a8364e12e4a3b2f49dfefa402b1799f5886539ca770aada0857e89a46c7098ab31ac3ee5d2
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -34,6 +34,7 @@ Table of Contents
|
|
34
34
|
* [**Authenticated**](#authenticated)
|
35
35
|
* [**AppProxyVerification**](#appproxyverification)
|
36
36
|
* [Recommended Usage](#recommended-usage)
|
37
|
+
* [**Upgrading from 8.6 to 9.0.0**](#upgrading-from-86-to-900)
|
37
38
|
* [**Troubleshooting**](#troubleshooting)
|
38
39
|
* [Generator shopify_app:install hangs](#generator-shopify_appinstall-hangs)
|
39
40
|
* [**Testing an embedded app outside the Shopify admin**](#testing-an-embedded-app-outside-the-shopify-admin)
|
@@ -395,7 +396,7 @@ ShopifyApp::SessionRepository
|
|
395
396
|
|
396
397
|
`ShopifyApp::SessionRepository` allows you as a developer to define how your sessions are retrieved and stored for shops. The `SessionRepository` is configured in the `config/initializers/shopify_app.rb` file and can be set to any object that implements `self.store(shopify_session)` which stores the session and returns a unique identifier and `self.retrieve(id)` which returns a `ShopifyAPI::Session` for the passed id. See either the `ShopifyApp::InMemorySessionStore` class or the `ShopifyApp::SessionStorage` concern for examples.
|
397
398
|
|
398
|
-
If you only run the install generator then by default you will have an in memory store but it **won't work** on multi-server environments including Heroku. If you ran all the generators including the shop_model generator then the `Shop` model itself will be the `SessionRepository`. If you look at the implementation of the generated shop model you'll see that this gem provides a concern for the `SessionRepository`. You can use this concern on any model that responds to `shopify_domain` and `
|
399
|
+
If you only run the install generator then by default you will have an in memory store but it **won't work** on multi-server environments including Heroku. If you ran all the generators including the shop_model generator then the `Shop` model itself will be the `SessionRepository`. If you look at the implementation of the generated shop model you'll see that this gem provides a concern for the `SessionRepository`. You can use this concern on any model that responds to `shopify_domain`, `shopify_token` and `api_version`.
|
399
400
|
|
400
401
|
Authenticated
|
401
402
|
-------------
|
@@ -444,3 +445,57 @@ Questions or problems?
|
|
444
445
|
|
445
446
|
- [Ask questions!](https://ecommerce.shopify.com/c/shopify-apis-and-technology)
|
446
447
|
- [Read the docs!](https://help.shopify.com/api/guides)
|
448
|
+
|
449
|
+
|
450
|
+
Upgrading from 8.6 to 9.0.0
|
451
|
+
---------------------------
|
452
|
+
|
453
|
+
### Configuration change
|
454
|
+
|
455
|
+
Add an api version configuration in `config/initializers/shopify_app.rb`
|
456
|
+
Set this to the version you want to run against by default see [url] for what versions are currently availabe
|
457
|
+
```ruby
|
458
|
+
config.api_version = '2019-04'
|
459
|
+
```
|
460
|
+
|
461
|
+
### Session storage change
|
462
|
+
|
463
|
+
You will need to add an `api_version` method to you session storage object. The default implmentation for this is.
|
464
|
+
```ruby
|
465
|
+
def api_version
|
466
|
+
ShopifyApp.configuration.api_version
|
467
|
+
end
|
468
|
+
```
|
469
|
+
|
470
|
+
### Generated file change
|
471
|
+
|
472
|
+
`embedded_app.html.erb` the useage of `shop_session.url` needs to be changed to `shop_session.domain`
|
473
|
+
```erb
|
474
|
+
<script type="text/javascript">
|
475
|
+
ShopifyApp.init({
|
476
|
+
apiKey: "<%= ShopifyApp.configuration.api_key %>",
|
477
|
+
|
478
|
+
shopOrigin: "<%= "https://#{ @shop_session.url }" if @shop_session %>",
|
479
|
+
|
480
|
+
debug: false,
|
481
|
+
forceRedirect: true
|
482
|
+
});
|
483
|
+
</script>
|
484
|
+
```
|
485
|
+
is changed to
|
486
|
+
```erb
|
487
|
+
<script type="text/javascript">
|
488
|
+
ShopifyApp.init({
|
489
|
+
apiKey: "<%= ShopifyApp.configuration.api_key %>",
|
490
|
+
|
491
|
+
shopOrigin: "<%= "https://#{ @shop_session.domain }" if @shop_session %>",
|
492
|
+
|
493
|
+
debug: false,
|
494
|
+
forceRedirect: true
|
495
|
+
});
|
496
|
+
</script>
|
497
|
+
```
|
498
|
+
|
499
|
+
### ShopifyAPI changes
|
500
|
+
|
501
|
+
You will need to also follow the ShopifyAPI [upgrade guide](https://github.com/shopify/shopify_api/README.md#-breaking-change-notice-for-version-700-) to ensure your app is ready to work with api versioning.
|
@@ -50,7 +50,11 @@ module ShopifyApp
|
|
50
50
|
end
|
51
51
|
|
52
52
|
def set_shopify_session
|
53
|
-
session_store = ShopifyAPI::Session.new(
|
53
|
+
session_store = ShopifyAPI::Session.new(
|
54
|
+
domain: shop_name,
|
55
|
+
token: token,
|
56
|
+
api_version: ShopifyApp.configuration.api_version
|
57
|
+
)
|
54
58
|
|
55
59
|
session[:shopify] = ShopifyApp::SessionRepository.store(session_store)
|
56
60
|
session[:shopify_domain] = shop_name
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
<ul>
|
4
4
|
<% @products.each do |product| %>
|
5
|
-
<li><%= link_to product.title, "https://#{@shop_session.
|
5
|
+
<li><%= link_to product.title, "https://#{@shop_session.domain}/admin/products/#{product.id}", target: "_top" %></li>
|
6
6
|
<% end %>
|
7
7
|
</ul>
|
8
8
|
|
@@ -12,6 +12,7 @@ module ShopifyApp
|
|
12
12
|
class_option :old_secret, type: :string, default: '<old_secret>'
|
13
13
|
class_option :scope, type: :array, default: ['read_products']
|
14
14
|
class_option :embedded, type: :string, default: 'true'
|
15
|
+
class_option :api_version, type: :string, default: ShopifyAPI::ApiVersion.latest_stable_version.to_s
|
15
16
|
|
16
17
|
def create_shopify_app_initializer
|
17
18
|
@application_name = format_array_argument(options['application_name'])
|
@@ -19,6 +20,7 @@ module ShopifyApp
|
|
19
20
|
@secret = options['secret']
|
20
21
|
@old_secret = options['old_secret']
|
21
22
|
@scope = format_array_argument(options['scope'])
|
23
|
+
@api_version = options['api_version']
|
22
24
|
|
23
25
|
template 'shopify_app.rb', 'config/initializers/shopify_app.rb'
|
24
26
|
end
|
@@ -25,7 +25,7 @@
|
|
25
25
|
<script type="text/javascript">
|
26
26
|
ShopifyApp.init({
|
27
27
|
apiKey: "<%= ShopifyApp.configuration.api_key %>",
|
28
|
-
shopOrigin: "<%= "https://#{ @shop_session.
|
28
|
+
shopOrigin: "<%= "https://#{ @shop_session.domain }" if @shop_session %>",
|
29
29
|
debug: <%= Rails.env.development? ? 'true' : 'false' %>,
|
30
30
|
forceRedirect: true
|
31
31
|
});
|
@@ -7,5 +7,6 @@ ShopifyApp.configure do |config|
|
|
7
7
|
# https://help.shopify.com/en/api/getting-started/authentication/oauth/scopes
|
8
8
|
config.embedded_app = <%= embedded_app? %>
|
9
9
|
config.after_authenticate_job = false
|
10
|
+
config.api_version = "<%= @api_version %>"
|
10
11
|
config.session_repository = ShopifyApp::InMemorySessionStore
|
11
12
|
end
|
@@ -32,7 +32,7 @@ module ShopifyApp
|
|
32
32
|
end
|
33
33
|
|
34
34
|
def login_again_if_different_shop
|
35
|
-
if shop_session && params[:shop] && params[:shop].is_a?(String) && (shop_session.
|
35
|
+
if shop_session && params[:shop] && params[:shop].is_a?(String) && (shop_session.domain != params[:shop])
|
36
36
|
clear_shop_session
|
37
37
|
redirect_to_login
|
38
38
|
end
|
@@ -6,7 +6,8 @@ module ShopifyApp
|
|
6
6
|
end
|
7
7
|
|
8
8
|
def perform(shop_domain:, shop_token:, scripttags:)
|
9
|
-
|
9
|
+
api_version = ShopifyApp.configuration.api_version
|
10
|
+
ShopifyAPI::Session.temp(domain: shop_domain, token: shop_token, api_version: api_version) do
|
10
11
|
manager = ScripttagsManager.new(scripttags, shop_domain)
|
11
12
|
manager.create_scripttags
|
12
13
|
end
|
@@ -6,7 +6,8 @@ module ShopifyApp
|
|
6
6
|
end
|
7
7
|
|
8
8
|
def perform(shop_domain:, shop_token:, webhooks:)
|
9
|
-
|
9
|
+
api_version = ShopifyApp.configuration.api_version
|
10
|
+
ShopifyAPI::Session.temp(domain: shop_domain, token: shop_token, api_version: api_version) do
|
10
11
|
manager = WebhooksManager.new(webhooks)
|
11
12
|
manager.create_webhooks
|
12
13
|
end
|
@@ -5,15 +5,21 @@ module ShopifyApp
|
|
5
5
|
included do
|
6
6
|
validates :shopify_domain, presence: true, uniqueness: { case_sensitive: false }
|
7
7
|
validates :shopify_token, presence: true
|
8
|
+
validates :api_version, presence: true
|
8
9
|
end
|
9
10
|
|
10
11
|
def with_shopify_session(&block)
|
11
|
-
ShopifyAPI::Session.temp(
|
12
|
+
ShopifyAPI::Session.temp(
|
13
|
+
domain: shopify_domain,
|
14
|
+
token: shopify_token,
|
15
|
+
api_version: api_version,
|
16
|
+
&block
|
17
|
+
)
|
12
18
|
end
|
13
19
|
|
14
20
|
class_methods do
|
15
21
|
def store(session)
|
16
|
-
shop =
|
22
|
+
shop = find_or_initialize_by(shopify_domain: session.domain)
|
17
23
|
shop.shopify_token = session.token
|
18
24
|
shop.save!
|
19
25
|
shop.id
|
@@ -23,10 +29,13 @@ module ShopifyApp
|
|
23
29
|
return unless id
|
24
30
|
|
25
31
|
if shop = self.find_by(id: id)
|
26
|
-
ShopifyAPI::Session.new(
|
32
|
+
ShopifyAPI::Session.new(
|
33
|
+
domain: shop.shopify_domain,
|
34
|
+
token: shop.shopify_token,
|
35
|
+
api_version: shop.api_version
|
36
|
+
)
|
27
37
|
end
|
28
38
|
end
|
29
39
|
end
|
30
|
-
|
31
40
|
end
|
32
41
|
end
|
data/lib/shopify_app/version.rb
CHANGED
data/package.json
CHANGED
data/shopify_app.gemspec
CHANGED
@@ -12,7 +12,7 @@ Gem::Specification.new do |s|
|
|
12
12
|
|
13
13
|
s.add_runtime_dependency('browser_sniffer', '~> 1.1.0')
|
14
14
|
s.add_runtime_dependency('rails', '>= 5.0.0')
|
15
|
-
s.add_runtime_dependency('shopify_api', '>=
|
15
|
+
s.add_runtime_dependency('shopify_api', '>= 7.0.0')
|
16
16
|
s.add_runtime_dependency('omniauth-shopify-oauth2', '~> 2.1.0')
|
17
17
|
|
18
18
|
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:
|
4
|
+
version: 9.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shopify
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-04-
|
11
|
+
date: 2019-04-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: browser_sniffer
|
@@ -43,9 +43,6 @@ dependencies:
|
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - ">="
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: 4.3.5
|
48
|
-
- - "<"
|
49
46
|
- !ruby/object:Gem::Version
|
50
47
|
version: 7.0.0
|
51
48
|
type: :runtime
|
@@ -53,9 +50,6 @@ dependencies:
|
|
53
50
|
version_requirements: !ruby/object:Gem::Requirement
|
54
51
|
requirements:
|
55
52
|
- - ">="
|
56
|
-
- !ruby/object:Gem::Version
|
57
|
-
version: 4.3.5
|
58
|
-
- - "<"
|
59
53
|
- !ruby/object:Gem::Version
|
60
54
|
version: 7.0.0
|
61
55
|
- !ruby/object:Gem::Dependency
|