Module: EventMachine::Synchrony::DataoneVin
- Defined in:
- lib/em-synchrony/dataone-vin.rb,
lib/em-synchrony/dataone-vin/version.rb,
lib/em-synchrony/dataone-vin/vin_exploder_adapter.rb
Defined Under Namespace
Classes: VinExploderAdapter
Constant Summary collapse
- VERSION =
"0.1.0"
Class Method Summary collapse
- .configure(client_id, authorization_code) ⇒ Object
- .decoder_settings(vin) ⇒ Object
- .get(vin) ⇒ Object
- .request_hash(vin) ⇒ Object
- .request_url ⇒ Object
Class Method Details
.configure(client_id, authorization_code) ⇒ Object
12 13 14 15 16 17 |
# File 'lib/em-synchrony/dataone-vin.rb', line 12 def configure(client_id, ) @dataone_config = { :client_id => client_id, :authorization_code => } end |
.decoder_settings(vin) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/em-synchrony/dataone-vin.rb', line 34 def decoder_settings(vin) JSON::dump \ "decoder_settings"=> {"display"=>"full", "version"=>"7.0.0", "styles"=>"on", "style_data_packs"=> {"basic_data"=>"on", "pricing"=>"on", "engines"=>"on", "transmissions"=>"on", "specifications"=>"on", "optional_equipment"=>"on", "colors"=>"on", "safety_equipment"=>"on", "warranties"=>"on"}, "common_data"=>"on", "common_data_packs"=> {"basic_data"=>"on", "pricing"=>"on", "engines"=>"on", "transmissions"=>"on", "specifications"=>"on", "colors"=>"on", "safety_equipment"=>"on", "warranties"=>"on"}}, "query_requests"=> {"Request-Sample"=> {"vin"=>vin, "year"=>"", "make"=>"", "model"=>"", "trim"=>"", "model_number"=>"", "package_code"=>"", "drive_type"=>"", "vehicle_type"=>"", "body_type"=>"", "body_subtype"=>"", "doors"=>"", "bedlength"=>"", "wheelbase"=>"", "msrp"=>"", "invoice_price"=>"", "engine"=> {"description"=>"", "block_type"=>"", "cylinders"=>"", "displacement"=>"", "fuel_type"=>""}, "transmission"=>{"description"=>"", "trans_type"=>"", "trans_speeds"=>""}, "optional_equipment_codes"=>"", "installed_equipment_descriptions"=>"", "interior_color"=>{"description"=>"", "color_code"=>""}, "exterior_color"=>{"description"=>"", "color_code"=>""}}} end |
.get(vin) ⇒ Object
19 20 21 22 23 24 |
# File 'lib/em-synchrony/dataone-vin.rb', line 19 def get(vin) JSON::load EM::HttpRequest.new(request_url).post( :head => {:content_type => 'application/x-www-form-urlencoded'}, :body => request_hash(vin) ).response end |
.request_hash(vin) ⇒ Object
30 31 32 |
# File 'lib/em-synchrony/dataone-vin.rb', line 30 def request_hash(vin) @dataone_config.merge :decoder_query => decoder_settings(vin) end |
.request_url ⇒ Object
26 27 28 |
# File 'lib/em-synchrony/dataone-vin.rb', line 26 def request_url "https://api.dataonesoftware.com/webservices/vindecoder/decode" end |