Class: Afterpay::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/afterpay/config.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfig

Returns a new instance of Config.



11
12
13
14
15
# File 'lib/afterpay/config.rb', line 11

def initialize
  @env = "sandbox"
  @raise_errors = true
  @skip_remote_config = false
end

Instance Attribute Details

#afterpay_pluginObject

Returns the value of attribute afterpay_plugin.



5
6
7
# File 'lib/afterpay/config.rb', line 5

def afterpay_plugin
  @afterpay_plugin
end

#app_idObject

Returns the value of attribute app_id.



5
6
7
# File 'lib/afterpay/config.rb', line 5

def app_id
  @app_id
end

#currencyObject

Returns the value of attribute currency.



5
6
7
# File 'lib/afterpay/config.rb', line 5

def currency
  @currency
end

#descriptionObject

Returns the value of attribute description.



5
6
7
# File 'lib/afterpay/config.rb', line 5

def description
  @description
end

#envObject

Returns the value of attribute env.



5
6
7
# File 'lib/afterpay/config.rb', line 5

def env
  @env
end

#maximum_amountObject

Returns the value of attribute maximum_amount.



5
6
7
# File 'lib/afterpay/config.rb', line 5

def maximum_amount
  @maximum_amount
end

#merchant_website_urlObject

Returns the value of attribute merchant_website_url.



5
6
7
# File 'lib/afterpay/config.rb', line 5

def merchant_website_url
  @merchant_website_url
end

#minimum_amountObject

Returns the value of attribute minimum_amount.



5
6
7
# File 'lib/afterpay/config.rb', line 5

def minimum_amount
  @minimum_amount
end

#platformObject

Returns the value of attribute platform.



5
6
7
# File 'lib/afterpay/config.rb', line 5

def platform
  @platform
end

#raise_errorsObject

Returns the value of attribute raise_errors.



5
6
7
# File 'lib/afterpay/config.rb', line 5

def raise_errors
  @raise_errors
end

#secretObject

Returns the value of attribute secret.



5
6
7
# File 'lib/afterpay/config.rb', line 5

def secret
  @secret
end

#skip_remote_configObject

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

#system_informationObject

Returns the value of attribute system_information.



5
6
7
# File 'lib/afterpay/config.rb', line 5

def system_information
  @system_information
end

#typeObject

Returns the value of attribute type.



5
6
7
# File 'lib/afterpay/config.rb', line 5

def type
  @type
end

Instance Method Details

#fetch_remote_configObject

Called only after app_id and secred is set



18
19
20
21
22
# File 'lib/afterpay/config.rb', line 18

def fetch_remote_config
  response_body = Afterpay.client.get("/v2/configuration").body
  @minimum_amount = response_body.dig(:minimumAmount, :amount).to_f
  @maximum_amount = response_body.dig(:maximumAmount, :amount).to_f
end