Class: Insightly::Configuration
- Inherits:
-
Object
- Object
- Insightly::Configuration
- Defined in:
- lib/insightly/configuration.rb
Constant Summary collapse
- API_VERSION =
:nodoc:
"v1"
- DEFAULT_ENDPOINT =
:nodoc:
"https://api.insight.ly/v1"
Class Attribute Summary collapse
-
.api_key ⇒ Object
writeonly
Sets the attribute api_key.
-
.custom_user_agent ⇒ Object
writeonly
Sets the attribute custom_user_agent.
-
.endpoint ⇒ Object
writeonly
Sets the attribute endpoint.
- .logger ⇒ Object
Instance Attribute Summary collapse
-
#api_key ⇒ Object
readonly
Returns the value of attribute api_key.
-
#custom_user_agent ⇒ Object
readonly
Returns the value of attribute custom_user_agent.
-
#endpoint ⇒ Object
readonly
Returns the value of attribute endpoint.
Class Method Summary collapse
-
._debug_logger ⇒ Object
:nodoc:.
-
._default_logger ⇒ Object
:nodoc:.
- .custom_fields_for_contacts(*args) ⇒ Object
- .custom_fields_for_opportunities(*args) ⇒ Object
- .custom_fields_for_organisations(*args) ⇒ Object
-
.expectant_reader(*attributes) ⇒ Object
:nodoc:.
-
.instantiate ⇒ Object
:nodoc:.
Instance Method Summary collapse
-
#api_version ⇒ Object
:nodoc:.
-
#initialize(options = {}) ⇒ Configuration
constructor
A new instance of Configuration.
- #logger ⇒ Object
-
#user_agent ⇒ Object
:nodoc:.
Constructor Details
#initialize(options = {}) ⇒ Configuration
Returns a new instance of Configuration.
53 54 55 56 57 |
# File 'lib/insightly/configuration.rb', line 53 def initialize( = {}) [:endpoint, :api_key, :custom_user_agent, :logger].each do |attr| instance_variable_set "@#{attr}", [attr] end end |
Class Attribute Details
.api_key=(value) ⇒ Object (writeonly)
Sets the attribute api_key
15 16 17 |
# File 'lib/insightly/configuration.rb', line 15 def api_key=(value) @api_key = value end |
.custom_user_agent=(value) ⇒ Object (writeonly)
Sets the attribute custom_user_agent
15 16 17 |
# File 'lib/insightly/configuration.rb', line 15 def custom_user_agent=(value) @custom_user_agent = value end |
.endpoint=(value) ⇒ Object (writeonly)
Sets the attribute endpoint
15 16 17 |
# File 'lib/insightly/configuration.rb', line 15 def endpoint=(value) @endpoint = value end |
.logger ⇒ Object
49 50 51 |
# File 'lib/insightly/configuration.rb', line 49 def self.logger @logger ||= _default_logger end |
Instance Attribute Details
#api_key ⇒ Object (readonly)
Returns the value of attribute api_key.
17 18 19 |
# File 'lib/insightly/configuration.rb', line 17 def api_key @api_key end |
#custom_user_agent ⇒ Object (readonly)
Returns the value of attribute custom_user_agent.
17 18 19 |
# File 'lib/insightly/configuration.rb', line 17 def custom_user_agent @custom_user_agent end |
#endpoint ⇒ Object (readonly)
Returns the value of attribute endpoint.
17 18 19 |
# File 'lib/insightly/configuration.rb', line 17 def endpoint @endpoint end |
Class Method Details
._debug_logger ⇒ Object
:nodoc:
81 82 83 84 85 |
# File 'lib/insightly/configuration.rb', line 81 def self._debug_logger # :nodoc: logger = Logger.new(STDOUT) logger.level = Logger::DEBUG logger end |
._default_logger ⇒ Object
:nodoc:
76 77 78 79 80 |
# File 'lib/insightly/configuration.rb', line 76 def self._default_logger # :nodoc: logger = Logger.new(STDOUT) logger.level = Logger::INFO logger end |
.custom_fields_for_contacts(*args) ⇒ Object
45 46 47 |
# File 'lib/insightly/configuration.rb', line 45 def self.custom_fields_for_contacts(*args) Insightly::Contact.custom_fields(*args) end |
.custom_fields_for_opportunities(*args) ⇒ Object
39 40 41 |
# File 'lib/insightly/configuration.rb', line 39 def self.custom_fields_for_opportunities(*args) Insightly::Opportunity.custom_fields(*args) end |
.custom_fields_for_organisations(*args) ⇒ Object
42 43 44 |
# File 'lib/insightly/configuration.rb', line 42 def self.custom_fields_for_organisations(*args) Insightly::Organisation.custom_fields(*args) end |
.expectant_reader(*attributes) ⇒ Object
:nodoc:
19 20 21 22 23 24 25 26 27 |
# File 'lib/insightly/configuration.rb', line 19 def self.expectant_reader(*attributes) # :nodoc: attributes.each do |attribute| (class << self; self; end).send(:define_method, attribute) do attribute_value = instance_variable_get("@#{attribute}") raise ConfigurationError.new(attribute.to_s, "needs to be set") unless attribute_value attribute_value end end end |
.instantiate ⇒ Object
:nodoc:
30 31 32 33 34 35 36 37 |
# File 'lib/insightly/configuration.rb', line 30 def self.instantiate # :nodoc: config = new( :custom_user_agent => @custom_user_agent, :endpoint => @endpoint, :logger => logger, :api_key => api_key ) end |
Instance Method Details
#api_version ⇒ Object
:nodoc:
59 60 61 |
# File 'lib/insightly/configuration.rb', line 59 def api_version # :nodoc: API_VERSION end |
#logger ⇒ Object
67 68 69 |
# File 'lib/insightly/configuration.rb', line 67 def logger @logger ||= self.class._default_logger end |