amazon-drs 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.travis.yml +8 -4
- data/README.md +15 -0
- data/amazon-drs.gemspec +1 -1
- data/appveyor.yml +1 -1
- data/lib/amazon-drs/base.rb +2 -4
- data/lib/amazon-drs/client.rb +9 -12
- data/lib/amazon-drs/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: dbd372d19169a88d813da0be0337dc05fe2c7d432aa5cbe45e8ed5beb23e8de7
|
4
|
+
data.tar.gz: bac12aa1a7bf28c44c75f4e3241622d5eccb8eedda39073e2486bc0adf0cb878
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 47d9589b0ee48bc1b31e579961b5e910a226b1f4672b04ab000763fca1970fc38f661cea2b5ae13cc580e8962e5e2a0e7adbb7574d62a322c7626881697ac55e
|
7
|
+
data.tar.gz: 4b4e6b192e0c424c04d32071110dbcaa809c5e7f2bb2ad3fb377954fcd54e3cbed4e75e35d7f7bc64683e60631a2eae07410fec09f8cefc8f908eeb2eb375fa6
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -20,6 +20,21 @@ Or install it yourself as:
|
|
20
20
|
|
21
21
|
## Usage
|
22
22
|
|
23
|
+
```ruby
|
24
|
+
# Please use access_token what is prepared beforehand:
|
25
|
+
# https://rubygems.org/gems/omniauth-amazon
|
26
|
+
client = AmazonDrs::Client.new('device_model') do |c|
|
27
|
+
c.authorization_code = 'authorization_code'
|
28
|
+
c.serial = 'serial'
|
29
|
+
c.redirect_uri = 'http://redirect_uri/'
|
30
|
+
c.access_token = 'access_token'
|
31
|
+
c.refresh_token = 'refresh_token'
|
32
|
+
c.client_id = 'aaa'
|
33
|
+
c.client_secret = 'secret'
|
34
|
+
end
|
35
|
+
@drs.subscription_info
|
36
|
+
```
|
37
|
+
|
23
38
|
## Contributing
|
24
39
|
|
25
40
|
Bug reports and pull requests are welcome on GitHub at https://github.com/aycabta/amazon-drs.
|
data/amazon-drs.gemspec
CHANGED
@@ -19,7 +19,7 @@ Gem::Specification.new do |spec|
|
|
19
19
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
20
|
spec.require_paths = ['lib']
|
21
21
|
|
22
|
-
spec.required_ruby_version = Gem::Requirement.new('>= 2.2.
|
22
|
+
spec.required_ruby_version = Gem::Requirement.new('>= 2.2.9')
|
23
23
|
|
24
24
|
spec.add_development_dependency 'bundler'
|
25
25
|
spec.add_development_dependency 'rake'
|
data/appveyor.yml
CHANGED
data/lib/amazon-drs/base.rb
CHANGED
@@ -11,7 +11,7 @@ module AmazonDrs
|
|
11
11
|
parse_body(response.body)
|
12
12
|
end
|
13
13
|
|
14
|
-
def parse_header(response)
|
14
|
+
private def parse_header(response)
|
15
15
|
response.each do |key, value|
|
16
16
|
case key.downcase
|
17
17
|
when 'x-amzn-errortype'
|
@@ -30,12 +30,10 @@ module AmazonDrs
|
|
30
30
|
end
|
31
31
|
end
|
32
32
|
end
|
33
|
-
private :parse_header
|
34
33
|
|
35
|
-
def parse_body(body)
|
34
|
+
private def parse_body(body)
|
36
35
|
# abstract
|
37
36
|
end
|
38
|
-
private :parse_body
|
39
37
|
|
40
38
|
def inspect
|
41
39
|
if @status_code == 200
|
data/lib/amazon-drs/client.rb
CHANGED
@@ -65,6 +65,7 @@ module AmazonDrs
|
|
65
65
|
end
|
66
66
|
end
|
67
67
|
|
68
|
+
# https://developer.amazon.com/public/solutions/devices/dash-replenishment-service/docs/dash-getsubscriptioninfo-endpoint
|
68
69
|
def subscription_info
|
69
70
|
headers = {
|
70
71
|
'x-amzn-accept-type': 'com.amazon.dash.replenishment.DrsSubscriptionInfoResult@1.0',
|
@@ -79,6 +80,7 @@ module AmazonDrs
|
|
79
80
|
end
|
80
81
|
end
|
81
82
|
|
83
|
+
# https://developer.amazon.com/public/solutions/devices/dash-replenishment-service/docs/dash-slotstatus-endpoint
|
82
84
|
def slot_status(slot_id, expected_replenishment_date, remaining_quantity_in_unit, original_quantity_in_unit, total_quantity_on_hand, last_use_date)
|
83
85
|
headers = {
|
84
86
|
'x-amzn-accept-type': 'com.amazon.dash.replenishment.DrsSlotStatusResult@1.0',
|
@@ -100,6 +102,7 @@ module AmazonDrs
|
|
100
102
|
end
|
101
103
|
end
|
102
104
|
|
105
|
+
# https://developer.amazon.com/public/solutions/devices/dash-replenishment-service/docs/dash-replenish-endpoint
|
103
106
|
def replenish(slot_id)
|
104
107
|
headers = {
|
105
108
|
'x-amzn-accept-type': 'com.amazon.dash.replenishment.DrsReplenishResult@1.0',
|
@@ -139,7 +142,7 @@ module AmazonDrs
|
|
139
142
|
end
|
140
143
|
end
|
141
144
|
|
142
|
-
def convert_to_iso8601(input)
|
145
|
+
private def convert_to_iso8601(input)
|
143
146
|
case input
|
144
147
|
when Date, Time
|
145
148
|
input.iso8601
|
@@ -149,9 +152,8 @@ module AmazonDrs
|
|
149
152
|
input.to_s
|
150
153
|
end
|
151
154
|
end
|
152
|
-
private :convert_to_iso8601
|
153
155
|
|
154
|
-
def process_token_response(resp)
|
156
|
+
private def process_token_response(resp)
|
155
157
|
if resp.kind_of?(AmazonDrs::Error)
|
156
158
|
nil
|
157
159
|
else
|
@@ -161,9 +163,8 @@ module AmazonDrs
|
|
161
163
|
@access_token
|
162
164
|
end
|
163
165
|
end
|
164
|
-
private :process_token_response
|
165
166
|
|
166
|
-
def request_drs(method, path, headers: {}, params: {})
|
167
|
+
private def request_drs(method, path, headers: {}, params: {})
|
167
168
|
url = "https://#{@drs_host}#{path}"
|
168
169
|
if @authorization_code.nil?
|
169
170
|
raise 'Authorization Code is not set'
|
@@ -184,9 +185,8 @@ module AmazonDrs
|
|
184
185
|
resp
|
185
186
|
end
|
186
187
|
end
|
187
|
-
private :request_drs
|
188
188
|
|
189
|
-
def refresh_access_token
|
189
|
+
private def refresh_access_token
|
190
190
|
params = {
|
191
191
|
grant_type: 'refresh_token',
|
192
192
|
refresh_token: @refresh_token,
|
@@ -196,9 +196,8 @@ module AmazonDrs
|
|
196
196
|
@access_token = nil
|
197
197
|
request(:post, "https://#{@amazon_host}/auth/o2/token", params: params)
|
198
198
|
end
|
199
|
-
private :refresh_access_token
|
200
199
|
|
201
|
-
def request_token
|
200
|
+
private def request_token
|
202
201
|
params = {
|
203
202
|
grant_type: 'authorization_code',
|
204
203
|
code: @authorization_code,
|
@@ -213,9 +212,8 @@ module AmazonDrs
|
|
213
212
|
::AmazonDrs::Error.new(response)
|
214
213
|
end
|
215
214
|
end
|
216
|
-
private :request_token
|
217
215
|
|
218
|
-
def request(method, url, headers: {}, params: {})
|
216
|
+
private def request(method, url, headers: {}, params: {})
|
219
217
|
uri = URI.parse(url)
|
220
218
|
if params.any?{ |key, value| value.is_a?(Enumerable) }
|
221
219
|
converted_params = []
|
@@ -253,6 +251,5 @@ module AmazonDrs
|
|
253
251
|
http.use_ssl = true
|
254
252
|
http.request(request)
|
255
253
|
end
|
256
|
-
private :request
|
257
254
|
end
|
258
255
|
end
|
data/lib/amazon-drs/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: amazon-drs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Code Ass
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-01-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -110,7 +110,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
110
110
|
requirements:
|
111
111
|
- - ">="
|
112
112
|
- !ruby/object:Gem::Version
|
113
|
-
version: 2.2.
|
113
|
+
version: 2.2.9
|
114
114
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
115
115
|
requirements:
|
116
116
|
- - ">="
|
@@ -118,7 +118,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
118
118
|
version: '0'
|
119
119
|
requirements: []
|
120
120
|
rubyforge_project:
|
121
|
-
rubygems_version: 2.
|
121
|
+
rubygems_version: 2.7.3
|
122
122
|
signing_key:
|
123
123
|
specification_version: 4
|
124
124
|
summary: amazon-drs is for Amazon Dash Replenishment Service
|