oreilly_api 1.0.1 → 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 331993016d4ab1bced47131d0e70f76e32d8492d66a7a853583a61fef4599600
4
- data.tar.gz: 98931db3b5d41529f7d27a8f31270063c312139796a305bbd531fcae2ba160ec
3
+ metadata.gz: c9f5038e7928719e445cdd07449a7d88f1dfe2bf82cdf47db6d51d31dd5ba081
4
+ data.tar.gz: f2a09c91d003feb1774df8b3a6dae3de07d618689f7ba75b5ff76799da9d322f
5
5
  SHA512:
6
- metadata.gz: 64869f04d8246537679d62a7c8fdeaaefe362c4a5cb6daa7fa46ba47deebb92de8fda5eb7b8495abd3714e60546c6581a1f0a6195988e5f96f4d2d8cf968f19b
7
- data.tar.gz: b617ee084302e1141c5d78b859759cbaea1b95c05def9360687cd2215f4b31b805b49d535b5b7124325495069852e921c7834ce42c23d1d79d4317c0e5bb4992
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.00057 seconds |
4
- ./spec/oreilly_api_spec.rb[1:2] | passed | 0.02444 seconds |
5
- ./spec/oreilly_api_spec.rb[1:3] | passed | 0.00974 seconds |
6
- ./spec/oreilly_api_spec.rb[1:4] | pending | 0.00001 seconds |
7
- ./spec/oreilly_api_spec.rb[1:5] | passed | 0.01098 seconds |
8
- ./spec/oreilly_api_spec.rb[1:6] | passed | 0.00897 seconds |
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
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- oreilly_api (1.0.1)
4
+ oreilly_api (1.0.3)
5
5
  byebug
6
6
  redis
7
7
  redis_utility
data/README.md CHANGED
@@ -31,7 +31,6 @@ OreillyApi.config do |c|
31
31
  c.client_secret = 'client_sercet'
32
32
  c.identity = 'IDENTITY'
33
33
  c.version = 'sms-external-partner/services'
34
- c.account_number = '123456'
35
34
  end
36
35
  ```
37
36
 
data/Rakefile CHANGED
@@ -10,3 +10,7 @@ require 'rubocop/rake_task'
10
10
  RuboCop::RakeTask.new
11
11
 
12
12
  task default: %i[spec rubocop]
13
+
14
+ task :console do
15
+ exec "irb -r oreilly_api -I ./lib"
16
+ end
@@ -1,3 +1,3 @@
1
1
  module OreillyApi
2
- VERSION = "1.0.1"
2
+ VERSION = "1.0.3"
3
3
  end
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, :account_number
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#{OreillyApi.account_number}#{DateTime.now.strftime('%Y%m%d%l%S%M')}}"
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, customer_location_id, vehicles_with_items, stop_order: false)
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
- 'customerLocationId': customer_location_id || '',
40
- 'accountNumber' => OreillyApi.account_number,
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' => OreillyApi.account_number,
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=test#{params}"
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.1
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-02-08 00:00:00.000000000 Z
11
+ date: 2023-04-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler