Class: Outsmart::Client

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

Constant Summary collapse

BASE_URL =
"https://www.werkbonapp.nl/openapi/8"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(token:, software_token:, adapter: Faraday.default_adapter) ⇒ Client

Returns a new instance of Client.



12
13
14
15
16
# File 'lib/outsmart/client.rb', line 12

def initialize(token:, software_token:, adapter: Faraday.default_adapter)
  @token = token
  @software_token = software_token
  @adapter = adapter
end

Instance Attribute Details

#adapterObject (readonly)

Returns the value of attribute adapter.



10
11
12
# File 'lib/outsmart/client.rb', line 10

def adapter
  @adapter
end

#software_tokenObject (readonly)

Returns the value of attribute software_token.



10
11
12
# File 'lib/outsmart/client.rb', line 10

def software_token
  @software_token
end

#tokenObject (readonly)

Returns the value of attribute token.



10
11
12
# File 'lib/outsmart/client.rb', line 10

def token
  @token
end

Instance Method Details

#connectionObject



18
19
20
21
22
23
24
25
26
27
# File 'lib/outsmart/client.rb', line 18

def connection
  @connection ||= Faraday.new do |conn|
    conn.url_prefix = BASE_URL
    conn.request :json
    conn.params[:token] = @token
    conn.params[:software_token] = @software_token
    conn.response :json, content_type: "application/json"
    conn.adapter adapter
  end
end