Class: Payable::Client

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/payable/client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(company_id: Payable.config.company_id, api_key: Payable.config.api_key) ⇒ Client

Returns a new instance of Client.



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

def initialize(company_id: Payable.config.company_id, api_key: Payable.config.api_key)
  @company_id = company_id or raise MissingRequiredSetting, "company_id"
  @api_key = api_key or raise MissingRequiredSetting, "api_key"
end

Instance Attribute Details

#api_keyObject (readonly)

Returns the value of attribute api_key.



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

def api_key
  @api_key
end

#company_idObject (readonly)

Returns the value of attribute company_id.



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

def company_id
  @company_id
end

Instance Method Details

#connectionObject



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

def connection
  @connection ||= Faraday.new Payable.api_url do |conn|
    conn.basic_auth company_id, api_key
    conn.request :json
    conn.response :json
    conn.response :logger, Payable.config.logger, bodies: true if Payable.config.logger
    conn.response :symbolize_keys
    conn.response :raise_error
    conn.adapter Faraday.default_adapter
  end
end