Class: Improvmx::Client
- Inherits:
-
Object
- Object
- Improvmx::Client
- Defined in:
- lib/improvmx/client.rb
Instance Method Summary collapse
- #delete(resource_path) ⇒ Object
- #get(resource_path, params = nil, accept = '*/*') ⇒ Object
-
#initialize(api_key = Improvmx.api_key) ⇒ Client
constructor
A new instance of Client.
- #post(resource_path, data, headers = {}) ⇒ Object
- #put(resource_path, data) ⇒ Object
Methods included from Utils
Methods included from Aliases
#create_alias, #create_or_update_alias, #delete_alias, #get_alias, #list_aliases, #update_alias
Constructor Details
#initialize(api_key = Improvmx.api_key) ⇒ Client
Returns a new instance of Client.
11 12 13 14 15 16 17 18 19 |
# File 'lib/improvmx/client.rb', line 11 def initialize(api_key = Improvmx.api_key) rest_client_params = { user: 'api', password: api_key, user_agent: "improvmx-ruby/#{Improvmx::VERSION}" } @http_client = RestClient::Resource.new('https://api.improvmx.com/v3', rest_client_params) end |
Instance Method Details
#delete(resource_path) ⇒ Object
42 43 44 45 46 47 |
# File 'lib/improvmx/client.rb', line 42 def delete(resource_path) response = @http_client[resource_path].delete Response.new(response) rescue StandardError => e raise communication_error e end |
#get(resource_path, params = nil, accept = '*/*') ⇒ Object
28 29 30 31 32 33 |
# File 'lib/improvmx/client.rb', line 28 def get(resource_path, params = nil, accept = '*/*') response = @http_client[resource_path].get(params: params, accept: accept) Response.new(response) rescue StandardError => e raise communication_error e end |