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.



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_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

#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

#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

#typeObject

Returns the value of attribute type.



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

def type
  @type
end

#user_agent_headerObject

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_configObject

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