Module: Booqable::Configurable

Included in:
Booqable, Client
Defined in:
lib/booqable/configurable.rb

Overview

Configuration options for Client, defaulting to values in Default

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#api_domainObject

Returns the value of attribute api_domain.



34
35
36
# File 'lib/booqable/configurable.rb', line 34

def api_domain
  @api_domain
end

#api_endpointString

Returns Base URL for API requests. default: company.booqable.com/api/4.

Returns:



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/booqable/configurable.rb', line 34

attr_accessor :api_domain,
:api_endpoint,
:api_key,
:api_version,
:auto_paginate,
:client_id,
:client_secret,
:company_id,
:connection_options,
:debug,
:default_media_type,
:middleware,
:no_retries,
:per_page,
:proxy,
:read_token,
:redirect_uri,
:single_use_token,
:single_use_token_algorithm,
:single_use_token_company_id,
:single_use_token_expiration_period,
:single_use_token_private_key,
:single_use_token_secret,
:single_use_token_user_id,
:ssl_verify_mode,
:user_agent,
:write_token

#api_keyObject

Returns the value of attribute api_key.



34
35
36
# File 'lib/booqable/configurable.rb', line 34

def api_key
  @api_key
end

#api_versionObject

Returns the value of attribute api_version.



34
35
36
# File 'lib/booqable/configurable.rb', line 34

def api_version
  @api_version
end

#auto_paginateBoolean

Returns Auto fetch next page of results until rate limit reached.

Returns:

  • (Boolean)

    Auto fetch next page of results until rate limit reached



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/booqable/configurable.rb', line 34

attr_accessor :api_domain,
:api_endpoint,
:api_key,
:api_version,
:auto_paginate,
:client_id,
:client_secret,
:company_id,
:connection_options,
:debug,
:default_media_type,
:middleware,
:no_retries,
:per_page,
:proxy,
:read_token,
:redirect_uri,
:single_use_token,
:single_use_token_algorithm,
:single_use_token_company_id,
:single_use_token_expiration_period,
:single_use_token_private_key,
:single_use_token_secret,
:single_use_token_user_id,
:ssl_verify_mode,
:user_agent,
:write_token

#client_idString

Returns Configure OAuth app key.

Returns:

  • (String)

    Configure OAuth app key



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/booqable/configurable.rb', line 34

attr_accessor :api_domain,
:api_endpoint,
:api_key,
:api_version,
:auto_paginate,
:client_id,
:client_secret,
:company_id,
:connection_options,
:debug,
:default_media_type,
:middleware,
:no_retries,
:per_page,
:proxy,
:read_token,
:redirect_uri,
:single_use_token,
:single_use_token_algorithm,
:single_use_token_company_id,
:single_use_token_expiration_period,
:single_use_token_private_key,
:single_use_token_secret,
:single_use_token_user_id,
:ssl_verify_mode,
:user_agent,
:write_token

#client_secretObject

Returns the value of attribute client_secret.



34
35
36
# File 'lib/booqable/configurable.rb', line 34

def client_secret
  @client_secret
end

#company_idObject

Returns the value of attribute company_id.



34
35
36
# File 'lib/booqable/configurable.rb', line 34

def company_id
  @company_id
end

#connection_optionsHash

Returns Configure connection options for Faraday.

Returns:

  • (Hash)

    Configure connection options for Faraday

See Also:



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/booqable/configurable.rb', line 34

attr_accessor :api_domain,
:api_endpoint,
:api_key,
:api_version,
:auto_paginate,
:client_id,
:client_secret,
:company_id,
:connection_options,
:debug,
:default_media_type,
:middleware,
:no_retries,
:per_page,
:proxy,
:read_token,
:redirect_uri,
:single_use_token,
:single_use_token_algorithm,
:single_use_token_company_id,
:single_use_token_expiration_period,
:single_use_token_private_key,
:single_use_token_secret,
:single_use_token_user_id,
:ssl_verify_mode,
:user_agent,
:write_token

#debugObject

Returns the value of attribute debug.



34
35
36
# File 'lib/booqable/configurable.rb', line 34

def debug
  @debug
end

#default_media_typeString

Returns Configure preferred media type (for API versioning, for example).

Returns:

  • (String)

    Configure preferred media type (for API versioning, for example)



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/booqable/configurable.rb', line 34

attr_accessor :api_domain,
:api_endpoint,
:api_key,
:api_version,
:auto_paginate,
:client_id,
:client_secret,
:company_id,
:connection_options,
:debug,
:default_media_type,
:middleware,
:no_retries,
:per_page,
:proxy,
:read_token,
:redirect_uri,
:single_use_token,
:single_use_token_algorithm,
:single_use_token_company_id,
:single_use_token_expiration_period,
:single_use_token_private_key,
:single_use_token_secret,
:single_use_token_user_id,
:ssl_verify_mode,
:user_agent,
:write_token

#middlewareFaraday::Builder or Faraday::RackBuilder

Returns Configure middleware for Faraday.

Returns:

  • (Faraday::Builder or Faraday::RackBuilder)

    Configure middleware for Faraday

See Also:



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/booqable/configurable.rb', line 34

attr_accessor :api_domain,
:api_endpoint,
:api_key,
:api_version,
:auto_paginate,
:client_id,
:client_secret,
:company_id,
:connection_options,
:debug,
:default_media_type,
:middleware,
:no_retries,
:per_page,
:proxy,
:read_token,
:redirect_uri,
:single_use_token,
:single_use_token_algorithm,
:single_use_token_company_id,
:single_use_token_expiration_period,
:single_use_token_private_key,
:single_use_token_secret,
:single_use_token_user_id,
:ssl_verify_mode,
:user_agent,
:write_token

#no_retriesObject

Returns the value of attribute no_retries.



34
35
36
# File 'lib/booqable/configurable.rb', line 34

def no_retries
  @no_retries
end

#per_pageString

Returns Configure page size for paginated results. API default: 25.

Returns:

  • (String)

    Configure page size for paginated results. API default: 25



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/booqable/configurable.rb', line 34

attr_accessor :api_domain,
:api_endpoint,
:api_key,
:api_version,
:auto_paginate,
:client_id,
:client_secret,
:company_id,
:connection_options,
:debug,
:default_media_type,
:middleware,
:no_retries,
:per_page,
:proxy,
:read_token,
:redirect_uri,
:single_use_token,
:single_use_token_algorithm,
:single_use_token_company_id,
:single_use_token_expiration_period,
:single_use_token_private_key,
:single_use_token_secret,
:single_use_token_user_id,
:ssl_verify_mode,
:user_agent,
:write_token

#proxyString

Returns URI for proxy server.

Returns:

  • (String)

    URI for proxy server

See Also:



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/booqable/configurable.rb', line 34

attr_accessor :api_domain,
:api_endpoint,
:api_key,
:api_version,
:auto_paginate,
:client_id,
:client_secret,
:company_id,
:connection_options,
:debug,
:default_media_type,
:middleware,
:no_retries,
:per_page,
:proxy,
:read_token,
:redirect_uri,
:single_use_token,
:single_use_token_algorithm,
:single_use_token_company_id,
:single_use_token_expiration_period,
:single_use_token_private_key,
:single_use_token_secret,
:single_use_token_user_id,
:ssl_verify_mode,
:user_agent,
:write_token

#read_tokenObject

Returns the value of attribute read_token.



34
35
36
# File 'lib/booqable/configurable.rb', line 34

def read_token
  @read_token
end

#redirect_uriObject

Returns the value of attribute redirect_uri.



34
35
36
# File 'lib/booqable/configurable.rb', line 34

def redirect_uri
  @redirect_uri
end

#single_use_tokenObject

Returns the value of attribute single_use_token.



34
35
36
# File 'lib/booqable/configurable.rb', line 34

def single_use_token
  @single_use_token
end

#single_use_token_algorithmObject

Returns the value of attribute single_use_token_algorithm.



34
35
36
# File 'lib/booqable/configurable.rb', line 34

def single_use_token_algorithm
  @single_use_token_algorithm
end

#single_use_token_company_idObject

Returns the value of attribute single_use_token_company_id.



34
35
36
# File 'lib/booqable/configurable.rb', line 34

def single_use_token_company_id
  @single_use_token_company_id
end

#single_use_token_expiration_periodObject

Returns the value of attribute single_use_token_expiration_period.



34
35
36
# File 'lib/booqable/configurable.rb', line 34

def single_use_token_expiration_period
  @single_use_token_expiration_period
end

#single_use_token_private_keyObject

Returns the value of attribute single_use_token_private_key.



34
35
36
# File 'lib/booqable/configurable.rb', line 34

def single_use_token_private_key
  @single_use_token_private_key
end

#single_use_token_secretObject

Returns the value of attribute single_use_token_secret.



34
35
36
# File 'lib/booqable/configurable.rb', line 34

def single_use_token_secret
  @single_use_token_secret
end

#single_use_token_user_idObject

Returns the value of attribute single_use_token_user_id.



34
35
36
# File 'lib/booqable/configurable.rb', line 34

def single_use_token_user_id
  @single_use_token_user_id
end

#ssl_verify_modeString

Returns SSL verify mode for ssl connections.

Returns:

  • (String)

    SSL verify mode for ssl connections

See Also:



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/booqable/configurable.rb', line 34

attr_accessor :api_domain,
:api_endpoint,
:api_key,
:api_version,
:auto_paginate,
:client_id,
:client_secret,
:company_id,
:connection_options,
:debug,
:default_media_type,
:middleware,
:no_retries,
:per_page,
:proxy,
:read_token,
:redirect_uri,
:single_use_token,
:single_use_token_algorithm,
:single_use_token_company_id,
:single_use_token_expiration_period,
:single_use_token_private_key,
:single_use_token_secret,
:single_use_token_user_id,
:ssl_verify_mode,
:user_agent,
:write_token

#user_agentString

Returns Configure User-Agent header for requests.

Returns:

  • (String)

    Configure User-Agent header for requests.



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/booqable/configurable.rb', line 34

attr_accessor :api_domain,
:api_endpoint,
:api_key,
:api_version,
:auto_paginate,
:client_id,
:client_secret,
:company_id,
:connection_options,
:debug,
:default_media_type,
:middleware,
:no_retries,
:per_page,
:proxy,
:read_token,
:redirect_uri,
:single_use_token,
:single_use_token_algorithm,
:single_use_token_company_id,
:single_use_token_expiration_period,
:single_use_token_private_key,
:single_use_token_secret,
:single_use_token_user_id,
:ssl_verify_mode,
:user_agent,
:write_token

#write_tokenObject

Returns the value of attribute write_token.



34
35
36
# File 'lib/booqable/configurable.rb', line 34

def write_token
  @write_token
end

Class Method Details

.keysArray

List of configurable keys for Booqable::Client

Returns:

  • (Array)

    of option keys



65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# File 'lib/booqable/configurable.rb', line 65

def keys
  @keys ||= %i[
    api_domain
    api_endpoint
    api_key
    api_version
    auto_paginate
    client_id
    client_secret
    company_id
    connection_options
    debug
    default_media_type
    middleware
    no_retries
    per_page
    proxy
    read_token
    redirect_uri
    single_use_token
    single_use_token_algorithm
    single_use_token_company_id
    single_use_token_expiration_period
    single_use_token_private_key
    single_use_token_secret
    single_use_token_user_id
    ssl_verify_mode
    user_agent
    write_token
  ]
end

Instance Method Details

#configure {|_self| ... } ⇒ Object

Set configuration options using a block

Yields:

  • (_self)

Yield Parameters:



99
100
101
# File 'lib/booqable/configurable.rb', line 99

def configure
  yield self
end

#debug?Boolean

Whether to print debug information

Returns:

  • (Boolean)

    true if debug mode is enabled, false otherwise



129
130
131
# File 'lib/booqable/configurable.rb', line 129

def debug?
  @debug || false
end

#reset!Object Also known as: setup

Reset configuration options to default values



104
105
106
107
108
109
110
111
112
113
114
115
# File 'lib/booqable/configurable.rb', line 104

def reset!
  # rubocop:disable Style/HashEachMethods
  #
  # This may look like a `.keys.each` which should be replaced with `#each_key`, but
  # this doesn't actually work, since `#keys` is just a method we've defined ourselves.
  # The class doesn't fulfill the whole `Enumerable` contract.
  Booqable::Configurable.keys.each do |key|
    # rubocop:enable Style/HashEachMethods
    instance_variable_set(:"@#{key}", Booqable::Default.options[key])
  end
  self
end

#same_options?(opts) ⇒ Boolean

Compares client options to a Hash of requested options

Parameters:

  • opts (Hash)

    Options to compare with current client options

Returns:

  • (Boolean)


122
123
124
# File 'lib/booqable/configurable.rb', line 122

def same_options?(opts)
  opts.hash == options.hash
end