Class: DaClient

Inherits:
Object
  • Object
show all
Defined in:
lib/da_client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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 = 
  @env = env
  @host = default_host
  super()
end

Instance Attribute Details

#accountObject

Returns the value of attribute account.



4
5
6
# File 'lib/da_client.rb', line 4

def 
  @account
end

#envObject

Returns the value of attribute env.



4
5
6
# File 'lib/da_client.rb', line 4

def env
  @env
end

#hostObject

Returns the value of attribute host.



4
5
6
# File 'lib/da_client.rb', line 4

def host
  @host
end

#tokenObject

Returns the value of attribute token.



4
5
6
# File 'lib/da_client.rb', line 4

def token
  @token
end

Instance Method Details

#default_hostObject



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