Class: MOCO::Connection
- Inherits:
-
Object
- Object
- MOCO::Connection
- Defined in:
- lib/moco/connection.rb
Overview
Handles HTTP communication with the MOCO API Responsible for building API requests and converting responses to entity objects
Instance Attribute Summary collapse
-
#api_key ⇒ Object
readonly
Returns the value of attribute api_key.
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#debug ⇒ Object
readonly
Returns the value of attribute debug.
-
#subdomain ⇒ Object
readonly
Returns the value of attribute subdomain.
Instance Method Summary collapse
-
#initialize(client, subdomain, api_key, debug: false) ⇒ Connection
constructor
A new instance of Connection.
Constructor Details
#initialize(client, subdomain, api_key, debug: false) ⇒ Connection
Returns a new instance of Connection.
12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/moco/connection.rb', line 12 def initialize(client, subdomain, api_key, debug: false) @client = client @subdomain = subdomain @api_key = api_key @debug = debug @conn = Faraday.new do |f| f.request :json f.response :json f.request :authorization, "Token", "token=#{@api_key}" f.url_prefix = "https://#{@subdomain}.mocoapp.com/api/v1" end end |
Instance Attribute Details
#api_key ⇒ Object (readonly)
Returns the value of attribute api_key.
10 11 12 |
# File 'lib/moco/connection.rb', line 10 def api_key @api_key end |
#client ⇒ Object (readonly)
Returns the value of attribute client.
10 11 12 |
# File 'lib/moco/connection.rb', line 10 def client @client end |
#debug ⇒ Object (readonly)
Returns the value of attribute debug.
10 11 12 |
# File 'lib/moco/connection.rb', line 10 def debug @debug end |
#subdomain ⇒ Object (readonly)
Returns the value of attribute subdomain.
10 11 12 |
# File 'lib/moco/connection.rb', line 10 def subdomain @subdomain end |