Class: Apikit::Client

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_endpoint, config = Apikit.config) ⇒ Client

options:



6
7
8
9
# File 'lib/apikit/client.rb', line 6

def initialize(api_endpoint, config = Apikit.config )
  @api_endpoint = api_endpoint
  @config = config
end

Instance Attribute Details

#api_endpointObject

Returns the value of attribute api_endpoint.



3
4
5
# File 'lib/apikit/client.rb', line 3

def api_endpoint
  @api_endpoint
end

#configObject

Returns the value of attribute config.



3
4
5
# File 'lib/apikit/client.rb', line 3

def config
  @config
end

Instance Method Details

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



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

def delete(path, options = {})
  request :delete, path, options
end

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

options:

query:


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

def get(path, options = {})
  request :get, path, options
end

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



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

def post(path, options = {})
  request :post, path, options
end

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



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

def put(path, options = {})
  request :put, path, options
end

#request(method, path, options = {}) ⇒ Object



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

def request(method, path, options = {})
  response = agent.call(method, URI::Parser.new.escape(path.to_s), nil, options)
  response.data
end