Module: Booqable::Default
- Defined in:
- lib/booqable/default.rb
Overview
Default configuration options for Client
Provides default values for all configuration options, with support for environment variable overrides. All defaults can be overridden by setting the appropriate environment variables.
Constant Summary collapse
- USER_AGENT =
Default User Agent header string
"Booqable Ruby Gem #{Booqable::VERSION}"- MEDIA_TYPE =
Default media type (json:api) for requests
"application/vnd.api+json"- RETRY_OPTIONS =
Default retry options for Faraday::Retry middleware
{ exceptions: Faraday::Retry::Middleware::DEFAULT_EXCEPTIONS + [ Booqable::ServerError ], max: 2, # maximum number of retries (total of 3 attempts including the first) interval: 2, # seconds to wait before retrying interval_randomness: 0.5, # randomize the interval by this amount backoff_factor: 2 # multiply the interval by this factor on each retry }
- MIDDLEWARE =
Basic middleware stack for Faraday::Connection (without authentication middleware)
Faraday::RackBuilder.new do |builder| # Retry middleware builder.use Faraday::Retry::Middleware, RETRY_OPTIONS # Error handling middleware builder.use Booqable::Middleware::RaiseError builder.adapter Faraday.default_adapter end
Class Method Summary collapse
-
.api_domain ⇒ String
Default API endpoint from ENV.
-
.api_endpoint ⇒ String?
Default API endpoint from ENV.
-
.api_key ⇒ String?
Default API key from ENV.
-
.api_version ⇒ Integer
Default API version from ENV.
-
.around_refresh_token ⇒ Proc?
Default ‘around_refresh_token` callable.
-
.auto_paginate ⇒ String
Default pagination preference from ENV.
-
.client_id ⇒ String
Default OAuth app key from ENV.
-
.client_secret ⇒ String
Default OAuth app secret from ENV.
-
.company_id ⇒ String?
Default company ID from ENV.
-
.connection_options ⇒ Hash
Default options for Faraday::Connection.
-
.debug ⇒ Boolean
Default debug mode setting.
-
.default_media_type ⇒ String
Default media type from ENV or MEDIA_TYPE.
-
.middleware ⇒ Faraday::RackBuilder or Faraday::Builder
Default middleware stack for Faraday::Connection from MIDDLEWARE.
-
.no_retries ⇒ Boolean
Default retry setting.
-
.options ⇒ Hash
Configuration options.
-
.per_page ⇒ Integer
Default pagination page size from ENV.
-
.proxy ⇒ String
Default proxy server URI for Faraday connection from ENV.
-
.read_token ⇒ Proc
Default OAuth token reader.
-
.redirect_uri ⇒ String
Default redirect URI for OAuth from ENV.
-
.single_use_token ⇒ String?
Default single use token from ENV.
-
.single_use_token_algorithm ⇒ String?
Default single use token algorithm from ENV.
-
.single_use_token_company_id ⇒ String?
Default single use token company ID from ENV.
-
.single_use_token_expiration_period ⇒ Integer
Default single use token expiration period from ENV.
-
.single_use_token_private_key ⇒ String?
Default single use token private key from ENV.
-
.single_use_token_secret ⇒ String?
Default single use token secret from ENV.
-
.single_use_token_user_id ⇒ String?
Default single use token user ID from ENV.
-
.ssl_verify_mode ⇒ Integer
Default SSL verify mode from ENV.
-
.user_agent ⇒ String
Default User-Agent header string from ENV or USER_AGENT.
-
.write_token ⇒ Proc
Default OAuth token writer.
Class Method Details
.api_domain ⇒ String
Default API endpoint from ENV
48 49 50 |
# File 'lib/booqable/default.rb', line 48 def api_domain ENV.fetch("BOOQABLE_API_DOMAIN", "booqable.com") end |
.api_endpoint ⇒ String?
Default API endpoint from ENV
60 61 62 |
# File 'lib/booqable/default.rb', line 60 def api_endpoint ENV.fetch("BOOQABLE_API_ENDPOINT", nil) end |
.api_key ⇒ String?
Default API key from ENV
167 168 169 |
# File 'lib/booqable/default.rb', line 167 def api_key ENV.fetch("BOOQABLE_API_KEY", nil) end |
.api_version ⇒ Integer
Default API version from ENV
54 55 56 |
# File 'lib/booqable/default.rb', line 54 def api_version ENV.fetch("BOOQABLE_API_VERSION", 4) end |
.around_refresh_token ⇒ Proc?
Default ‘around_refresh_token` callable
When non-nil, the OAuth middleware yields its read+check+refresh sequence to this callable so the host application can serialize concurrent refreshes (e.g. with an advisory lock).
161 162 163 |
# File 'lib/booqable/default.rb', line 161 def around_refresh_token nil end |
.auto_paginate ⇒ String
Default pagination preference from ENV
66 67 68 |
# File 'lib/booqable/default.rb', line 66 def auto_paginate ENV.fetch("BOOQABLE_AUTO_PAGINATE", nil) end |
.client_id ⇒ String
Default OAuth app key from ENV
72 73 74 |
# File 'lib/booqable/default.rb', line 72 def client_id ENV.fetch("BOOQABLE_CLIENT_ID", nil) end |
.client_secret ⇒ String
Default OAuth app secret from ENV
78 79 80 |
# File 'lib/booqable/default.rb', line 78 def client_secret ENV.fetch("BOOQABLE_CLIENT_SECRET", nil) end |
.company_id ⇒ String?
Default company ID from ENV
84 85 86 |
# File 'lib/booqable/default.rb', line 84 def company_id ENV.fetch("BOOQABLE_COMPANY_ID", nil) end |
.connection_options ⇒ Hash
Default options for Faraday::Connection
96 97 98 |
# File 'lib/booqable/default.rb', line 96 def nil end |
.debug ⇒ Boolean
Default debug mode setting
215 216 217 |
# File 'lib/booqable/default.rb', line 215 def debug false end |
.default_media_type ⇒ String
Default media type from ENV or MEDIA_TYPE
102 103 104 |
# File 'lib/booqable/default.rb', line 102 def default_media_type ENV.fetch("BOOQABLE_DEFAULT_MEDIA_TYPE") { MEDIA_TYPE } end |
.middleware ⇒ Faraday::RackBuilder or Faraday::Builder
Default middleware stack for Faraday::Connection from MIDDLEWARE
109 110 111 |
# File 'lib/booqable/default.rb', line 109 def middleware MIDDLEWARE end |
.no_retries ⇒ Boolean
Default retry setting
221 222 223 |
# File 'lib/booqable/default.rb', line 221 def no_retries false end |
.options ⇒ Hash
Configuration options
42 43 44 |
# File 'lib/booqable/default.rb', line 42 def Booqable::Configurable.keys.to_h { |key| [ key, send(key) ] } end |
.per_page ⇒ Integer
Default pagination page size from ENV
115 116 117 118 119 |
# File 'lib/booqable/default.rb', line 115 def per_page page_size = ENV.fetch("BOOQABLE_PER_PAGE", 25) page_size&.to_i end |
.proxy ⇒ String
Default proxy server URI for Faraday connection from ENV
123 124 125 |
# File 'lib/booqable/default.rb', line 123 def proxy ENV.fetch("BOOQABLE_PROXY", nil) end |
.read_token ⇒ Proc
Default OAuth token reader
144 145 146 |
# File 'lib/booqable/default.rb', line 144 def read_token Proc.new { } end |
.redirect_uri ⇒ String
Default redirect URI for OAuth from ENV
90 91 92 |
# File 'lib/booqable/default.rb', line 90 def redirect_uri ENV.fetch("BOOQABLE_REDIRECT_URI", nil) end |
.single_use_token ⇒ String?
Default single use token from ENV
173 174 175 |
# File 'lib/booqable/default.rb', line 173 def single_use_token ENV.fetch("BOOQABLE_SINGLE_USE_TOKEN", nil) end |
.single_use_token_algorithm ⇒ String?
Default single use token algorithm from ENV
179 180 181 |
# File 'lib/booqable/default.rb', line 179 def single_use_token_algorithm ENV.fetch("BOOQABLE_SINGLE_USE_TOKEN_ALGORITHM", nil) end |
.single_use_token_company_id ⇒ String?
Default single use token company ID from ENV
203 204 205 |
# File 'lib/booqable/default.rb', line 203 def single_use_token_company_id ENV.fetch("BOOQABLE_SINGLE_USE_TOKEN_COMPANY_ID", nil) end |
.single_use_token_expiration_period ⇒ Integer
Default single use token expiration period from ENV
197 198 199 |
# File 'lib/booqable/default.rb', line 197 def single_use_token_expiration_period ENV.fetch("BOOQABLE_SINGLE_USE_TOKEN_EXPIRATION_PERIOD") { 10 * 60 }.to_i # default to 10 minutes end |
.single_use_token_private_key ⇒ String?
Default single use token private key from ENV
191 192 193 |
# File 'lib/booqable/default.rb', line 191 def single_use_token_private_key ENV.fetch("BOOQABLE_SINGLE_USE_TOKEN_PRIVATE_KEY", nil) end |
.single_use_token_secret ⇒ String?
Default single use token secret from ENV
185 186 187 |
# File 'lib/booqable/default.rb', line 185 def single_use_token_secret ENV.fetch("BOOQABLE_SINGLE_USE_TOKEN_SECRET", nil) end |
.single_use_token_user_id ⇒ String?
Default single use token user ID from ENV
209 210 211 |
# File 'lib/booqable/default.rb', line 209 def single_use_token_user_id ENV.fetch("BOOQABLE_SINGLE_USE_TOKEN_USER_ID", nil) end |
.ssl_verify_mode ⇒ Integer
Default SSL verify mode from ENV
129 130 131 132 133 134 |
# File 'lib/booqable/default.rb', line 129 def ssl_verify_mode # 0 is OpenSSL::SSL::VERIFY_NONE # 1 is OpenSSL::SSL::SSL_VERIFY_PEER # the standard default for SSL is SSL_VERIFY_PEER which requires a server certificate check on the client ENV.fetch("BOOQABLE_SSL_VERIFY_MODE", 1).to_i end |
.user_agent ⇒ String
Default User-Agent header string from ENV or USER_AGENT
138 139 140 |
# File 'lib/booqable/default.rb', line 138 def user_agent ENV.fetch("BOOQABLE_USER_AGENT") { USER_AGENT } end |
.write_token ⇒ Proc
Default OAuth token writer
150 151 152 |
# File 'lib/booqable/default.rb', line 150 def write_token Proc.new { } end |