Class: Manifestly::Client
- Inherits:
-
Object
- Object
- Manifestly::Client
- 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
-
#api_key ⇒ Object
readonly
Returns the value of attribute api_key.
-
#api_version ⇒ Object
readonly
Returns the value of attribute api_version.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Instance Method Summary collapse
- #delete(path, params: {}, headers: {}) ⇒ Object
- #get(path, params: {}, headers: {}) ⇒ Object
-
#initialize(url: ENV['MANIFESTLY_URL'], api_version: ENV['MANIFESTLY_API_VERSION'], api_key: ENV['MANIFESTLY_API_KEY']) ⇒ Client
constructor
A new instance of Client.
- #post(path, params: {}, headers: {}) ⇒ Object
- #put(path, params: {}, headers: {}) ⇒ Object
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_key ⇒ Object (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_version ⇒ Object (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 |
#url ⇒ Object (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 |