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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 11642f45e00463fcc89f57bb19d198192870ba8da5d08f4b58c15b6d81b9fc17
4
- data.tar.gz: 27f2562f2e91badf805f28f670d43c5420b76b0cb3b68c0ca1982244f4762dce
3
+ metadata.gz: 653ddf7f8c324f940bf9e2d704910377e34f015eee770b52ce8b0928781dcdd1
4
+ data.tar.gz: e82a027e61ab3d5af7edcad6457bb5e69db804589bb9dce6dc5f65e09f78d199
5
5
  SHA512:
6
- metadata.gz: d881b0f7703e965ff3b1a33117ce4f9a847189b0b7f24614565363e3ff183fab8d2b2c91acad11e7b51a7c3fa9b658b0029ad8cceba90d5d7118156b084456a4
7
- data.tar.gz: b418d1c1418301ea8142e03c928fb07687df36ff717d3c3e2ab79e7c3df726ffb709a4d9e5b3594be45461818941713d8a372f8f691d6ce9f634ab3fced10f94
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
- request_credentials = LucidShopify::RequestCredentials.new(
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.(request_credentials)
72
- LucidShopify::DeleteAllWebhooks.new.(request_credentials)
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.(request_credentials, webhook)
79
- LucidShopify::DeleteWebhook.new.(request_credentials, webhook_id)
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.(request_credentials, authorization_code)
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.(request_credentials, charge) # see LucidShopify::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.(request_credentials, accepted_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(request_credentials, 'orders', since_id: since_id)['orders']
130
- client.post_json(request_credentials, 'orders', new_order)
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(request_credentials, 'orders')
136
- client.throttled.post_json(request_credentials, 'orders', new_order)
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 request_credentials [RequestCredentials]
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(request_credentials, charge)
23
- data = @client.post_json(request_credentials, "recurring_application_charges/#{charge.to_h['id']}/activate", charge.to_h)
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
- request_credentials = RequestCredentials.new(myshopify_domain)
27
+ credentials = Credentials.new(myshopify_domain)
28
28
 
29
- data = @client.post_json(request_credentials, 'oauth/access_token', post_data(authorization_code))
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 request_credentials [RequestCredentials]
18
+ # @param credentials [Credentials]
19
19
  # @param webhooks [WebhookList]
20
20
  #
21
21
  # @return [Array<Hash>] response data
22
22
  #
23
- def call(request_credentials, webhooks: Container[:webhook_list])
23
+ def call(credentials, webhooks: Container[:webhook_list])
24
24
  webhooks.map do |webhook|
25
- Thread.new { @create_webhook.(request_credentials, 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 request_credentials [RequestCredentials]
17
+ # @param credentials [Credentials]
18
18
  # @param charge [Hash]
19
19
  #
20
20
  # @return [Hash] the pending charge
21
21
  #
22
- def call(request_credentials, charge)
23
- data = @client.post_json(request_credentials, 'recurring_application_charges', post_data(charge))
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 request_credentials [RequestCredentials]
15
+ # @param credentials [Credentials]
16
16
  # @param webhook [Hash]
17
17
  #
18
18
  # @return [Hash] response data
19
19
  #
20
- def call(request_credentials, webhook)
20
+ def call(credentials, webhook)
21
21
  data = {**webhook, address: LucidShopify.config.webhook_uri}
22
22
 
23
- @client.post_json(request_credentials, 'webhooks', webhook: data)
23
+ @client.post_json(credentials, 'webhooks', webhook: data)
24
24
  end
25
25
  end
26
26
  end
@@ -3,7 +3,7 @@
3
3
  require 'lucid_shopify'
4
4
 
5
5
  module LucidShopify
6
- class RequestCredentials
6
+ class Credentials
7
7
  extend Dry::Initializer
8
8
 
9
9
  # @return [String]
@@ -17,15 +17,15 @@ module LucidShopify
17
17
  #
18
18
  # Delete any existing webhooks.
19
19
  #
20
- # @param request_credentials [RequestCredentials]
20
+ # @param credentials [Credentials]
21
21
  #
22
22
  # @return [Array<Hash>] response data
23
23
  #
24
- def call(request_credentials)
24
+ def call(credentials)
25
25
  webhooks = @client.get('webhooks')['webhooks']
26
26
 
27
27
  webhooks.map do |webhook|
28
- Thread.new { @delete_webhook.(request_credentials, webhook['id']) }
28
+ Thread.new { @delete_webhook.(credentials, webhook['id']) }
29
29
  end.map(&:value)
30
30
  end
31
31
  end
@@ -7,7 +7,7 @@ module LucidShopify
7
7
  #
8
8
  # @private
9
9
  #
10
- # @param credentials [RequestCredentials]
10
+ # @param credentials [Credentials]
11
11
  # @param path [String] the endpoint relative to the base URL
12
12
  #
13
13
  def initialize(credentials, path)
@@ -12,13 +12,13 @@ module LucidShopify
12
12
  end
13
13
 
14
14
  #
15
- # @param request_credentials [RequestCredentials]
15
+ # @param credentials [Credentials]
16
16
  # @param id [Integer]
17
17
  #
18
18
  # @return [Hash] response data
19
19
  #
20
- def call(request_credentials, id)
21
- @client.delete(request_credentials, "webhooks/#{id}")
20
+ def call(credentials, id)
21
+ @client.delete(credentials, "webhooks/#{id}")
22
22
  end
23
23
  end
24
24
  end
@@ -7,7 +7,7 @@ module LucidShopify
7
7
  #
8
8
  # @private
9
9
  #
10
- # @param credentials [RequestCredentials]
10
+ # @param credentials [Credentials]
11
11
  # @param path [String] the endpoint relative to the base URL
12
12
  # @param params [Hash] the query params
13
13
  #
@@ -7,7 +7,7 @@ module LucidShopify
7
7
  #
8
8
  # @private
9
9
  #
10
- # @param credentials [RequestCredentials]
10
+ # @param credentials [Credentials]
11
11
  # @param path [String] the endpoint relative to the base URL
12
12
  # @param json [Hash] the JSON request body
13
13
  #
@@ -7,7 +7,7 @@ module LucidShopify
7
7
  #
8
8
  # @private
9
9
  #
10
- # @param credentials [RequestCredentials]
10
+ # @param credentials [Credentials]
11
11
  # @param path [String] the endpoint relative to the base URL
12
12
  # @param json [Hash] the JSON request body
13
13
  #
@@ -9,7 +9,7 @@ module LucidShopify
9
9
  class Request
10
10
  extend Dry::Initializer
11
11
 
12
- # @return [RequestCredentials]
12
+ # @return [Credentials]
13
13
  param :credentials
14
14
  # @return [Symbol]
15
15
  param :http_method
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module LucidShopify
4
- VERSION = '0.14.0'
4
+ VERSION = '0.15.0'
5
5
  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 :RequestCredentials, 'lucid_shopify/request_credentials'
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.14.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