Class: Carquery::Client
- Inherits:
-
Object
- Object
- Carquery::Client
- Defined in:
- lib/carquery/client.rb,
lib/carquery/client/version.rb
Constant Summary collapse
- API_VERSION =
'0.3'.freeze
- BASE_URL =
'https://www.carqueryapi.com'.freeze
- VERSION =
"0.1.2"
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Client
constructor
A new instance of Client.
- #makes_for_year(year, us_only = 1) ⇒ Object
- #models_for_year_and_make(year, make, us_only = 1) ⇒ Object
- #trims_for_model(year, make, model) ⇒ Object
- #years ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Client
Returns a new instance of Client.
10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/carquery/client.rb', line 10 def initialize( = {}) @connection = Faraday::Connection.new( BASE_URL, headers: { 'Content-Type' => 'application/json' }, ssl: { ca_path: .fetch(:ca_path, default_config[:ca_path]) }, ) do |f| f.response :json end end |
Instance Method Details
#makes_for_year(year, us_only = 1) ⇒ Object
28 29 30 |
# File 'lib/carquery/client.rb', line 28 def makes_for_year(year, us_only = 1) request(cmd: 'getMakes', year: year, sold_in_us: us_only)['Makes'] end |
#models_for_year_and_make(year, make, us_only = 1) ⇒ Object
32 33 34 |
# File 'lib/carquery/client.rb', line 32 def models_for_year_and_make(year, make, us_only = 1) request(cmd: 'getModels', year: year, make: make, sold_in_us: us_only)['Models'] end |
#trims_for_model(year, make, model) ⇒ Object
36 37 38 |
# File 'lib/carquery/client.rb', line 36 def trims_for_model(year, make, model) request(cmd: 'getTrims', year: year, make: make, model: model)['Trims'] end |
#years ⇒ Object
24 25 26 |
# File 'lib/carquery/client.rb', line 24 def years request(cmd: 'getYears')['Years'] end |