lucid_shopify 0.22.0 → 0.23.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/README.md +5 -5
- data/lib/lucid_shopify.rb +1 -1
- data/lib/lucid_shopify/{authorize.rb → authorise.rb} +8 -8
- data/lib/lucid_shopify/container.rb +1 -1
- data/lib/lucid_shopify/credentials.rb +1 -1
- data/lib/lucid_shopify/request.rb +3 -3
- data/lib/lucid_shopify/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c225c729d5ced22978539c22523dc007e1e4219fe7333784aff780022d969999
|
4
|
+
data.tar.gz: af1375251a30898d6f025b849749482b976a25223e563666d055e4edc7fcc0d7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2125841d6a8aebaad6170d5474b1796ce348d65d16261425b3dde750456eecb4c0a2a3355738951c3707422dd15e276e00b3a0021af6d832958c555704e458d2
|
7
|
+
data.tar.gz: 8c675d75398adf165686cea0531ae9bb31154b98cc880c8303416262bb8b27a343ac9d285225287a2c3fc7d7aec955fb2e2631c1d3df5501724f0a7e61de1469
|
data/README.md
CHANGED
@@ -28,14 +28,14 @@ the default unconfigured behaviour is equivalent to:
|
|
28
28
|
|
29
29
|
LucidShopify.config = LucidShopify::Config::PRIVATE_APP
|
30
30
|
|
31
|
-
Additionally, each API request requires
|
31
|
+
Additionally, each API request requires authorisation:
|
32
32
|
|
33
33
|
credentials = LucidShopify::Credentials.new(
|
34
34
|
'...', # myshopify_domain
|
35
35
|
'...', # access_token
|
36
36
|
)
|
37
37
|
|
38
|
-
If the access token is omitted, the request will be
|
38
|
+
If the access token is omitted, the request will be unauthorised.
|
39
39
|
This is only useful during the OAuth2 process.
|
40
40
|
|
41
41
|
|
@@ -100,11 +100,11 @@ Verify webhook requests with the request data and the HMAC header:
|
|
100
100
|
end
|
101
101
|
|
102
102
|
|
103
|
-
###
|
103
|
+
### Authorisation
|
104
104
|
|
105
|
-
|
105
|
+
authorise = LucidShopify::Authorise.new
|
106
106
|
|
107
|
-
access_token =
|
107
|
+
access_token = authorise.(credentials, authorisation_code)
|
108
108
|
|
109
109
|
|
110
110
|
### Billing
|
data/lib/lucid_shopify.rb
CHANGED
@@ -9,7 +9,7 @@ end
|
|
9
9
|
|
10
10
|
module LucidShopify
|
11
11
|
autoload :ActivateCharge, 'lucid_shopify/activate_charge'
|
12
|
-
autoload :
|
12
|
+
autoload :Authorise, 'lucid_shopify/authorise'
|
13
13
|
autoload :Client, 'lucid_shopify/client'
|
14
14
|
autoload :Container, 'lucid_shopify/container'
|
15
15
|
autoload :CreateAllWebhooks, 'lucid_shopify/create_all_webhooks'
|
@@ -3,7 +3,7 @@
|
|
3
3
|
require 'lucid_shopify/container'
|
4
4
|
|
5
5
|
module LucidShopify
|
6
|
-
class
|
6
|
+
class Authorise
|
7
7
|
Error = Class.new(Error)
|
8
8
|
|
9
9
|
#
|
@@ -14,19 +14,19 @@ module LucidShopify
|
|
14
14
|
end
|
15
15
|
|
16
16
|
#
|
17
|
-
# Exchange an
|
17
|
+
# Exchange an authorisation code for a new Shopify access token.
|
18
18
|
#
|
19
19
|
# @param myshopify_domain [String]
|
20
|
-
# @param
|
20
|
+
# @param authorisation_code [String]
|
21
21
|
#
|
22
22
|
# @return [String] the access token
|
23
23
|
#
|
24
24
|
# @raise [Error] if the response is invalid
|
25
25
|
#
|
26
|
-
def call(myshopify_domain,
|
26
|
+
def call(myshopify_domain, authorisation_code)
|
27
27
|
credentials = Credentials.new(myshopify_domain)
|
28
28
|
|
29
|
-
data = @client.post_json(credentials, 'oauth/access_token', post_data(
|
29
|
+
data = @client.post_json(credentials, 'oauth/access_token', post_data(authorisation_code))
|
30
30
|
|
31
31
|
raise Error if data['access_token'].nil?
|
32
32
|
raise Error if data['scope'] != LucidShopify.config.scope
|
@@ -35,15 +35,15 @@ module LucidShopify
|
|
35
35
|
end
|
36
36
|
|
37
37
|
#
|
38
|
-
# @param
|
38
|
+
# @param authorisation_code [String]
|
39
39
|
#
|
40
40
|
# @return [Hash]
|
41
41
|
#
|
42
|
-
private def post_data(
|
42
|
+
private def post_data(authorisation_code)
|
43
43
|
{
|
44
44
|
client_id: LucidShopify.config.api_key,
|
45
45
|
client_secret: LucidShopify.config.shared_secret,
|
46
|
-
code:
|
46
|
+
code: authorisation_code,
|
47
47
|
}
|
48
48
|
end
|
49
49
|
end
|
@@ -11,7 +11,7 @@ module LucidShopify
|
|
11
11
|
|
12
12
|
# Services only (dependencies); no value objects, entities.
|
13
13
|
Container.register(:activate_charge) { ActivateCharge.new }
|
14
|
-
Container.register(:
|
14
|
+
Container.register(:authorise) { Authorise.new }
|
15
15
|
Container.register(:client) { Client.new }
|
16
16
|
Container.register(:create_all_webhooks) { CreateAllWebhooks.new }
|
17
17
|
Container.register(:create_charge) { CreateCharge.new }
|
@@ -29,10 +29,10 @@ module LucidShopify
|
|
29
29
|
private def build_url
|
30
30
|
admin_url = "https://#{credentials.myshopify_domain}/admin"
|
31
31
|
|
32
|
-
|
33
|
-
|
32
|
+
normalised_path = path.sub(/^\//, '')
|
33
|
+
normalised_path = path.sub(/\.json$/, '')
|
34
34
|
|
35
|
-
admin_url + '/' +
|
35
|
+
admin_url + '/' + normalised_path + '.json'
|
36
36
|
end
|
37
37
|
|
38
38
|
#
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lucid_shopify
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.23.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kelsey Judson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-05-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dotenv
|
@@ -117,7 +117,7 @@ files:
|
|
117
117
|
- README.md
|
118
118
|
- lib/lucid_shopify.rb
|
119
119
|
- lib/lucid_shopify/activate_charge.rb
|
120
|
-
- lib/lucid_shopify/
|
120
|
+
- lib/lucid_shopify/authorise.rb
|
121
121
|
- lib/lucid_shopify/client.rb
|
122
122
|
- lib/lucid_shopify/config.rb
|
123
123
|
- lib/lucid_shopify/container.rb
|