oreilly_api 1.0.1 → 1.0.3
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/.rspec_status +6 -6
- data/Gemfile.lock +1 -1
- data/README.md +0 -1
- data/Rakefile +4 -0
- data/lib/oreilly_api/version.rb +1 -1
- data/lib/oreilly_api.rb +13 -12
- 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: c9f5038e7928719e445cdd07449a7d88f1dfe2bf82cdf47db6d51d31dd5ba081
|
4
|
+
data.tar.gz: f2a09c91d003feb1774df8b3a6dae3de07d618689f7ba75b5ff76799da9d322f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '038a777daaddf9708f22a84afa6fa0d830283868ca26ac2ff15df3ccb433b66157a98284f0d5f6b172fa4b81a3482b58a84730d2215ffa9b3d049b58552941d3'
|
7
|
+
data.tar.gz: 8fcedc483cbb2e88cd2ce74e8e40f196f977a049294639cddf7c32c9185d304f80a2b48e7bc7c87c81bc2381125d05972938f4501692dc536a6f9428380f64f5
|
data/.rspec_status
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
example_id | status | run_time |
|
2
2
|
------------------------------- | ------- | --------------- |
|
3
|
-
./spec/oreilly_api_spec.rb[1:1] | passed | 0.
|
4
|
-
./spec/oreilly_api_spec.rb[1:2] | passed | 0.
|
5
|
-
./spec/oreilly_api_spec.rb[1:3] | passed | 0.
|
6
|
-
./spec/oreilly_api_spec.rb[1:4] | pending | 0.
|
7
|
-
./spec/oreilly_api_spec.rb[1:5] | passed | 0.
|
8
|
-
./spec/oreilly_api_spec.rb[1:6] | passed | 0.
|
3
|
+
./spec/oreilly_api_spec.rb[1:1] | passed | 0.00108 seconds |
|
4
|
+
./spec/oreilly_api_spec.rb[1:2] | passed | 0.0281 seconds |
|
5
|
+
./spec/oreilly_api_spec.rb[1:3] | passed | 0.00814 seconds |
|
6
|
+
./spec/oreilly_api_spec.rb[1:4] | pending | 0.00002 seconds |
|
7
|
+
./spec/oreilly_api_spec.rb[1:5] | passed | 0.01212 seconds |
|
8
|
+
./spec/oreilly_api_spec.rb[1:6] | passed | 0.01094 seconds |
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
data/Rakefile
CHANGED
data/lib/oreilly_api/version.rb
CHANGED
data/lib/oreilly_api.rb
CHANGED
@@ -8,12 +8,13 @@ require 'redis'
|
|
8
8
|
require 'redis_utility'
|
9
9
|
|
10
10
|
# rubocop:disable Metrics/MethodLength
|
11
|
+
# rubocop:disable Layout/LineLength
|
11
12
|
|
12
13
|
# OreillyApi
|
13
14
|
module OreillyApi
|
14
15
|
TOKEN = 'oreilly_api_token'
|
15
16
|
class << self
|
16
|
-
attr_accessor :domain, :version, :client_id, :client_secret, :identity, :
|
17
|
+
attr_accessor :domain, :version, :client_id, :client_secret, :identity, :device_id
|
17
18
|
|
18
19
|
def config
|
19
20
|
yield self
|
@@ -23,22 +24,21 @@ module OreillyApi
|
|
23
24
|
RedisUtility.redis_config = redis_config
|
24
25
|
end
|
25
26
|
|
26
|
-
def payload_id
|
27
|
-
"YM#{
|
27
|
+
def payload_id(account_number)
|
28
|
+
"YM#{account_number}#{DateTime.now.strftime('%Y%m%d%l%S%M')}"
|
28
29
|
end
|
29
30
|
|
30
|
-
def place_order(po_number,
|
31
|
+
def place_order(po_number, account_number, vehicles_with_items, stop_order: false)
|
31
32
|
payload = {
|
32
33
|
'header' => {
|
33
34
|
'identity' => OreillyApi.identity,
|
34
|
-
'payloadId' => OreillyApi.payload_id,
|
35
|
+
'payloadId' => OreillyApi.payload_id(account_number),
|
35
36
|
'timestamp' => Time.now.strftime("%Y-%m-%d %H:%M:%S")
|
36
37
|
},
|
37
38
|
'orderHeader' => {
|
38
39
|
'poNumber' => po_number,
|
39
|
-
'
|
40
|
-
'
|
41
|
-
'comments' => "test"
|
40
|
+
'accountNumber' => account_number,
|
41
|
+
'comments' => "comments"
|
42
42
|
},
|
43
43
|
'vehicles' => vehicles_with_items
|
44
44
|
}.to_json
|
@@ -49,12 +49,12 @@ module OreillyApi
|
|
49
49
|
[res.code, place_order_response]
|
50
50
|
end
|
51
51
|
|
52
|
-
def fetch_quote(items)
|
52
|
+
def fetch_quote(items, account_number)
|
53
53
|
payload = {
|
54
|
-
'accountNumber' =>
|
54
|
+
'accountNumber' => account_number,
|
55
55
|
'header' => {
|
56
56
|
'identity' => OreillyApi.identity,
|
57
|
-
'payloadId' => OreillyApi.payload_id,
|
57
|
+
'payloadId' => OreillyApi.payload_id(account_number),
|
58
58
|
'timestamp' => Time.now.strftime("%Y-%m-%d %H:%M:%S")
|
59
59
|
},
|
60
60
|
'items' => items
|
@@ -105,7 +105,7 @@ module OreillyApi
|
|
105
105
|
}.to_json
|
106
106
|
|
107
107
|
params = "&client_id=#{OreillyApi.client_id}&client_secret=#{OreillyApi.client_secret}"
|
108
|
-
url = "#{OreillyApi.domain}/oauth-server/oauth/token?grant_type=client_credentials&device_id
|
108
|
+
url = "#{OreillyApi.domain}/oauth-server/oauth/token?grant_type=client_credentials&device_id=#{OreillyApi.device_id}#{params}"
|
109
109
|
res = RestClient.post(url, payload, { 'Content-Type' => 'application/json' })
|
110
110
|
token_info = JSON.parse(res)
|
111
111
|
@token = token_info['access_token']
|
@@ -122,4 +122,5 @@ module OreillyApi
|
|
122
122
|
end
|
123
123
|
end
|
124
124
|
# rubocop:enable Metrics/MethodLength
|
125
|
+
# rubocop:enable Layout/LineLength
|
125
126
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: oreilly_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- TruptiHosmani
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-04-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|