Class: DaClient
- Inherits:
-
Object
- Object
- DaClient
- Defined in:
- lib/da_client.rb
Instance Attribute Summary collapse
-
#account ⇒ Object
Returns the value of attribute account.
-
#env ⇒ Object
Returns the value of attribute env.
-
#host ⇒ Object
Returns the value of attribute host.
-
#token ⇒ Object
Returns the value of attribute token.
Instance Method Summary collapse
- #default_host ⇒ Object
-
#initialize(token:, account:, env: "production") ⇒ DaClient
constructor
A new instance of DaClient.
- #vehicles(q: {}, page: 1, per_page: 20, token: @token) ⇒ Object
Constructor Details
#initialize(token:, account:, env: "production") ⇒ DaClient
Returns a new instance of DaClient.
6 7 8 9 10 11 12 |
# File 'lib/da_client.rb', line 6 def initialize(token: , account: , env: "production") @token = token @account = account @env = env @host = default_host super() end |
Instance Attribute Details
#account ⇒ Object
Returns the value of attribute account.
4 5 6 |
# File 'lib/da_client.rb', line 4 def account @account end |
#env ⇒ Object
Returns the value of attribute env.
4 5 6 |
# File 'lib/da_client.rb', line 4 def env @env end |
#host ⇒ Object
Returns the value of attribute host.
4 5 6 |
# File 'lib/da_client.rb', line 4 def host @host end |
#token ⇒ Object
Returns the value of attribute token.
4 5 6 |
# File 'lib/da_client.rb', line 4 def token @token end |
Instance Method Details
#default_host ⇒ Object
14 15 16 17 |
# File 'lib/da_client.rb', line 14 def default_host return ENV["DA_CLIENT_HOST"] if ENV["DA_CLIENT_HOST"] env == 'production' ? 'https://app.dealeraccelerate.com' : 'https://app.dealer-accelerate-staging.com' end |
#vehicles(q: {}, page: 1, per_page: 20, token: @token) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/da_client.rb', line 19 def vehicles(q: {}, page: 1, per_page: 20, token: @token) path = "api/v1/accounts/#{@account}/vehicles" obj = { q: q, page: page, per_page: per_page, token: token } query = to_params(obj) uri = "#{@host}/#{path}?#{query}" request(uri) end |