Class: Manifestly::Client

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

Constant Summary collapse

DEFAULT_URL =
'https://manifest.ly/api'.freeze
DEFAULT_API_VERSION =
'v1'.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(url: ENV['MANIFESTLY_URL'], api_version: ENV['MANIFESTLY_API_VERSION'], api_key: ENV['MANIFESTLY_API_KEY']) ⇒ Client

Returns a new instance of Client.



10
11
12
13
14
# File 'lib/manifestly/http/client.rb', line 10

def initialize(url: ENV['MANIFESTLY_URL'], api_version: ENV['MANIFESTLY_API_VERSION'], api_key: ENV['MANIFESTLY_API_KEY'])
  @url = url || DEFAULT_URL
  @api_version = api_version || DEFAULT_API_VERSION
  @api_key = api_key || raise('api key is required')
end

Instance Attribute Details

#api_keyObject (readonly)

Returns the value of attribute api_key.



8
9
10
# File 'lib/manifestly/http/client.rb', line 8

def api_key
  @api_key
end

#api_versionObject (readonly)

Returns the value of attribute api_version.



8
9
10
# File 'lib/manifestly/http/client.rb', line 8

def api_version
  @api_version
end

#urlObject (readonly)

Returns the value of attribute url.



8
9
10
# File 'lib/manifestly/http/client.rb', line 8

def url
  @url
end

Instance Method Details

#delete(path, params: {}, headers: {}) ⇒ Object



48
49
50
# File 'lib/manifestly/http/client.rb', line 48

def delete(path, params: {}, headers: {})
  handle_request { raw_delete("#{url}/#{api_version}/#{path}", params: params, headers: headers) }
end

#get(path, params: {}, headers: {}) ⇒ Object



16
17
18
# File 'lib/manifestly/http/client.rb', line 16

def get(path, params: {}, headers: {})
  handle_request { raw_get("#{url}/#{api_version}/#{path}", params: params, headers: headers) }
end

#post(path, params: {}, headers: {}) ⇒ Object



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

def post(path, params: {}, headers: {})
  handle_request { raw_post("#{url}/#{api_version}/#{path}", params: params, headers: headers) }
end

#put(path, params: {}, headers: {}) ⇒ Object



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

def put(path, params: {}, headers: {})
  handle_request { raw_put("#{url}/#{api_version}/#{path}", params: params, headers: headers) }
end