Class: Multiapi::Client

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_key:, base_url: 'https://api.multiapi.com') ⇒ Client

Returns a new instance of Client.



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

def initialize(api_key:, base_url: 'https://api.multiapi.com')
  @api_key = api_key
  @base_url = base_url
  @connection = create_connection
end

Instance Attribute Details

#api_keyObject (readonly)

Returns the value of attribute api_key.



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

def api_key
  @api_key
end

#base_urlObject (readonly)

Returns the value of attribute base_url.



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

def base_url
  @base_url
end

Instance Method Details

#delete(path, params = {}) ⇒ Object



37
38
39
# File 'lib/multiapi/client.rb', line 37

def delete(path, params = {})
  handle_response(@connection.delete(path, params))
end

#get(path, params = {}) ⇒ Object



25
26
27
# File 'lib/multiapi/client.rb', line 25

def get(path, params = {})
  handle_response(@connection.get(path, params))
end

#post(path, body = {}) ⇒ Object



29
30
31
# File 'lib/multiapi/client.rb', line 29

def post(path, body = {})
  handle_response(@connection.post(path, body.to_json))
end

#put(path, body = {}) ⇒ Object



33
34
35
# File 'lib/multiapi/client.rb', line 33

def put(path, body = {})
  handle_response(@connection.put(path, body.to_json))
end

#transactionsObject



21
22
23
# File 'lib/multiapi/client.rb', line 21

def transactions
  @transactions ||= Resources::Transaction.new(self)
end

#usersObject



17
18
19
# File 'lib/multiapi/client.rb', line 17

def users
  @users ||= Resources::User.new(self)
end