Module: Api::Configurable
- Included in:
- Client
- Defined in:
- lib/api/configurable.rb
Overview
Instance Attribute Summary collapse
-
#access_token ⇒ Object
Returns the value of attribute access_token.
-
#access_token_prefix ⇒ Object
Returns the value of attribute access_token_prefix.
-
#api_endpoint ⇒ String
Base URL for API requests.
-
#api_version ⇒ String
Version of the api.
-
#auto_paginate ⇒ Boolean
Auto fetch next page of results until rate limit reached.
-
#basic_login ⇒ Object
Returns the value of attribute basic_login.
-
#basic_password ⇒ Object
Returns the value of attribute basic_password.
-
#connection_options ⇒ Hash
Configure connection options for Faraday.
-
#per_page ⇒ String
Configure page size for paginated results.
-
#sawyer_options ⇒ Hash
Configure sawyer options.
-
#user_agent ⇒ String
Configure User-Agent header for requests.
Class Method Summary collapse
-
.keys ⇒ Array
List of configurable keys for Client.
Instance Method Summary collapse
-
#configure {|_self| ... } ⇒ Object
Set configuration options using a block.
-
#reset!(options = {}) ⇒ Object
Reset configuration options to default values.
-
#same_options?(opts) ⇒ Boolean
Compares client options to a Hash of requested options.
Instance Attribute Details
#access_token ⇒ Object
Returns the value of attribute access_token.
31 32 33 |
# File 'lib/api/configurable.rb', line 31 def access_token @access_token end |
#access_token_prefix ⇒ Object
Returns the value of attribute access_token_prefix.
31 32 33 |
# File 'lib/api/configurable.rb', line 31 def access_token_prefix @access_token_prefix end |
#api_endpoint ⇒ String
Returns Base URL for API requests.
31 |
# File 'lib/api/configurable.rb', line 31 attr_accessor :access_token, :access_token_prefix, :basic_login, :basic_password, :connection_options, :sawyer_options, :user_agent, :auto_paginate, :per_page |
#api_version ⇒ String
Returns Version of the api. default: v1.
31 |
# File 'lib/api/configurable.rb', line 31 attr_accessor :access_token, :access_token_prefix, :basic_login, :basic_password, :connection_options, :sawyer_options, :user_agent, :auto_paginate, :per_page |
#auto_paginate ⇒ Boolean
Returns Auto fetch next page of results until rate limit reached. Will only work with an Hypermedia API.
31 |
# File 'lib/api/configurable.rb', line 31 attr_accessor :access_token, :access_token_prefix, :basic_login, :basic_password, :connection_options, :sawyer_options, :user_agent, :auto_paginate, :per_page |
#basic_login ⇒ Object
Returns the value of attribute basic_login.
31 32 33 |
# File 'lib/api/configurable.rb', line 31 def basic_login @basic_login end |
#basic_password ⇒ Object
Returns the value of attribute basic_password.
31 32 33 |
# File 'lib/api/configurable.rb', line 31 def basic_password @basic_password end |
#connection_options ⇒ Hash
Returns Configure connection options for Faraday.
31 |
# File 'lib/api/configurable.rb', line 31 attr_accessor :access_token, :access_token_prefix, :basic_login, :basic_password, :connection_options, :sawyer_options, :user_agent, :auto_paginate, :per_page |
#per_page ⇒ String
Returns Configure page size for paginated results. API default: 30.
31 |
# File 'lib/api/configurable.rb', line 31 attr_accessor :access_token, :access_token_prefix, :basic_login, :basic_password, :connection_options, :sawyer_options, :user_agent, :auto_paginate, :per_page |
#sawyer_options ⇒ Hash
Returns Configure sawyer options.
31 |
# File 'lib/api/configurable.rb', line 31 attr_accessor :access_token, :access_token_prefix, :basic_login, :basic_password, :connection_options, :sawyer_options, :user_agent, :auto_paginate, :per_page |
#user_agent ⇒ String
Returns Configure User-Agent header for requests.
31 |
# File 'lib/api/configurable.rb', line 31 attr_accessor :access_token, :access_token_prefix, :basic_login, :basic_password, :connection_options, :sawyer_options, :user_agent, :auto_paginate, :per_page |
Class Method Details
.keys ⇒ Array
List of configurable keys for Api::Client
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/api/configurable.rb', line 38 def keys @keys ||= [ :access_token, :access_token_prefix, :api_endpoint, :api_version, :auto_paginate, :basic_login, :basic_password, :connection_options, :sawyer_options, :per_page, :user_agent, ] end |
Instance Method Details
#configure {|_self| ... } ⇒ Object
Set configuration options using a block
56 57 58 |
# File 'lib/api/configurable.rb', line 56 def configure yield self end |
#reset!(options = {}) ⇒ Object
Reset configuration options to default values
69 70 71 72 73 74 75 76 |
# File 'lib/api/configurable.rb', line 69 def reset!( = {}) default_class = module_defaults || class_defaults Api::Configurable.keys.each do |key| value = [key] || default_class.[key] || Api::Default.[key] instance_variable_set(:"@#{key}", value) end self end |
#same_options?(opts) ⇒ Boolean
Compares client options to a Hash of requested options
64 65 66 |
# File 'lib/api/configurable.rb', line 64 def (opts) opts.hash == .hash end |