Class: Afterpay::Config
- Inherits:
-
Object
- Object
- Afterpay::Config
- Defined in:
- lib/afterpay/config.rb
Instance Attribute Summary collapse
-
#app_id ⇒ Object
Returns the value of attribute app_id.
-
#currency ⇒ Object
Returns the value of attribute currency.
-
#description ⇒ Object
Returns the value of attribute description.
-
#env ⇒ Object
Returns the value of attribute env.
-
#maximum_amount ⇒ Object
Returns the value of attribute maximum_amount.
-
#minimum_amount ⇒ Object
Returns the value of attribute minimum_amount.
-
#raise_errors ⇒ Object
Returns the value of attribute raise_errors.
-
#secret ⇒ Object
Returns the value of attribute secret.
-
#skip_remote_config ⇒ Object
Returns the value of attribute skip_remote_config.
-
#type ⇒ Object
Returns the value of attribute type.
-
#user_agent_header ⇒ Object
Returns the value of attribute user_agent_header.
Instance Method Summary collapse
-
#fetch_remote_config ⇒ Object
Called only after app_id and secred is set.
-
#initialize ⇒ Config
constructor
A new instance of Config.
Constructor Details
#initialize ⇒ Config
Returns a new instance of Config.
10 11 12 13 14 |
# File 'lib/afterpay/config.rb', line 10 def initialize @env = "sandbox" @raise_errors = true @skip_remote_config = false end |
Instance Attribute Details
#app_id ⇒ Object
Returns the value of attribute app_id.
5 6 7 |
# File 'lib/afterpay/config.rb', line 5 def app_id @app_id end |
#currency ⇒ Object
Returns the value of attribute currency.
5 6 7 |
# File 'lib/afterpay/config.rb', line 5 def currency @currency end |
#description ⇒ Object
Returns the value of attribute description.
5 6 7 |
# File 'lib/afterpay/config.rb', line 5 def description @description end |
#env ⇒ Object
Returns the value of attribute env.
5 6 7 |
# File 'lib/afterpay/config.rb', line 5 def env @env end |
#maximum_amount ⇒ Object
Returns the value of attribute maximum_amount.
5 6 7 |
# File 'lib/afterpay/config.rb', line 5 def maximum_amount @maximum_amount end |
#minimum_amount ⇒ Object
Returns the value of attribute minimum_amount.
5 6 7 |
# File 'lib/afterpay/config.rb', line 5 def minimum_amount @minimum_amount end |
#raise_errors ⇒ Object
Returns the value of attribute raise_errors.
5 6 7 |
# File 'lib/afterpay/config.rb', line 5 def raise_errors @raise_errors end |
#secret ⇒ Object
Returns the value of attribute secret.
5 6 7 |
# File 'lib/afterpay/config.rb', line 5 def secret @secret end |
#skip_remote_config ⇒ Object
Returns the value of attribute skip_remote_config.
5 6 7 |
# File 'lib/afterpay/config.rb', line 5 def skip_remote_config @skip_remote_config end |
#type ⇒ Object
Returns the value of attribute type.
5 6 7 |
# File 'lib/afterpay/config.rb', line 5 def type @type end |
#user_agent_header ⇒ Object
Returns the value of attribute user_agent_header.
5 6 7 |
# File 'lib/afterpay/config.rb', line 5 def user_agent_header @user_agent_header end |
Instance Method Details
#fetch_remote_config ⇒ Object
Called only after app_id and secred is set
17 18 19 20 21 22 23 24 |
# File 'lib/afterpay/config.rb', line 17 def fetch_remote_config response = Afterpay.client.get("/v1/configuration").body[0] @type = response[:type] @minimum_amount = response.dig(:minimumAmount, :amount).to_f @maximum_amount = response.dig(:maximumAmount, :amount).to_f @description = response[:description] end |