Class: Freshsales::API
- Inherits:
-
Object
- Object
- Freshsales::API
- Defined in:
- lib/freshsales/api.rb
Instance Attribute Summary collapse
-
#debug ⇒ Object
Returns the value of attribute debug.
-
#faraday_adapter ⇒ Object
Returns the value of attribute faraday_adapter.
-
#freshsales_apikey ⇒ Object
Returns the value of attribute freshsales_apikey.
-
#freshsales_domain ⇒ Object
Returns the value of attribute freshsales_domain.
-
#logger ⇒ Object
Returns the value of attribute logger.
-
#proxy ⇒ Object
Returns the value of attribute proxy.
-
#raw_data ⇒ Object
Returns the value of attribute raw_data.
-
#symbolize_keys ⇒ Object
Returns the value of attribute symbolize_keys.
Instance Method Summary collapse
-
#initialize(opts = {}) ⇒ API
constructor
A new instance of API.
-
#method_missing(method, *args) ⇒ Object
rubocop:disable Style/MethodMissing.
-
#respond_to_missing?(_method_name, _include_private = false) ⇒ Boolean
rubocop:enable Style/MethodMissing.
Constructor Details
#initialize(opts = {}) ⇒ API
Returns a new instance of API.
5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/freshsales/api.rb', line 5 def initialize(opts = {}) @freshsales_apikey = opts.fetch(:freshsales_apikey, ENV["FRESHSALES_APIKEY"]) @freshsales_domain = opts.fetch(:freshsales_domain, ENV["FRESHSALES_DOMAIN"]) @raw_data = opts.fetch(:raw_data, false) @symbolize_keys = opts.fetch(:symbolize_keys, false) @debug = opts.fetch(:debug, false) @logger = opts.fetch(:logger, ::Logger.new(STDOUT)) @faraday_adapter = opts.fetch(:faraday_adapter, Faraday.default_adapter) @proxy = opts.fetch(:proxy, ENV["FRESHSALES_PROXY"]) @client = Client.new(self) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args) ⇒ Object
rubocop:disable Style/MethodMissing
19 20 21 22 23 |
# File 'lib/freshsales/api.rb', line 19 def method_missing(method, *args) request = RequestBuilder.new(@client) request.send(method, *args) request end |
Instance Attribute Details
#debug ⇒ Object
Returns the value of attribute debug.
3 4 5 |
# File 'lib/freshsales/api.rb', line 3 def debug @debug end |
#faraday_adapter ⇒ Object
Returns the value of attribute faraday_adapter.
3 4 5 |
# File 'lib/freshsales/api.rb', line 3 def faraday_adapter @faraday_adapter end |
#freshsales_apikey ⇒ Object
Returns the value of attribute freshsales_apikey.
3 4 5 |
# File 'lib/freshsales/api.rb', line 3 def freshsales_apikey @freshsales_apikey end |
#freshsales_domain ⇒ Object
Returns the value of attribute freshsales_domain.
3 4 5 |
# File 'lib/freshsales/api.rb', line 3 def freshsales_domain @freshsales_domain end |
#logger ⇒ Object
Returns the value of attribute logger.
3 4 5 |
# File 'lib/freshsales/api.rb', line 3 def logger @logger end |
#proxy ⇒ Object
Returns the value of attribute proxy.
3 4 5 |
# File 'lib/freshsales/api.rb', line 3 def proxy @proxy end |
#raw_data ⇒ Object
Returns the value of attribute raw_data.
3 4 5 |
# File 'lib/freshsales/api.rb', line 3 def raw_data @raw_data end |
#symbolize_keys ⇒ Object
Returns the value of attribute symbolize_keys.
3 4 5 |
# File 'lib/freshsales/api.rb', line 3 def symbolize_keys @symbolize_keys end |
Instance Method Details
#respond_to_missing?(_method_name, _include_private = false) ⇒ Boolean
rubocop:enable Style/MethodMissing
26 27 28 |
# File 'lib/freshsales/api.rb', line 26 def respond_to_missing?(_method_name, _include_private = false) true end |