vindata 0.0.1 → 0.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/Rakefile +1 -0
- data/lib/vindata/services/edmunds.rb +33 -17
- data/lib/vindata/services/nada.rb +139 -0
- data/lib/vindata/services.rb +2 -1
- data/lib/vindata/version.rb +1 -1
- data/lib/vindata/wsdls/ProdSecureLogin.wsdl +74 -0
- data/lib/vindata/wsdls/ProdVehicle.wsdl +1485 -0
- data/lib/vindata/wsdls/TestSecureLogin.wsdl +74 -0
- data/lib/vindata/wsdls/TestVehicle.wsdl +1485 -0
- data/lib/vindata.rb +1 -1
- metadata +9 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c35b0dc0e039d50643af7cc83bc535772ec4677b
|
4
|
+
data.tar.gz: 4c47d22f600fbccc1650cd308c856bc029345a87
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 700d495663192836a70d8c27b40f2a043f27c5d380be733aa38969785a8787b900570d28529491971839248e9338dc9a62f0fcfd5de3ce5779e5443f4789b7bb
|
7
|
+
data.tar.gz: dcd5df5a8bc01f9cd3d3565260f908100ac1127adb986be0fa4f1d3a282b7e6cb3b6beec2bb68cedad132bbbe70e25c094746dc91258361009e0bd3a0263ea2e
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'bundler/gem_tasks'
|
@@ -13,18 +13,23 @@ module VinData::Services
|
|
13
13
|
def details_by_vin vin
|
14
14
|
# Lookup vehicle make/model/year by VIN
|
15
15
|
vinlookup = base_url + 'vins/'+vin
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
16
|
+
begin
|
17
|
+
response = JSON.parse(RestClient.get vinlookup, {:params => {
|
18
|
+
fmt: 'json',
|
19
|
+
api_key: configuration[:api_key]
|
20
|
+
}})
|
20
21
|
|
21
|
-
|
22
|
+
# TODO: Check data validity here
|
22
23
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
24
|
+
return {
|
25
|
+
make: response['make']['niceName'],
|
26
|
+
model: response['model']['niceName'],
|
27
|
+
year: response['years'][0]['year']
|
28
|
+
}
|
29
|
+
# Indicates VIN request failed with Edmunds
|
30
|
+
rescue RestClient::BadRequest => err
|
31
|
+
return nil
|
32
|
+
end
|
28
33
|
end
|
29
34
|
|
30
35
|
# Required Data:
|
@@ -34,7 +39,12 @@ module VinData::Services
|
|
34
39
|
# :mileage
|
35
40
|
# :zip
|
36
41
|
def get_acv data
|
37
|
-
|
42
|
+
return nil unless ((data[:make] && data[:model] && data[:year]) || data[:vin]) && data[:mileage] && data[:zip]
|
43
|
+
if data[:vin]
|
44
|
+
car_details = details_by_vin data.delete(:vin)
|
45
|
+
return nil unless car_details
|
46
|
+
data.merge! car_details
|
47
|
+
end
|
38
48
|
|
39
49
|
# Get the style ID by vehicle make/model/year
|
40
50
|
stylelookup = base_url + data[:make] + '/' + data[:model] + '/' + data[:year].to_s + '/styles'
|
@@ -56,12 +66,18 @@ module VinData::Services
|
|
56
66
|
}})
|
57
67
|
|
58
68
|
# TODO: Check data validity here
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
69
|
+
if response == nil || response['tmv'] == nil
|
70
|
+
return nil
|
71
|
+
else
|
72
|
+
return {
|
73
|
+
common: {
|
74
|
+
retail: response['tmv']['nationalBasePrice']['usedTmvRetail'],
|
75
|
+
private_party: response['tmv']['nationalBasePrice']['usedPrivateParty'],
|
76
|
+
trade_in: response['tmv']['nationalBasePrice']['usedTradeIn']
|
77
|
+
},
|
78
|
+
edmunds: response
|
79
|
+
}
|
80
|
+
end
|
65
81
|
end
|
66
82
|
end
|
67
83
|
end
|
@@ -0,0 +1,139 @@
|
|
1
|
+
require 'vindata/services/base'
|
2
|
+
require 'savon'
|
3
|
+
|
4
|
+
module Savon
|
5
|
+
class Client
|
6
|
+
def get_request_xml operation_name, locals
|
7
|
+
Savon::Builder.new(operation_name, @wsdl, @globals, locals).pretty
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
module VinData::Services
|
13
|
+
class Nada < Base
|
14
|
+
|
15
|
+
def initialize
|
16
|
+
get_token
|
17
|
+
end
|
18
|
+
|
19
|
+
def name
|
20
|
+
'NADA'
|
21
|
+
end
|
22
|
+
|
23
|
+
def base_url
|
24
|
+
nil
|
25
|
+
end
|
26
|
+
|
27
|
+
def get_token
|
28
|
+
# we don't want to get the token every time
|
29
|
+
return @token if @token.present?
|
30
|
+
|
31
|
+
fail 'NADA requires username and password' unless configuration[:username].present? &&
|
32
|
+
configuration[:password].present?
|
33
|
+
|
34
|
+
wsdl_path = File.expand_path(File.join(File.dirname(__FILE__), '../wsdls/ProdSecureLogin.wsdl'))
|
35
|
+
# do auth login to get token
|
36
|
+
client = Savon.client(
|
37
|
+
wsdl: wsdl_path,
|
38
|
+
raise_errors: true,
|
39
|
+
log_level: :info,
|
40
|
+
pretty_print_xml: true,
|
41
|
+
env_namespace: :soap,
|
42
|
+
namespace_identifier: :web
|
43
|
+
)
|
44
|
+
data = client.call(:get_token,
|
45
|
+
message: { 'tokenRequest' =>
|
46
|
+
{ 'Username' => configuration[:username],
|
47
|
+
'Password' => configuration[:password]
|
48
|
+
}
|
49
|
+
}
|
50
|
+
)
|
51
|
+
@token = data.to_hash[:get_token_response][:get_token_result]
|
52
|
+
end
|
53
|
+
|
54
|
+
def get_client
|
55
|
+
wsdl_path = File.expand_path(
|
56
|
+
File.join(File.dirname(__FILE__),
|
57
|
+
'../wsdls/ProdVehicle.wsdl')
|
58
|
+
)
|
59
|
+
# do auth login to get token
|
60
|
+
client = Savon.client(
|
61
|
+
wsdl: wsdl_path,
|
62
|
+
raise_errors: true,
|
63
|
+
log_level: :info,
|
64
|
+
pretty_print_xml: true,
|
65
|
+
env_namespace: :soap,
|
66
|
+
namespace_identifier: :web
|
67
|
+
)
|
68
|
+
client
|
69
|
+
end
|
70
|
+
|
71
|
+
def get_region_by_state(state)
|
72
|
+
client = get_client
|
73
|
+
data = client.call(:get_region_by_state_code,
|
74
|
+
message: { 'l_Request' => { 'Token' => get_token,
|
75
|
+
'Period' => 0,
|
76
|
+
'VehicleType' => 'UsedCar',
|
77
|
+
'StateCode' => state
|
78
|
+
}
|
79
|
+
}
|
80
|
+
)
|
81
|
+
data.to_hash[:get_region_by_state_code_response][:get_region_by_state_code_result]
|
82
|
+
end
|
83
|
+
|
84
|
+
def details_by_vin(vin)
|
85
|
+
token = get_token
|
86
|
+
client = get_client
|
87
|
+
data = client.call(:get_vehicles,
|
88
|
+
message: { 'vehicleRequest' =>
|
89
|
+
{ 'Token' => token,
|
90
|
+
'Period' => 0,
|
91
|
+
'VehicleType' => 'UsedCar',
|
92
|
+
'Vin' => vin
|
93
|
+
}
|
94
|
+
}
|
95
|
+
)
|
96
|
+
data.to_hash[:get_vehicles_response][:get_vehicles_result][:vehicle_struc].first
|
97
|
+
end
|
98
|
+
|
99
|
+
# Required Data:
|
100
|
+
# :vin
|
101
|
+
# :state
|
102
|
+
# :mileage
|
103
|
+
def get_acv(data)
|
104
|
+
return nil unless data[:vin] && data[:state] && data[:mileage]
|
105
|
+
|
106
|
+
token = get_token
|
107
|
+
|
108
|
+
region_id = get_region_by_state data[:state]
|
109
|
+
|
110
|
+
client = get_client
|
111
|
+
|
112
|
+
begin
|
113
|
+
data = client.call(:get_default_vehicle_and_value_by_vin,
|
114
|
+
message: { 'vehicleRequest' =>
|
115
|
+
{ 'Token' => token,
|
116
|
+
'Period' => 0,
|
117
|
+
'VehicleType' => 'UsedCar',
|
118
|
+
'Vin' => data[:vin],
|
119
|
+
'Region' => region_id,
|
120
|
+
'Mileage' => data[:mileage]
|
121
|
+
}
|
122
|
+
}
|
123
|
+
)
|
124
|
+
data = data.to_hash[:get_default_vehicle_and_value_by_vin_response][:get_default_vehicle_and_value_by_vin_result]
|
125
|
+
return {
|
126
|
+
common: {
|
127
|
+
retail: data[:retail_plus_vin_acc_mileage],
|
128
|
+
trade_in: data[:trade_in_plus_vin_acc_mileage]
|
129
|
+
},
|
130
|
+
nada: data
|
131
|
+
}
|
132
|
+
|
133
|
+
rescue Savon::SOAPFault => error
|
134
|
+
return false if error.message.include? 'No vehicle found'
|
135
|
+
raise error.message
|
136
|
+
end
|
137
|
+
end
|
138
|
+
end
|
139
|
+
end
|
data/lib/vindata/services.rb
CHANGED
data/lib/vindata/version.rb
CHANGED
@@ -0,0 +1,74 @@
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
2
|
+
<wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:tns="http://webservice.nada.com/" xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" targetNamespace="http://webservice.nada.com/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
|
3
|
+
<wsdl:documentation xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">This is NADA Web Service into its Login methods.</wsdl:documentation>
|
4
|
+
<wsdl:types>
|
5
|
+
<s:schema elementFormDefault="qualified" targetNamespace="http://webservice.nada.com/">
|
6
|
+
<s:element name="getToken">
|
7
|
+
<s:complexType>
|
8
|
+
<s:sequence>
|
9
|
+
<s:element minOccurs="0" maxOccurs="1" name="tokenRequest" type="tns:GetTokenRequest" />
|
10
|
+
</s:sequence>
|
11
|
+
</s:complexType>
|
12
|
+
</s:element>
|
13
|
+
<s:complexType name="GetTokenRequest">
|
14
|
+
<s:sequence>
|
15
|
+
<s:element minOccurs="0" maxOccurs="1" name="Username" type="s:string" />
|
16
|
+
<s:element minOccurs="0" maxOccurs="1" name="Password" type="s:string" />
|
17
|
+
</s:sequence>
|
18
|
+
</s:complexType>
|
19
|
+
<s:element name="getTokenResponse">
|
20
|
+
<s:complexType>
|
21
|
+
<s:sequence>
|
22
|
+
<s:element minOccurs="0" maxOccurs="1" name="getTokenResult" type="s:string" />
|
23
|
+
</s:sequence>
|
24
|
+
</s:complexType>
|
25
|
+
</s:element>
|
26
|
+
</s:schema>
|
27
|
+
</wsdl:types>
|
28
|
+
<wsdl:message name="getTokenSoapIn">
|
29
|
+
<wsdl:part name="parameters" element="tns:getToken" />
|
30
|
+
</wsdl:message>
|
31
|
+
<wsdl:message name="getTokenSoapOut">
|
32
|
+
<wsdl:part name="parameters" element="tns:getTokenResponse" />
|
33
|
+
</wsdl:message>
|
34
|
+
<wsdl:portType name="SecureLoginSoap">
|
35
|
+
<wsdl:operation name="getToken">
|
36
|
+
<wsdl:documentation xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">Logs the user in and returns a valid token.</wsdl:documentation>
|
37
|
+
<wsdl:input message="tns:getTokenSoapIn" />
|
38
|
+
<wsdl:output message="tns:getTokenSoapOut" />
|
39
|
+
</wsdl:operation>
|
40
|
+
</wsdl:portType>
|
41
|
+
<wsdl:binding name="SecureLoginSoap" type="tns:SecureLoginSoap">
|
42
|
+
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" />
|
43
|
+
<wsdl:operation name="getToken">
|
44
|
+
<soap:operation soapAction="http://webservice.nada.com/getToken" style="document" />
|
45
|
+
<wsdl:input>
|
46
|
+
<soap:body use="literal" />
|
47
|
+
</wsdl:input>
|
48
|
+
<wsdl:output>
|
49
|
+
<soap:body use="literal" />
|
50
|
+
</wsdl:output>
|
51
|
+
</wsdl:operation>
|
52
|
+
</wsdl:binding>
|
53
|
+
<wsdl:binding name="SecureLoginSoap12" type="tns:SecureLoginSoap">
|
54
|
+
<soap12:binding transport="http://schemas.xmlsoap.org/soap/http" />
|
55
|
+
<wsdl:operation name="getToken">
|
56
|
+
<soap12:operation soapAction="http://webservice.nada.com/getToken" style="document" />
|
57
|
+
<wsdl:input>
|
58
|
+
<soap12:body use="literal" />
|
59
|
+
</wsdl:input>
|
60
|
+
<wsdl:output>
|
61
|
+
<soap12:body use="literal" />
|
62
|
+
</wsdl:output>
|
63
|
+
</wsdl:operation>
|
64
|
+
</wsdl:binding>
|
65
|
+
<wsdl:service name="SecureLogin">
|
66
|
+
<wsdl:documentation xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">This is NADA Web Service into its Login methods.</wsdl:documentation>
|
67
|
+
<wsdl:port name="SecureLoginSoap" binding="tns:SecureLoginSoap">
|
68
|
+
<soap:address location="https://webservice.nada.com/vehicles/Secure/SecureLogin.asmx" />
|
69
|
+
</wsdl:port>
|
70
|
+
<wsdl:port name="SecureLoginSoap12" binding="tns:SecureLoginSoap12">
|
71
|
+
<soap12:address location="https://webservice.nada.com/vehicles/Secure/SecureLogin.asmx" />
|
72
|
+
</wsdl:port>
|
73
|
+
</wsdl:service>
|
74
|
+
</wsdl:definitions>
|