Module: SageOne::Configuration
- Included in:
- SageOne
- Defined in:
- lib/sage_one/configuration.rb
Overview
Provide numerous configuration options that control core behaviour.
Constant Summary collapse
- VALID_OPTIONS_KEYS =
[ :adapter, :faraday_config_block, :api_endpoint, :proxy, :access_token, :client_id, :client_secret, :user_agent, :request_host, :auto_traversal, :raw_response].freeze
- DEFAULT_ADAPTER =
Faraday.default_adapter
- DEFAULT_API_ENDPOINT =
'https://app.sageone.com/api/v1/'.freeze
- DEFAULT_USER_AGENT =
"SageOne Ruby Gem #{SageOne::VERSION}".freeze
- DEFAULT_AUTO_TRAVERSAL =
Only get the first page when making paginated data requests
false
- DEFAULT_RAW_RESPONSE =
Parse Json, Mashify & convert SData when making requests
false
Class Method Summary collapse
-
.extended(base) ⇒ Object
When extended call reset.
Instance Method Summary collapse
-
#api_endpoint=(value) ⇒ Object
Override the default API endpoint, this ensures a trailing forward slash is added.
-
#configure {|_self| ... } ⇒ Object
Yields the given block passing in selfing allow you to set config options on the ‘extend’-ing module.
-
#faraday_config(&block) ⇒ Object
Stores the given block which is called when the new Faraday::Connection is set up for all requests.
-
#options ⇒ Hash
All options with their current values.
-
#reset ⇒ Object
Sets the options to the default values.
Class Method Details
.extended(base) ⇒ Object
When extended call reset
63 64 65 |
# File 'lib/sage_one/configuration.rb', line 63 def self.extended(base) base.reset end |
Instance Method Details
#api_endpoint=(value) ⇒ Object
Override the default API endpoint, this ensures a trailing forward slash is added.
36 37 38 |
# File 'lib/sage_one/configuration.rb', line 36 def api_endpoint=(value) @api_endpoint = File.join(value, "") end |
#configure {|_self| ... } ⇒ Object
Yields the given block passing in selfing allow you to set config options on the ‘extend’-ing module.
53 54 55 |
# File 'lib/sage_one/configuration.rb', line 53 def configure yield self end |
#faraday_config(&block) ⇒ Object
Stores the given block which is called when the new Faraday::Connection is set up for all requests. This allow you to configure the connection, for example with your own middleware.
43 44 45 |
# File 'lib/sage_one/configuration.rb', line 43 def faraday_config(&block) @faraday_config_block = block end |
#options ⇒ Hash
Returns All options with their current values.
58 59 60 |
# File 'lib/sage_one/configuration.rb', line 58 def VALID_OPTIONS_KEYS.inject({}){|o,k| o.merge!(k => send(k)) } end |
#reset ⇒ Object
Sets the options to the default values
68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/sage_one/configuration.rb', line 68 def reset self.adapter = DEFAULT_ADAPTER self.api_endpoint = DEFAULT_API_ENDPOINT self.proxy = nil self.access_token = nil self.client_id = nil self.client_secret = nil self.request_host = nil self.user_agent = DEFAULT_USER_AGENT self.auto_traversal = DEFAULT_AUTO_TRAVERSAL self.raw_response = DEFAULT_RAW_RESPONSE end |