lucid-shopify 0.36.0 → 0.37.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +13 -24
- data/lib/lucid/shopify/client.rb +24 -0
- data/lib/lucid/shopify/container.rb +0 -1
- data/lib/lucid/shopify/version.rb +1 -1
- data/lib/lucid/shopify.rb +11 -2
- metadata +17 -18
- data/lib/lucid/shopify/config.rb +0 -51
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 514e2e06b6f26b6bb7cf487e1c8bdf15ced2d6f22edc0999bb938d80ed56b84e
|
4
|
+
data.tar.gz: '00976c459f606e71d097a016b1529f2e735366a49ff0972da489522638501170'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4a90a8ecb406a9ebdd61d3605a278a5a1f9de09133b26561b406f8fefa4bbeccea2db2d46f060b55bf5c54a9b8a01ba5b1f97b345b1d582578bedcafdb514cfb
|
7
|
+
data.tar.gz: 8b3649891e6cc04e146b8e793cd959c52169b94bb1deb06ae65191fe40e91b87ac31d713be6db50f97176c7f8e7c105dd9955a7413a6aa7723b9f64e690ed99b
|
data/README.md
CHANGED
@@ -14,28 +14,19 @@ Usage
|
|
14
14
|
|
15
15
|
### Configure the default API client
|
16
16
|
|
17
|
-
Lucid::Shopify.configure
|
18
|
-
api_key
|
19
|
-
api_version
|
20
|
-
billing_callback_uri
|
21
|
-
callback_uri
|
22
|
-
logger
|
23
|
-
scope
|
24
|
-
shared_secret
|
25
|
-
webhook_uri
|
26
|
-
|
27
|
-
|
28
|
-
Alternatively load the configuration from a Ruby file. The Ruby
|
29
|
-
file is evaluated and should return a hash.
|
30
|
-
|
31
|
-
Lucid::Shopify.configure_from_file('config/shopify.rb') # the default path
|
32
|
-
|
33
|
-
When loading from a file, any environment variables matching the
|
34
|
-
upcased key with the prefix ‘SHOPIFY_’ will override values in the
|
35
|
-
file. For example ‘SHOPIFY_SHARED_SECRET=...’.
|
17
|
+
Lucid::Shopify.configure do |config|
|
18
|
+
config.api_key = '...'
|
19
|
+
config.api_version = '...' # e.g. '2019-07'
|
20
|
+
config.billing_callback_uri = '...'
|
21
|
+
config.callback_uri = '...' # (for OAuth; unused by this gem)
|
22
|
+
config.logger = Logger.new(STDOUT)
|
23
|
+
config.scope = '...'
|
24
|
+
config.shared_secret = '...'
|
25
|
+
config.webhook_uri = '...'
|
26
|
+
end
|
36
27
|
|
37
|
-
All
|
38
|
-
any configuration at all.
|
28
|
+
All settings are optional and in some private apps, you may not
|
29
|
+
require any configuration at all.
|
39
30
|
|
40
31
|
Additionally, each API request requires authorisation:
|
41
32
|
|
@@ -142,9 +133,7 @@ charge:
|
|
142
133
|
|
143
134
|
Request logging is disabled by default. To enable it:
|
144
135
|
|
145
|
-
Lucid::Shopify.
|
146
|
-
logger: Logger.new(STDOUT),
|
147
|
-
)
|
136
|
+
Lucid::Shopify.config.logger = Logger.new(STDOUT)
|
148
137
|
|
149
138
|
|
150
139
|
### Make throttled API requests
|
data/lib/lucid/shopify/client.rb
CHANGED
@@ -50,6 +50,13 @@ module Lucid
|
|
50
50
|
self.class.new(**@params, throttling: false)
|
51
51
|
end
|
52
52
|
|
53
|
+
# @param credentials [Credentials]
|
54
|
+
#
|
55
|
+
# @return [AuthenticatedClient]
|
56
|
+
def authenticate(credentials)
|
57
|
+
AuthenticatedClient.new(self, credentials)
|
58
|
+
end
|
59
|
+
|
53
60
|
# @see DeleteRequest#initialize
|
54
61
|
def delete(*args)
|
55
62
|
send_request.(DeleteRequest.new(*args))
|
@@ -70,5 +77,22 @@ module Lucid
|
|
70
77
|
send_request.(PutRequest.new(*args))
|
71
78
|
end
|
72
79
|
end
|
80
|
+
|
81
|
+
class AuthenticatedClient
|
82
|
+
# @private
|
83
|
+
#
|
84
|
+
# @param client [Client]
|
85
|
+
# @param credentials [Credentials]
|
86
|
+
def initialize(client, credentials)
|
87
|
+
@client = client
|
88
|
+
@credentials = credentials
|
89
|
+
end
|
90
|
+
|
91
|
+
%i[delete get post_json put_json].each do |method|
|
92
|
+
define_method(method) do |*args|
|
93
|
+
@client.__send__(method, @credentials, *args)
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
73
97
|
end
|
74
98
|
end
|
data/lib/lucid/shopify.rb
CHANGED
@@ -39,6 +39,17 @@ module Lucid
|
|
39
39
|
autoload :WebhookHandlerList, 'lucid/shopify/webhook_handler_list'
|
40
40
|
autoload :WebhookList, 'lucid/shopify/webhook_list'
|
41
41
|
|
42
|
+
extend Dry::Configurable
|
43
|
+
|
44
|
+
setting :api_key
|
45
|
+
setting :api_version, '2019-07'
|
46
|
+
setting :billing_callback_uri
|
47
|
+
setting :callback_uri
|
48
|
+
setting :logger, Logger.new(File::NULL).freeze
|
49
|
+
setting :scope
|
50
|
+
setting :shared_secret
|
51
|
+
setting :webhook_uri
|
52
|
+
|
42
53
|
class << self
|
43
54
|
# Webhooks created for each shop.
|
44
55
|
#
|
@@ -67,5 +78,3 @@ module Lucid
|
|
67
78
|
end
|
68
79
|
end
|
69
80
|
end
|
70
|
-
|
71
|
-
require 'lucid/shopify/config'
|
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.37.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:
|
11
|
+
date: 2020-01-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dotenv
|
@@ -66,6 +66,20 @@ dependencies:
|
|
66
66
|
- - '='
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0.67'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: dry-configurable
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0.9'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0.9'
|
69
83
|
- !ruby/object:Gem::Dependency
|
70
84
|
name: dry-container
|
71
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -122,20 +136,6 @@ dependencies:
|
|
122
136
|
- - "~>"
|
123
137
|
- !ruby/object:Gem::Version
|
124
138
|
version: '4.1'
|
125
|
-
- !ruby/object:Gem::Dependency
|
126
|
-
name: lucid-utils
|
127
|
-
requirement: !ruby/object:Gem::Requirement
|
128
|
-
requirements:
|
129
|
-
- - "~>"
|
130
|
-
- !ruby/object:Gem::Version
|
131
|
-
version: '0.1'
|
132
|
-
type: :runtime
|
133
|
-
prerelease: false
|
134
|
-
version_requirements: !ruby/object:Gem::Requirement
|
135
|
-
requirements:
|
136
|
-
- - "~>"
|
137
|
-
- !ruby/object:Gem::Version
|
138
|
-
version: '0.1'
|
139
139
|
description:
|
140
140
|
email: kelsey@lucid.nz
|
141
141
|
executables: []
|
@@ -148,7 +148,6 @@ files:
|
|
148
148
|
- lib/lucid/shopify/activate_charge.rb
|
149
149
|
- lib/lucid/shopify/authorise.rb
|
150
150
|
- lib/lucid/shopify/client.rb
|
151
|
-
- lib/lucid/shopify/config.rb
|
152
151
|
- lib/lucid/shopify/container.rb
|
153
152
|
- lib/lucid/shopify/create_all_webhooks.rb
|
154
153
|
- lib/lucid/shopify/create_charge.rb
|
@@ -192,7 +191,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
192
191
|
- !ruby/object:Gem::Version
|
193
192
|
version: '0'
|
194
193
|
requirements: []
|
195
|
-
rubygems_version: 3.
|
194
|
+
rubygems_version: 3.1.2
|
196
195
|
signing_key:
|
197
196
|
specification_version: 4
|
198
197
|
summary: Shopify client library
|
data/lib/lucid/shopify/config.rb
DELETED
@@ -1,51 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'logger'
|
4
|
-
|
5
|
-
require 'lucid/shopify'
|
6
|
-
require 'lucid/utils'
|
7
|
-
|
8
|
-
module Lucid
|
9
|
-
module Shopify
|
10
|
-
class << self
|
11
|
-
# @param options [Hash]
|
12
|
-
#
|
13
|
-
# @return [Config]
|
14
|
-
def configure(options = {})
|
15
|
-
@config = Config.new(
|
16
|
-
**@config.to_h.compact,
|
17
|
-
**options,
|
18
|
-
)
|
19
|
-
end
|
20
|
-
|
21
|
-
# @param path [String]
|
22
|
-
#
|
23
|
-
# @return [Config]
|
24
|
-
def configure_from_file(path = 'config/shopify.rb')
|
25
|
-
options = Utils::ConfigFromFile.new.(path, env_prefix: 'shopify')
|
26
|
-
|
27
|
-
configure(options)
|
28
|
-
end
|
29
|
-
|
30
|
-
# @return [Config]
|
31
|
-
def config
|
32
|
-
@config ||= configure
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
class Config < Dry::Struct
|
37
|
-
attribute :api_version, Types::String.default('2019-07')
|
38
|
-
attribute :logger, Types::Logger.default(Logger.new(File::NULL).freeze)
|
39
|
-
|
40
|
-
# The following attributes may be unnecessary in some private apps.
|
41
|
-
attribute? :api_key, Types::String
|
42
|
-
attribute? :billing_callback_uri, Types::String
|
43
|
-
attribute? :callback_uri, Types::String
|
44
|
-
attribute? :scope, Types::String
|
45
|
-
attribute? :shared_secret, Types::String
|
46
|
-
attribute? :webhook_uri, Types::String
|
47
|
-
end
|
48
|
-
|
49
|
-
self.configure
|
50
|
-
end
|
51
|
-
end
|