vindata 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 +4 -4
- data/lib/vindata/services/edmunds.rb +53 -22
- data/lib/vindata/version.rb +1 -1
- data/lib/vindata.rb +6 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5d5cf7f52d834c03dde6460ad4ad64d0be20e0e4
|
4
|
+
data.tar.gz: cfe11414fc3e56963687796cba3fa1a67f8c54a1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 75ddbb0a1f089cc9e7388a5bf0bb72fc855f71b0524c9636a7dd2010161984035b0ab22c561e697a14f86f2e36a24c45e7eaf6ddd3fb7a33ae5130b67ea3462b
|
7
|
+
data.tar.gz: ee404f9dc9938104044326ffc2ee0da4bc6413713b3c2c1e4d57908c47ec1a7e3c1a193fba280e1862f8acf25365b99c5647aead089bb13f744d86f2901b78b7
|
@@ -12,25 +12,60 @@ module VinData::Services
|
|
12
12
|
|
13
13
|
def details_by_vin vin
|
14
14
|
# Lookup vehicle make/model/year by VIN
|
15
|
-
vinlookup = base_url
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
}})
|
15
|
+
vinlookup = "#{base_url}vins/#{vin}"
|
16
|
+
response = JSON.parse(RestClient.get vinlookup, {:params => {
|
17
|
+
fmt: 'json',
|
18
|
+
api_key: configuration[:edmunds][:api_key]
|
19
|
+
}})
|
21
20
|
|
22
|
-
|
21
|
+
# TODO: Check data validity here
|
23
22
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
23
|
+
return {
|
24
|
+
make: response['make']['niceName'],
|
25
|
+
model: response['model']['niceName'],
|
26
|
+
year: response['years'][0]['year'],
|
27
|
+
edmunds: response
|
28
|
+
}
|
29
|
+
# Indicates VIN request failed with Edmunds
|
30
|
+
rescue RestClient::BadRequest => err
|
31
|
+
return nil
|
32
|
+
# Indicates VIN was not valid
|
33
|
+
rescue RestClient::ResourceNotFound => err
|
34
|
+
return nil
|
35
|
+
end
|
36
|
+
|
37
|
+
def recalls data
|
38
|
+
# return nil unless data[:style_id]
|
39
|
+
years_url = "https://api.edmunds.com/api/vehicle/v2/#{data[:make]}/#{data[:model]}"
|
40
|
+
response = JSON.parse(RestClient.get years_url, {:params => {
|
41
|
+
fmt: 'json',
|
42
|
+
api_key: configuration[:edmunds][:api_key]
|
43
|
+
}})
|
44
|
+
year_id = response['years'].select{ |x| x['year'] == data[:year] }.first['id']
|
45
|
+
|
46
|
+
recall_url = 'https://api.edmunds.com/v1/api/maintenance/recallrepository/findbymodelyearid'
|
47
|
+
response = JSON.parse(RestClient.get recall_url, {:params => {
|
48
|
+
modelyearid: year_id,
|
49
|
+
fmt: 'json',
|
50
|
+
api_key: configuration[:edmunds][:api_key]
|
51
|
+
}})
|
52
|
+
|
53
|
+
# TODO: Check data validity here
|
54
|
+
|
55
|
+
return {
|
56
|
+
edmunds: response
|
57
|
+
}
|
58
|
+
# Indicates VIN request failed with Edmunds
|
59
|
+
rescue RestClient::BadRequest => err
|
60
|
+
return nil
|
61
|
+
end
|
62
|
+
|
63
|
+
def style_data data
|
64
|
+
stylelookup = base_url + data[:make] + '/' + data[:model] + '/' + data[:year].to_s + '/styles'
|
65
|
+
JSON.parse(RestClient.get stylelookup, {:params => {
|
66
|
+
fmt: 'json',
|
67
|
+
api_key: configuration[:edmunds][:api_key]
|
68
|
+
}})
|
34
69
|
end
|
35
70
|
|
36
71
|
# Required Data:
|
@@ -48,11 +83,7 @@ module VinData::Services
|
|
48
83
|
end
|
49
84
|
|
50
85
|
# Get the style ID by vehicle make/model/year
|
51
|
-
|
52
|
-
response = JSON.parse(RestClient.get stylelookup, {:params => {
|
53
|
-
fmt: 'json',
|
54
|
-
api_key: configuration[:edmunds][:api_key]
|
55
|
-
}})
|
86
|
+
response = style_data data
|
56
87
|
|
57
88
|
# TODO: Check data validity here
|
58
89
|
|
data/lib/vindata/version.rb
CHANGED
data/lib/vindata.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# External gems
|
2
|
-
require 'rest_client'
|
2
|
+
require 'rest_client'
|
3
3
|
|
4
4
|
# Internal files
|
5
5
|
require 'vindata/configuration'
|
@@ -15,4 +15,9 @@ module VinData
|
|
15
15
|
service = Services.get service
|
16
16
|
service.get_acv data
|
17
17
|
end
|
18
|
+
|
19
|
+
def self.recalls data, service = config[:service]
|
20
|
+
service = Services.get service
|
21
|
+
service.recalls data
|
22
|
+
end
|
18
23
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vindata
|
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
|
- Roupen Mouradian
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-07-
|
11
|
+
date: 2015-07-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|