Class: ZendeskAPI::Configuration
- Inherits:
-
Object
- Object
- ZendeskAPI::Configuration
- Defined in:
- lib/zendesk_api/configuration.rb
Overview
Holds the configuration options for the client and connection
Instance Attribute Summary collapse
-
#access_token ⇒ String
OAuth2 access_token.
-
#adapter ⇒ Symbol
Faraday adapter.
-
#allow_http ⇒ Boolean
Whether to allow non-HTTPS connections for development purposes.
-
#cache ⇒ ZendeskAPI::LRUCache
Use this cache instead of default ZendeskAPI::LRUCache.new - must respond to read/write/fetch e.g.
-
#client_options ⇒ Hash
Client configurations (eg ssh config) to pass to Faraday.
-
#logger ⇒ Logger
Logger to use when logging requests.
-
#password ⇒ String
The basic auth password.
-
#raise_error_when_rate_limited ⇒ Boolean
Whether to raise error when rate-limited (http status: 429).
-
#retry ⇒ Boolean
Whether to attempt to retry when rate-limited (http status: 429).
-
#retry_codes ⇒ Object
specify the server error codes in which you want a retry to be attempted.
-
#retry_on_exception ⇒ Object
specify if you want a (network layer) exception to elicit a retry.
-
#token ⇒ String
The basic auth token.
-
#url ⇒ String
The API url.
-
#url_based_access_token ⇒ Object
Returns the value of attribute url_based_access_token.
-
#use_resource_cache ⇒ Boolean
Whether to use resource_cache or not.
-
#username ⇒ String
The basic auth username.
Instance Method Summary collapse
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
-
#options ⇒ Hash
Sets accept and user_agent headers, and url.
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
54 55 56 57 58 59 |
# File 'lib/zendesk_api/configuration.rb', line 54 def initialize @client_options = {} @use_resource_cache = true self.cache = ZendeskAPI::LRUCache.new(1000) end |
Instance Attribute Details
#access_token ⇒ String
Returns OAuth2 access_token.
35 36 37 |
# File 'lib/zendesk_api/configuration.rb', line 35 def access_token @access_token end |
#adapter ⇒ Symbol
Returns Faraday adapter.
29 30 31 |
# File 'lib/zendesk_api/configuration.rb', line 29 def adapter @adapter end |
#allow_http ⇒ Boolean
Returns Whether to allow non-HTTPS connections for development purposes.
32 33 34 |
# File 'lib/zendesk_api/configuration.rb', line 32 def allow_http @allow_http end |
#cache ⇒ ZendeskAPI::LRUCache
Use this cache instead of default ZendeskAPI::LRUCache.new
-
must respond to read/write/fetch e.g. ActiveSupport::Cache::MemoryStore.new)
-
pass false to disable caching
43 44 45 |
# File 'lib/zendesk_api/configuration.rb', line 43 def cache @cache end |
#client_options ⇒ Hash
Returns Client configurations (eg ssh config) to pass to Faraday.
26 27 28 |
# File 'lib/zendesk_api/configuration.rb', line 26 def @client_options end |
#logger ⇒ Logger
Returns Logger to use when logging requests.
23 24 25 |
# File 'lib/zendesk_api/configuration.rb', line 23 def logger @logger end |
#password ⇒ String
Returns The basic auth password.
8 9 10 |
# File 'lib/zendesk_api/configuration.rb', line 8 def password @password end |
#raise_error_when_rate_limited ⇒ Boolean
Returns Whether to raise error when rate-limited (http status: 429).
20 21 22 |
# File 'lib/zendesk_api/configuration.rb', line 20 def raise_error_when_rate_limited @raise_error_when_rate_limited end |
#retry ⇒ Boolean
Returns Whether to attempt to retry when rate-limited (http status: 429).
17 18 19 |
# File 'lib/zendesk_api/configuration.rb', line 17 def retry @retry end |
#retry_codes ⇒ Object
specify the server error codes in which you want a retry to be attempted
49 50 51 |
# File 'lib/zendesk_api/configuration.rb', line 49 def retry_codes @retry_codes end |
#retry_on_exception ⇒ Object
specify if you want a (network layer) exception to elicit a retry
52 53 54 |
# File 'lib/zendesk_api/configuration.rb', line 52 def retry_on_exception @retry_on_exception end |
#token ⇒ String
Returns The basic auth token.
11 12 13 |
# File 'lib/zendesk_api/configuration.rb', line 11 def token @token end |
#url ⇒ String
Returns The API url. Must be https unless #allow_http is set.
14 15 16 |
# File 'lib/zendesk_api/configuration.rb', line 14 def url @url end |
#url_based_access_token ⇒ Object
Returns the value of attribute url_based_access_token.
37 38 39 |
# File 'lib/zendesk_api/configuration.rb', line 37 def url_based_access_token @url_based_access_token end |
#use_resource_cache ⇒ Boolean
Returns Whether to use resource_cache or not.
46 47 48 |
# File 'lib/zendesk_api/configuration.rb', line 46 def use_resource_cache @use_resource_cache end |
#username ⇒ String
Returns The basic auth username.
5 6 7 |
# File 'lib/zendesk_api/configuration.rb', line 5 def username @username end |
Instance Method Details
#options ⇒ Hash
Sets accept and user_agent headers, and url.
64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/zendesk_api/configuration.rb', line 64 def { :headers => { :accept => 'application/json', :accept_encoding => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', :user_agent => "ZendeskAPI Ruby #{ZendeskAPI::VERSION}" }, :request => { :open_timeout => 10, :timeout => 60 }, :url => @url }.merge() end |