Class: Audd::Client

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_token:, base_url:) ⇒ Client

Returns a new instance of Client.



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

def initialize(api_token:, base_url:)
  @api_token = api_token
  @base_url = base_url
  @http_client = HttpClient.new
end

Instance Attribute Details

#api_tokenObject (readonly)

Returns the value of attribute api_token.



9
10
11
# File 'lib/audd/client.rb', line 9

def api_token
  @api_token
end

#base_urlObject (readonly)

Returns the value of attribute base_url.



9
10
11
# File 'lib/audd/client.rb', line 9

def base_url
  @base_url
end

Instance Method Details

#inspectObject



26
27
28
# File 'lib/audd/client.rb', line 26

def inspect
  "#<#{self.class.name} base_url=#{base_url.inspect} api_token=[FILTERED]>"
end

#post(path, fields:, timeout:, file: nil) ⇒ Object



17
18
19
20
21
22
23
24
# File 'lib/audd/client.rb', line 17

def post(path, fields:, timeout:, file: nil)
  @http_client.post_form(
    "#{base_url}#{path}",
    fields: fields.merge("api_token" => api_token),
    timeout: timeout,
    file: file
  )
end