Class: Improvmx::Client
- Inherits:
-
Object
- Object
- Improvmx::Client
- Defined in:
- lib/improvmx/client.rb
Instance Attribute Summary collapse
-
#domain ⇒ Object
readonly
Returns the value of attribute domain.
Instance Method Summary collapse
-
#delete(resource_path) ⇒ Improvmx::Response
Generic Improvmx DELETE Handler.
-
#get(resource_path, params = nil, accept = '*/*') ⇒ Improvmx::Response
Generic Improvmx GET Handler.
-
#initialize(api_key = Improvmx.api_key, domain = Improvmx.domain) ⇒ Client
constructor
A new instance of Client.
-
#post(resource_path, data, headers = {}) ⇒ Improvmx::Response
Generic Improvmx POST Handler.
-
#put(resource_path, data) ⇒ Improvmx::Response
Generic Improvmx PUT Handler.
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, domain = Improvmx.domain) ⇒ Client
Returns a new instance of Client.
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/improvmx/client.rb', line 11 def initialize(api_key = Improvmx.api_key, domain = Improvmx.domain) 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) @domain = domain end |
Instance Attribute Details
#domain ⇒ Object (readonly)
Returns the value of attribute domain.
78 79 80 |
# File 'lib/improvmx/client.rb', line 78 def domain @domain end |
Instance Method Details
#delete(resource_path) ⇒ Improvmx::Response
Generic Improvmx DELETE Handler
with.
71 72 73 74 75 76 |
# File 'lib/improvmx/client.rb', line 71 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 = '*/*') ⇒ Improvmx::Response
Generic Improvmx GET Handler
with. containing required parameters for the requested resource.
45 46 47 48 49 50 |
# File 'lib/improvmx/client.rb', line 45 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 |
#post(resource_path, data, headers = {}) ⇒ Improvmx::Response
Generic Improvmx POST Handler
with. Be sure to include your domain, where necessary. containing required parameters for the requested resource.
30 31 32 33 34 35 |
# File 'lib/improvmx/client.rb', line 30 def post(resource_path, data, headers = {}) response = @http_client[resource_path].post(data, headers) Response.new(response) rescue StandardError => e raise communication_error e end |
#put(resource_path, data) ⇒ Improvmx::Response
Generic Improvmx PUT Handler
with. containing required parameters for the requested resource.
59 60 61 62 63 64 |
# File 'lib/improvmx/client.rb', line 59 def put(resource_path, data) response = @http_client[resource_path].put(data) Response.new(response) rescue StandardError => e raise communication_error e end |