Class: Crm::Core::Configuration
- Inherits:
-
Object
- Object
- Crm::Core::Configuration
- Defined in:
- lib/crm/core/configuration.rb
Overview
Configuration
is yielded by Crm.configure. It lets you set the credentials for accessing the API. The tenant
, login
, and api_key
attributes must be provided.
Instance Attribute Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#api_key ⇒ Object
7 8 9 |
# File 'lib/crm/core/configuration.rb', line 7 def api_key @api_key end |
#endpoint ⇒ Object
11 12 13 |
# File 'lib/crm/core/configuration.rb', line 11 def endpoint @endpoint end |
#logger ⇒ Object
39 40 41 |
# File 'lib/crm/core/configuration.rb', line 39 def logger Crm::Core::LogSubscriber.logger end |
#login ⇒ Object
8 9 10 |
# File 'lib/crm/core/configuration.rb', line 8 def login @login end |
#tenant ⇒ Object
9 10 11 |
# File 'lib/crm/core/configuration.rb', line 9 def tenant @tenant end |
Instance Method Details
#endpoint_uri ⇒ Object
28 29 30 31 32 33 34 35 36 37 |
# File 'lib/crm/core/configuration.rb', line 28 def endpoint_uri if endpoint.present? url = endpoint url = "https://#{url}" unless url.match(/^http/) url += '/' unless url.end_with?('/') URI.parse(url) else URI.parse("https://#{tenant}.crm.infopark.net/api2/") end end |
#validate! ⇒ Object
57 58 59 60 61 62 63 |
# File 'lib/crm/core/configuration.rb', line 57 def validate! raise "Missing required configuration key: api_key" if api_key.blank? raise "Missing required configuration key: login" if login.blank? if tenant.blank? && endpoint.blank? raise "Missing required configuration key: tenant" end end |