Class: PaymentRails::Configuration
- Inherits:
-
Object
- Object
- PaymentRails::Configuration
- Defined in:
- lib/paymentrails/Configuration.rb
Defined Under Namespace
Classes: InvalidProxyAddress
Instance Attribute Summary collapse
-
#environment ⇒ Object
readonly
Returns the value of attribute environment.
-
#privateKey ⇒ Object
Returns the value of attribute privateKey.
-
#proxy ⇒ Object
readonly
Returns the value of attribute proxy.
-
#publicKey ⇒ Object
Returns the value of attribute publicKey.
Instance Method Summary collapse
- #apiBase ⇒ Object
-
#initialize(publicKey, privateKey, environment = 'production', proxy_uri: nil) ⇒ Configuration
constructor
A new instance of Configuration.
- #useSsl? ⇒ Boolean
Constructor Details
#initialize(publicKey, privateKey, environment = 'production', proxy_uri: nil) ⇒ Configuration
Returns a new instance of Configuration.
5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/paymentrails/Configuration.rb', line 5 def initialize(publicKey, privateKey, environment = 'production', proxy_uri: nil) raise ArgumentError, 'Both key/secret must be a nonempty string' if publicKey.to_s&.empty? || privateKey.to_s&.empty? @publicKey = publicKey @privateKey = privateKey @environment = environment # failfast on a bad proxy begin @proxy = proxy_uri.nil? ? nil : URI.parse(proxy_uri) rescue URI::InvalidURIError raise InvalidProxyAddress, "Invalid proxy provided to configuration: #{proxy_uri}" end end |
Instance Attribute Details
#environment ⇒ Object (readonly)
Returns the value of attribute environment.
46 47 48 |
# File 'lib/paymentrails/Configuration.rb', line 46 def environment @environment end |
#privateKey ⇒ Object
Returns the value of attribute privateKey.
42 43 44 |
# File 'lib/paymentrails/Configuration.rb', line 42 def privateKey @privateKey end |
#proxy ⇒ Object (readonly)
Returns the value of attribute proxy.
36 37 38 |
# File 'lib/paymentrails/Configuration.rb', line 36 def proxy @proxy end |
#publicKey ⇒ Object
Returns the value of attribute publicKey.
38 39 40 |
# File 'lib/paymentrails/Configuration.rb', line 38 def publicKey @publicKey end |
Instance Method Details
#apiBase ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/paymentrails/Configuration.rb', line 19 def apiBase case environment when 'production' 'https://api.trolley.com' when 'development' 'https://api.railz.io' when 'integration' 'http://api.local.dev:3000' else 'https://api.trolley.com' end end |
#useSsl? ⇒ Boolean
32 33 34 |
# File 'lib/paymentrails/Configuration.rb', line 32 def useSsl? apiBase.start_with? 'https' end |