lucid_shopify 0.28.1 → 0.31.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 +22 -12
- data/lib/lucid_shopify/config.rb +31 -54
- data/lib/lucid_shopify/types.rb +9 -0
- data/lib/lucid_shopify/version.rb +1 -1
- data/lib/lucid_shopify.rb +2 -0
- metadata +31 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a99dcbd8e551ee898a53837cd9a91bb62bac7223038eac70109ddd3424b249c8
|
4
|
+
data.tar.gz: 10aad4e20e50af8facb41cd9d624e8867d1ef2d1707067566d9fb4ca3a2b72c8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d0f44d70b758e58aec0cb6798d424c0f67a3e614f1f160b86e5f27e0bf5cf590243745e491ef4a1b6e9f8ae7c1364c1ab05028239fe7aeef51e7455e160d0386
|
7
|
+
data.tar.gz: 6ea021837da9b31acf7063bf7c43b932145e2dc79db06d0291900d85ef287dfd5f18a45ca0772794a57d249ec54153ee3ebe4236bb806dc6b253abc9c492e42d
|
data/README.md
CHANGED
@@ -14,20 +14,28 @@ Usage
|
|
14
14
|
|
15
15
|
### Configure the default API client
|
16
16
|
|
17
|
-
LucidShopify.
|
18
|
-
'...',
|
19
|
-
'...', #
|
20
|
-
'...',
|
21
|
-
'...', #
|
22
|
-
|
23
|
-
'...',
|
24
|
-
'...',
|
17
|
+
LucidShopify.configure(
|
18
|
+
api_key: '...',
|
19
|
+
api_version: '...', # e.g. '2019-07'
|
20
|
+
billing_callback_uri: '...',
|
21
|
+
callback_uri: '...', # (for OAuth; unused by this gem)
|
22
|
+
logger: Logger.new(STDOUT),
|
23
|
+
scope: '...',
|
24
|
+
shared_secret: '...',
|
25
|
+
webhook_uri: '...',
|
25
26
|
)
|
26
27
|
|
27
|
-
|
28
|
-
|
28
|
+
Alternatively load the configuration from a Ruby file. The Ruby
|
29
|
+
file is evaluated and should return a hash.
|
29
30
|
|
30
|
-
LucidShopify.config
|
31
|
+
LucidShopify.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=...’.
|
36
|
+
|
37
|
+
All keys are optional and in some private apps, you may not require
|
38
|
+
any configuration at all.
|
31
39
|
|
32
40
|
Additionally, each API request requires authorisation:
|
33
41
|
|
@@ -134,7 +142,9 @@ charge:
|
|
134
142
|
|
135
143
|
Request logging is disabled by default. To enable it:
|
136
144
|
|
137
|
-
LucidShopify.
|
145
|
+
LucidShopify.configure(
|
146
|
+
logger: Logger.new(STDOUT),
|
147
|
+
)
|
138
148
|
|
139
149
|
|
140
150
|
### Make throttled API requests
|
data/lib/lucid_shopify/config.rb
CHANGED
@@ -1,78 +1,55 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'forwardable'
|
4
3
|
require 'logger'
|
5
4
|
|
6
5
|
require 'lucid_shopify'
|
6
|
+
require 'lucid_utils'
|
7
7
|
|
8
8
|
module LucidShopify
|
9
|
-
NotConfiguredError = Class.new(Error)
|
10
|
-
|
11
9
|
class << self
|
12
|
-
extend Forwardable
|
13
|
-
|
14
|
-
def_delegators(
|
15
|
-
:config,
|
16
|
-
:api_version,
|
17
|
-
:api_key,
|
18
|
-
:shared_secret,
|
19
|
-
:scope,
|
20
|
-
:billing_callback_uri,
|
21
|
-
:webhook_uri,
|
22
|
-
:logger
|
23
|
-
)
|
24
|
-
|
25
|
-
# @param config [Config]
|
26
|
-
attr_writer :config
|
27
|
-
|
28
10
|
#
|
29
|
-
# @
|
11
|
+
# @param options [Hash]
|
30
12
|
#
|
31
|
-
# @
|
13
|
+
# @return [Config]
|
32
14
|
#
|
33
|
-
def
|
34
|
-
|
35
|
-
|
36
|
-
|
15
|
+
def configure(options = {})
|
16
|
+
@config = Config.new(
|
17
|
+
**@config.to_h.compact,
|
18
|
+
**options,
|
19
|
+
)
|
37
20
|
end
|
38
|
-
end
|
39
|
-
|
40
|
-
class Config
|
41
|
-
extend Dry::Initializer
|
42
|
-
|
43
|
-
# @return [String]
|
44
|
-
param :api_version
|
45
|
-
# @return [String]
|
46
|
-
param :api_key
|
47
|
-
# @return [String]
|
48
|
-
param :shared_secret
|
49
|
-
# @return [String]
|
50
|
-
param :scope
|
51
|
-
# @return [String]
|
52
|
-
param :callback_uri
|
53
|
-
# @return [String]
|
54
|
-
param :billing_callback_uri
|
55
|
-
# @return [String]
|
56
|
-
param :webhook_uri
|
57
21
|
|
58
22
|
#
|
59
|
-
# @
|
23
|
+
# @param path [String]
|
60
24
|
#
|
61
|
-
|
62
|
-
|
25
|
+
# @return [Config]
|
26
|
+
#
|
27
|
+
def configure_from_file(path = 'config/shopify.rb')
|
28
|
+
options = LucidUtils::ConfigFromFile.new.(path, env_prefix: 'shopify')
|
29
|
+
|
30
|
+
configure(options)
|
63
31
|
end
|
64
32
|
|
65
33
|
#
|
66
|
-
# @
|
34
|
+
# @return [Config]
|
67
35
|
#
|
68
|
-
def
|
69
|
-
|
70
|
-
|
71
|
-
@logger = new_logger
|
36
|
+
def config
|
37
|
+
@config ||= configure
|
72
38
|
end
|
39
|
+
end
|
73
40
|
|
74
|
-
|
41
|
+
class Config < Dry::Struct
|
42
|
+
attribute :api_version, Types::String.default('2019-07')
|
43
|
+
attribute :logger, Types::Logger.default(Logger.new(File::NULL).freeze)
|
44
|
+
|
45
|
+
# The following attributes may be unnecessary in some private apps.
|
46
|
+
attribute? :api_key, Types::String
|
47
|
+
attribute? :billing_callback_uri, Types::String
|
48
|
+
attribute? :callback_uri, Types::String
|
49
|
+
attribute? :scope, Types::String
|
50
|
+
attribute? :shared_secret, Types::String
|
51
|
+
attribute? :webhook_uri, Types::String
|
75
52
|
end
|
76
53
|
|
77
|
-
self.
|
54
|
+
self.configure
|
78
55
|
end
|
data/lib/lucid_shopify.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'dry/initializer'
|
4
|
+
require 'dry/struct'
|
4
5
|
|
5
6
|
begin
|
6
7
|
require 'redis'
|
@@ -29,6 +30,7 @@ module LucidShopify
|
|
29
30
|
autoload :Result, 'lucid_shopify/result'
|
30
31
|
autoload :SendRequest, 'lucid_shopify/send_request'
|
31
32
|
autoload :ThrottledStrategy, 'lucid_shopify/throttled_strategy'
|
33
|
+
autoload :Types, 'lucid_shopify/types'
|
32
34
|
autoload :VerifyCallback, 'lucid_shopify/verify_callback'
|
33
35
|
autoload :VerifyWebhook, 'lucid_shopify/verify_webhook'
|
34
36
|
autoload :VERSION, 'lucid_shopify/version'
|
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.31.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-08-
|
11
|
+
date: 2019-08-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dotenv
|
@@ -94,6 +94,20 @@ dependencies:
|
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '3.0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: dry-struct
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '1.0'
|
104
|
+
type: :runtime
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '1.0'
|
97
111
|
- !ruby/object:Gem::Dependency
|
98
112
|
name: http
|
99
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -108,6 +122,20 @@ dependencies:
|
|
108
122
|
- - "~>"
|
109
123
|
- !ruby/object:Gem::Version
|
110
124
|
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.0'
|
132
|
+
type: :runtime
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - "~>"
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0.0'
|
111
139
|
description:
|
112
140
|
email: kelsey@lucid.nz
|
113
141
|
executables: []
|
@@ -137,6 +165,7 @@ files:
|
|
137
165
|
- lib/lucid_shopify/response.rb
|
138
166
|
- lib/lucid_shopify/send_request.rb
|
139
167
|
- lib/lucid_shopify/throttled_strategy.rb
|
168
|
+
- lib/lucid_shopify/types.rb
|
140
169
|
- lib/lucid_shopify/verify_callback.rb
|
141
170
|
- lib/lucid_shopify/verify_webhook.rb
|
142
171
|
- lib/lucid_shopify/version.rb
|