Class: Atrium::Client
- Inherits:
-
Object
- Object
- Atrium::Client
- Defined in:
- lib/atrium/client.rb
Constant Summary collapse
- DEVELOPMENT_URL =
"https://vestibule.mx.com".freeze
Instance Attribute Summary collapse
-
#base_url ⇒ Object
Returns the value of attribute base_url.
-
#mx_api_key ⇒ Object
Returns the value of attribute mx_api_key.
-
#mx_client_id ⇒ Object
Returns the value of attribute mx_client_id.
Instance Method Summary collapse
- #http_client ⇒ Object
-
#initialize(api_key = nil, client_id = nil, base_url = DEVELOPMENT_URL) ⇒ Client
constructor
A new instance of Client.
- #make_request(method, endpoint, body = nil, headers = {}) ⇒ Object
Constructor Details
#initialize(api_key = nil, client_id = nil, base_url = DEVELOPMENT_URL) ⇒ Client
Returns a new instance of Client.
6 7 8 9 10 |
# File 'lib/atrium/client.rb', line 6 def initialize(api_key = nil, client_id = nil, base_url = DEVELOPMENT_URL) @mx_api_key = api_key @mx_client_id = client_id @base_url = base_url end |
Instance Attribute Details
#base_url ⇒ Object
Returns the value of attribute base_url.
4 5 6 |
# File 'lib/atrium/client.rb', line 4 def base_url @base_url end |
#mx_api_key ⇒ Object
Returns the value of attribute mx_api_key.
4 5 6 |
# File 'lib/atrium/client.rb', line 4 def mx_api_key @mx_api_key end |
#mx_client_id ⇒ Object
Returns the value of attribute mx_client_id.
4 5 6 |
# File 'lib/atrium/client.rb', line 4 def mx_client_id @mx_client_id end |
Instance Method Details
#http_client ⇒ Object
22 23 24 |
# File 'lib/atrium/client.rb', line 22 def http_client @http_client ||= ::HTTPClient.new end |
#make_request(method, endpoint, body = nil, headers = {}) ⇒ Object
12 13 14 15 16 17 18 19 20 |
# File 'lib/atrium/client.rb', line 12 def make_request(method, endpoint, body = nil, headers = {}) headers = default_headers.merge(headers) url = "#{base_url}#{endpoint}" body = ::JSON.dump(body) if body response = http_client.public_send(method, url, body, headers) handle_response(response) end |