Class: Justifi::Configuration
- Inherits:
-
Object
- Object
- Justifi::Configuration
- Defined in:
- lib/justifi/configuration.rb
Constant Summary collapse
- API_BASE_URL =
"https://api.justifi.ai"
Instance Attribute Summary collapse
-
#access_token ⇒ Object
Returns the value of attribute access_token.
-
#cache ⇒ Object
Returns the value of attribute cache.
-
#client_id ⇒ Object
Returns the value of attribute client_id.
-
#client_secret ⇒ Object
Returns the value of attribute client_secret.
-
#environment ⇒ Object
Returns the value of attribute environment.
-
#max_attempts ⇒ Object
Returns the value of attribute max_attempts.
Class Method Summary collapse
Instance Method Summary collapse
- #api_url ⇒ Object
- #bad_credentials? ⇒ Boolean
- #clear_credentials ⇒ Object
- #credentials ⇒ Object
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
- #use_production ⇒ Object
- #use_staging ⇒ Object
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
22 23 24 |
# File 'lib/justifi/configuration.rb', line 22 def initialize @max_attempts = 3 end |
Instance Attribute Details
#access_token ⇒ Object
Returns the value of attribute access_token.
11 12 13 |
# File 'lib/justifi/configuration.rb', line 11 def access_token @access_token end |
#cache ⇒ Object
Returns the value of attribute cache.
14 15 16 |
# File 'lib/justifi/configuration.rb', line 14 def cache @cache end |
#client_id ⇒ Object
Returns the value of attribute client_id.
9 10 11 |
# File 'lib/justifi/configuration.rb', line 9 def client_id @client_id end |
#client_secret ⇒ Object
Returns the value of attribute client_secret.
10 11 12 |
# File 'lib/justifi/configuration.rb', line 10 def client_secret @client_secret end |
#environment ⇒ Object
Returns the value of attribute environment.
12 13 14 |
# File 'lib/justifi/configuration.rb', line 12 def environment @environment end |
#max_attempts ⇒ Object
Returns the value of attribute max_attempts.
13 14 15 |
# File 'lib/justifi/configuration.rb', line 13 def max_attempts @max_attempts end |
Class Method Details
.setup ⇒ Object
16 17 18 19 20 |
# File 'lib/justifi/configuration.rb', line 16 def self.setup new.tap do |instance| yield(instance) if block_given? end end |
Instance Method Details
#api_url ⇒ Object
45 46 47 48 49 50 51 52 |
# File 'lib/justifi/configuration.rb', line 45 def api_url case environment when "staging" ENV["API_STAGING_BASE_URL"] else API_BASE_URL end end |
#bad_credentials? ⇒ Boolean
35 36 37 38 |
# File 'lib/justifi/configuration.rb', line 35 def bad_credentials? # TODO: improve this return true if client_id.nil? || client_secret.nil? end |
#clear_credentials ⇒ Object
40 41 42 43 |
# File 'lib/justifi/configuration.rb', line 40 def clear_credentials @client_id = nil @client_secret = nil end |
#credentials ⇒ Object
26 27 28 29 30 31 32 33 |
# File 'lib/justifi/configuration.rb', line 26 def credentials raise Justifi::BadCredentialsError, "credentials not set" if bad_credentials? { client_id: client_id, client_secret: client_secret } end |
#use_production ⇒ Object
54 55 56 |
# File 'lib/justifi/configuration.rb', line 54 def use_production @environment = "production" end |
#use_staging ⇒ Object
58 59 60 |
# File 'lib/justifi/configuration.rb', line 58 def use_staging @environment = "staging" end |