blackbook_client 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rspec +0 -1
- data/Gemfile.lock +2 -2
- data/README.md +3 -1
- data/lib/blackbook_client/version.rb +1 -1
- data/lib/blackbook_client.rb +2 -0
- data/lib/chromedata_service.rb +16 -0
- data/lib/rest_client.rb +35 -0
- data/lib/vin_service.rb +4 -34
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f339ba182e8a800d72d48ee481ca160570f16de8f7ca1f867108b7be3a976f6b
|
4
|
+
data.tar.gz: 82b7c9ef12a58fabff1782d6322f662119e2ad900b2bf27ac257f2428e4566c7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2ccde612b561b2bc6d6d18621e54c2e28322ead8bfd1b16144aa387a1e2c78cf4dbcdac16b0623af9166eccd722247ef5132bf2657fd716f374c0b47969cd9fe
|
7
|
+
data.tar.gz: '09eca32c0a08b4018223a139b11afc8f601b16675a57321574b5ea34794902fd97a5fc2ec1bc3d8f0935151691cce8075495e469b58491143c3b7768c81241f0'
|
data/.rspec
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
blackbook_client (0.1.
|
4
|
+
blackbook_client (0.1.2)
|
5
5
|
httparty (~> 0.15)
|
6
6
|
|
7
7
|
GEM
|
@@ -13,7 +13,7 @@ GEM
|
|
13
13
|
safe_yaml (~> 1.0.0)
|
14
14
|
diff-lcs (1.3)
|
15
15
|
hashdiff (0.3.7)
|
16
|
-
httparty (0.
|
16
|
+
httparty (0.16.0)
|
17
17
|
multi_xml (>= 0.5.2)
|
18
18
|
multi_xml (0.6.0)
|
19
19
|
public_suffix (3.0.1)
|
data/README.md
CHANGED
@@ -27,9 +27,11 @@ Or install it yourself as:
|
|
27
27
|
#### Call the desired method
|
28
28
|
|
29
29
|
BlackbookClient.range_by_vin('19XFC1F79GE216281')
|
30
|
-
|
30
|
+
|
31
31
|
BlackbookClient.range_by_vin('19XFC1F79GE216281', { state: 'NY', mileage: 40000 })
|
32
32
|
|
33
|
+
BlackbookClient.range_by_chromedata_id(1000, { state: 'NY', mileage: 40000, chromeoptions: 'SE' })
|
34
|
+
|
33
35
|
#### Wait for the answer
|
34
36
|
|
35
37
|
{ range: { xclean: 16950, clean: 16375, average: 15650, rough: 14750 } }
|
data/lib/blackbook_client.rb
CHANGED
@@ -0,0 +1,16 @@
|
|
1
|
+
module ChromedataService
|
2
|
+
include RestClient
|
3
|
+
VEHICLE_BY_CHROMEDATA_URL =
|
4
|
+
"#{BASE_URL}/UsedCarWS/UsedCarWS/UsedVehicle/Chrome".freeze
|
5
|
+
|
6
|
+
def range_by_chromedata_id(chrome_id, query_params ={})
|
7
|
+
url = "#{VEHICLE_BY_CHROMEDATA_URL}/#{chrome_id}"
|
8
|
+
|
9
|
+
begin
|
10
|
+
response = HTTParty.get(url, headers: headers, query: query_params)
|
11
|
+
process_response(JSON.parse(response))
|
12
|
+
rescue => e
|
13
|
+
[{ error: e.to_s }, 500]
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
data/lib/rest_client.rb
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
module RestClient
|
2
|
+
BASE_URL = 'https://service.blackbookcloud.com'.freeze
|
3
|
+
|
4
|
+
def headers
|
5
|
+
token = Base64.encode64("#{username}:#{password}")
|
6
|
+
{ Authorization: "Basic #{token}" }
|
7
|
+
end
|
8
|
+
|
9
|
+
def process_response(response)
|
10
|
+
status = 200
|
11
|
+
|
12
|
+
if response['error_count'].positive?
|
13
|
+
response = { error: response['message_list'][0]['description'] }
|
14
|
+
status = 400
|
15
|
+
else
|
16
|
+
response = map_fields(response)
|
17
|
+
end
|
18
|
+
|
19
|
+
[response, status]
|
20
|
+
end
|
21
|
+
|
22
|
+
def map_fields(response)
|
23
|
+
return {} unless response && response['used_vehicles'] && response['used_vehicles']['used_vehicle_list']
|
24
|
+
vehicle_range = response['used_vehicles']['used_vehicle_list'][0]
|
25
|
+
|
26
|
+
return {
|
27
|
+
range: {
|
28
|
+
xclean: vehicle_range['adjusted_whole_xclean'],
|
29
|
+
clean: vehicle_range['adjusted_whole_clean'],
|
30
|
+
average: vehicle_range['adjusted_whole_avg'],
|
31
|
+
rough: vehicle_range['adjusted_whole_rough']
|
32
|
+
}
|
33
|
+
}
|
34
|
+
end
|
35
|
+
end
|
data/lib/vin_service.rb
CHANGED
@@ -1,6 +1,8 @@
|
|
1
|
+
require 'rest_client'
|
2
|
+
|
1
3
|
module VinService
|
4
|
+
include RestClient
|
2
5
|
|
3
|
-
BASE_URL = 'https://service.blackbookcloud.com'.freeze
|
4
6
|
VEHICLE_BY_VIN_URL = "#{BASE_URL}/UsedCarWS/UsedCarWS/UsedVehicle/VIN".freeze
|
5
7
|
|
6
8
|
def range_by_vin(vin, query_params = {})
|
@@ -13,36 +15,4 @@ module VinService
|
|
13
15
|
[{ error: e.to_s }, 500]
|
14
16
|
end
|
15
17
|
end
|
16
|
-
|
17
|
-
def headers
|
18
|
-
token = Base64.encode64("#{username}:#{password}")
|
19
|
-
{ Authorization: "Basic #{token}" }
|
20
|
-
end
|
21
|
-
|
22
|
-
def process_response(response)
|
23
|
-
status = 200
|
24
|
-
|
25
|
-
if response['error_count'].positive?
|
26
|
-
response = { error: response['message_list'][0]['description'] }
|
27
|
-
status = 400
|
28
|
-
else
|
29
|
-
response = map_fields(response)
|
30
|
-
end
|
31
|
-
|
32
|
-
[response, status]
|
33
|
-
end
|
34
|
-
|
35
|
-
def map_fields(response)
|
36
|
-
return {} unless response && response['used_vehicles'] && response['used_vehicles']['used_vehicle_list']
|
37
|
-
vehicle_range = response['used_vehicles']['used_vehicle_list'][0]
|
38
|
-
|
39
|
-
return {
|
40
|
-
range: {
|
41
|
-
xclean: vehicle_range['adjusted_whole_xclean'],
|
42
|
-
clean: vehicle_range['adjusted_whole_clean'],
|
43
|
-
average: vehicle_range['adjusted_whole_avg'],
|
44
|
-
rough: vehicle_range['adjusted_whole_rough']
|
45
|
-
}
|
46
|
-
}
|
47
|
-
end
|
48
|
-
end
|
18
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: blackbook_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Christian Schmeichel
|
@@ -116,6 +116,8 @@ files:
|
|
116
116
|
- blackbook_client.gemspec
|
117
117
|
- lib/blackbook_client.rb
|
118
118
|
- lib/blackbook_client/version.rb
|
119
|
+
- lib/chromedata_service.rb
|
120
|
+
- lib/rest_client.rb
|
119
121
|
- lib/trade_service.rb
|
120
122
|
- lib/vin_service.rb
|
121
123
|
homepage: https://github.com/theappraisallane/blackbook-client
|