lucid_shopify 0.14.0 → 0.15.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 +12 -12
- data/lib/lucid_shopify/activate_charge.rb +3 -3
- data/lib/lucid_shopify/authorize.rb +2 -2
- data/lib/lucid_shopify/create_all_webhooks.rb +3 -3
- data/lib/lucid_shopify/create_charge.rb +3 -3
- data/lib/lucid_shopify/create_webhook.rb +3 -3
- data/lib/lucid_shopify/{request_credentials.rb → credentials.rb} +1 -1
- data/lib/lucid_shopify/delete_all_webhooks.rb +3 -3
- data/lib/lucid_shopify/delete_request.rb +1 -1
- data/lib/lucid_shopify/delete_webhook.rb +3 -3
- data/lib/lucid_shopify/get_request.rb +1 -1
- data/lib/lucid_shopify/post_request.rb +1 -1
- data/lib/lucid_shopify/put_request.rb +1 -1
- data/lib/lucid_shopify/request.rb +1 -1
- data/lib/lucid_shopify/version.rb +1 -1
- data/lib/lucid_shopify.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 653ddf7f8c324f940bf9e2d704910377e34f015eee770b52ce8b0928781dcdd1
|
4
|
+
data.tar.gz: e82a027e61ab3d5af7edcad6457bb5e69db804589bb9dce6dc5f65e09f78d199
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8d91712da6b6790a66736fe38c849e18516d6d2fa04b1ba0f7112a5dcae09f74dcf529a8e6ab2515a89b9beaf5d67cf8eae3e3283ef5840859a0ba7996c8da22
|
7
|
+
data.tar.gz: 47cad3f01c5e7282402b0849abd01a1a5ca7b053990b64d2869b9e800493c73431334d8bc221ca1b8abb94493e5fbda1cee6afcdb05362b23bb4a332eaaa06bc
|
data/README.md
CHANGED
@@ -28,7 +28,7 @@ argument to any of the classes that make use of it.
|
|
28
28
|
|
29
29
|
Additionally, each API request requires authorization:
|
30
30
|
|
31
|
-
|
31
|
+
credentials = LucidShopify::Credentials.new(
|
32
32
|
'...', # myshopify_domain
|
33
33
|
'...', # access_token
|
34
34
|
)
|
@@ -68,15 +68,15 @@ to create a worker around something like this:
|
|
68
68
|
|
69
69
|
Create/delete all configured webhooks (see above):
|
70
70
|
|
71
|
-
LucidShopify::CreateAllWebhooks.new.(
|
72
|
-
LucidShopify::DeleteAllWebhooks.new.(
|
71
|
+
LucidShopify::CreateAllWebhooks.new.(credentials)
|
72
|
+
LucidShopify::DeleteAllWebhooks.new.(credentials)
|
73
73
|
|
74
74
|
Create/delete webhooks manually:
|
75
75
|
|
76
76
|
webhook = {topic: 'orders/create', fields: %w(id tags)}
|
77
77
|
|
78
|
-
LucidShopify::CreateWebhook.new.(
|
79
|
-
LucidShopify::DeleteWebhook.new.(
|
78
|
+
LucidShopify::CreateWebhook.new.(credentials, webhook)
|
79
|
+
LucidShopify::DeleteWebhook.new.(credentials, webhook_id)
|
80
80
|
|
81
81
|
|
82
82
|
### Verification
|
@@ -102,7 +102,7 @@ Verify webhook requests with the request data and the HMAC header:
|
|
102
102
|
|
103
103
|
authorize = LucidShopify::Authorize.new
|
104
104
|
|
105
|
-
access_token = authorize.(
|
105
|
+
access_token = authorize.(credentials, authorization_code)
|
106
106
|
|
107
107
|
|
108
108
|
### Billing
|
@@ -111,7 +111,7 @@ Create a new charge:
|
|
111
111
|
|
112
112
|
create_charge = LucidShopify::CreateCharge.new
|
113
113
|
|
114
|
-
charge = create_charge.(
|
114
|
+
charge = create_charge.(credentials, charge) # see LucidShopify::Charge
|
115
115
|
|
116
116
|
Redirect the user to `charge['confirmation_url']`. When the user
|
117
117
|
returns (see `config.billing_callback_uri`), activate the accepted
|
@@ -119,21 +119,21 @@ charge:
|
|
119
119
|
|
120
120
|
activate_charge = LucidShopify::ActivateCharge.new
|
121
121
|
|
122
|
-
activate_charge.(
|
122
|
+
activate_charge.(credentials, accepted_charge)
|
123
123
|
|
124
124
|
|
125
125
|
### Make API requests
|
126
126
|
|
127
127
|
client = LucidShopify::Client.new
|
128
128
|
|
129
|
-
client.get(
|
130
|
-
client.post_json(
|
129
|
+
client.get(credentials, 'orders', since_id: since_id)['orders']
|
130
|
+
client.post_json(credentials, 'orders', new_order)
|
131
131
|
|
132
132
|
|
133
133
|
### Make throttled API requests
|
134
134
|
|
135
|
-
client.throttled.get(
|
136
|
-
client.throttled.post_json(
|
135
|
+
client.throttled.get(credentials, 'orders')
|
136
|
+
client.throttled.post_json(credentials, 'orders', new_order)
|
137
137
|
|
138
138
|
Note that throttling currently uses a naive implementation that is
|
139
139
|
only maintained across a single thread.
|
@@ -14,13 +14,13 @@ module LucidShopify
|
|
14
14
|
#
|
15
15
|
# Activate a recurring application charge.
|
16
16
|
#
|
17
|
-
# @param
|
17
|
+
# @param credentials [Credentials]
|
18
18
|
# @param charge [#to_h] an accepted charge received from Shopify via callback
|
19
19
|
#
|
20
20
|
# @return [Hash] the active charge
|
21
21
|
#
|
22
|
-
def call(
|
23
|
-
data = @client.post_json(
|
22
|
+
def call(credentials, charge)
|
23
|
+
data = @client.post_json(credentials, "recurring_application_charges/#{charge.to_h['id']}/activate", charge.to_h)
|
24
24
|
|
25
25
|
data['recurring_application_charge']
|
26
26
|
end
|
@@ -24,9 +24,9 @@ module LucidShopify
|
|
24
24
|
# @raise [Error] if the response is invalid
|
25
25
|
#
|
26
26
|
def call(myshopify_domain, authorization_code)
|
27
|
-
|
27
|
+
credentials = Credentials.new(myshopify_domain)
|
28
28
|
|
29
|
-
data = @client.post_json(
|
29
|
+
data = @client.post_json(credentials, 'oauth/access_token', post_data(authorization_code))
|
30
30
|
|
31
31
|
raise Error if data['access_token'].nil?
|
32
32
|
raise Error if data['scope'] != LucidShopify.config.scope
|
@@ -15,14 +15,14 @@ module LucidShopify
|
|
15
15
|
# Create all webhooks for the shop. Shopify ignores any webhooks which
|
16
16
|
# already exist remotely.
|
17
17
|
#
|
18
|
-
# @param
|
18
|
+
# @param credentials [Credentials]
|
19
19
|
# @param webhooks [WebhookList]
|
20
20
|
#
|
21
21
|
# @return [Array<Hash>] response data
|
22
22
|
#
|
23
|
-
def call(
|
23
|
+
def call(credentials, webhooks: Container[:webhook_list])
|
24
24
|
webhooks.map do |webhook|
|
25
|
-
Thread.new { @create_webhook.(
|
25
|
+
Thread.new { @create_webhook.(credentials, webhook) }
|
26
26
|
end.map(&:value)
|
27
27
|
end
|
28
28
|
end
|
@@ -14,13 +14,13 @@ module LucidShopify
|
|
14
14
|
#
|
15
15
|
# Create a new recurring application charge.
|
16
16
|
#
|
17
|
-
# @param
|
17
|
+
# @param credentials [Credentials]
|
18
18
|
# @param charge [Hash]
|
19
19
|
#
|
20
20
|
# @return [Hash] the pending charge
|
21
21
|
#
|
22
|
-
def call(
|
23
|
-
data = @client.post_json(
|
22
|
+
def call(credentials, charge)
|
23
|
+
data = @client.post_json(credentials, 'recurring_application_charges', post_data(charge))
|
24
24
|
|
25
25
|
data['recurring_application_charge']
|
26
26
|
end
|
@@ -12,15 +12,15 @@ module LucidShopify
|
|
12
12
|
end
|
13
13
|
|
14
14
|
#
|
15
|
-
# @param
|
15
|
+
# @param credentials [Credentials]
|
16
16
|
# @param webhook [Hash]
|
17
17
|
#
|
18
18
|
# @return [Hash] response data
|
19
19
|
#
|
20
|
-
def call(
|
20
|
+
def call(credentials, webhook)
|
21
21
|
data = {**webhook, address: LucidShopify.config.webhook_uri}
|
22
22
|
|
23
|
-
@client.post_json(
|
23
|
+
@client.post_json(credentials, 'webhooks', webhook: data)
|
24
24
|
end
|
25
25
|
end
|
26
26
|
end
|
@@ -17,15 +17,15 @@ module LucidShopify
|
|
17
17
|
#
|
18
18
|
# Delete any existing webhooks.
|
19
19
|
#
|
20
|
-
# @param
|
20
|
+
# @param credentials [Credentials]
|
21
21
|
#
|
22
22
|
# @return [Array<Hash>] response data
|
23
23
|
#
|
24
|
-
def call(
|
24
|
+
def call(credentials)
|
25
25
|
webhooks = @client.get('webhooks')['webhooks']
|
26
26
|
|
27
27
|
webhooks.map do |webhook|
|
28
|
-
Thread.new { @delete_webhook.(
|
28
|
+
Thread.new { @delete_webhook.(credentials, webhook['id']) }
|
29
29
|
end.map(&:value)
|
30
30
|
end
|
31
31
|
end
|
@@ -12,13 +12,13 @@ module LucidShopify
|
|
12
12
|
end
|
13
13
|
|
14
14
|
#
|
15
|
-
# @param
|
15
|
+
# @param credentials [Credentials]
|
16
16
|
# @param id [Integer]
|
17
17
|
#
|
18
18
|
# @return [Hash] response data
|
19
19
|
#
|
20
|
-
def call(
|
21
|
-
@client.delete(
|
20
|
+
def call(credentials, id)
|
21
|
+
@client.delete(credentials, "webhooks/#{id}")
|
22
22
|
end
|
23
23
|
end
|
24
24
|
end
|
data/lib/lucid_shopify.rb
CHANGED
@@ -18,7 +18,7 @@ module LucidShopify
|
|
18
18
|
autoload :GetRequest, 'lucid_shopify/get_request'
|
19
19
|
autoload :PostRequest, 'lucid_shopify/post_request'
|
20
20
|
autoload :PutRequest, 'lucid_shopify/put_request'
|
21
|
-
autoload :
|
21
|
+
autoload :Credentials, 'lucid_shopify/credentials'
|
22
22
|
autoload :Request, 'lucid_shopify/request'
|
23
23
|
autoload :Response, 'lucid_shopify/response'
|
24
24
|
autoload :Result, 'lucid_shopify/result'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lucid_shopify
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.15.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kelsey Judson
|
@@ -124,6 +124,7 @@ files:
|
|
124
124
|
- lib/lucid_shopify/create_all_webhooks.rb
|
125
125
|
- lib/lucid_shopify/create_charge.rb
|
126
126
|
- lib/lucid_shopify/create_webhook.rb
|
127
|
+
- lib/lucid_shopify/credentials.rb
|
127
128
|
- lib/lucid_shopify/delete_all_webhooks.rb
|
128
129
|
- lib/lucid_shopify/delete_request.rb
|
129
130
|
- lib/lucid_shopify/delete_webhook.rb
|
@@ -132,7 +133,6 @@ files:
|
|
132
133
|
- lib/lucid_shopify/post_request.rb
|
133
134
|
- lib/lucid_shopify/put_request.rb
|
134
135
|
- lib/lucid_shopify/request.rb
|
135
|
-
- lib/lucid_shopify/request_credentials.rb
|
136
136
|
- lib/lucid_shopify/response.rb
|
137
137
|
- lib/lucid_shopify/send_request.rb
|
138
138
|
- lib/lucid_shopify/send_throttled_request.rb
|