Class: Trolley::Configuration
- Inherits:
-
Object
- Object
- Trolley::Configuration
- Defined in:
- lib/trolley/Configuration.rb
Defined Under Namespace
Classes: InvalidProxyAddress
Constant Summary collapse
- DEFAULT_API_BASE =
'https://api.trolley.com'.freeze
Instance Attribute Summary collapse
-
#api_base ⇒ Object
readonly
Returns the value of attribute api_base.
-
#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
-
#initialize(publicKey, privateKey, **optionals) ⇒ Configuration
constructor
A new instance of Configuration.
- #useSsl? ⇒ Boolean
Constructor Details
#initialize(publicKey, privateKey, **optionals) ⇒ Configuration
Returns a new instance of Configuration.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/trolley/Configuration.rb', line 8 def initialize(publicKey, privateKey, **optionals) raise ArgumentError, 'Both key/secret must be a nonempty string' if publicKey.to_s&.empty? || privateKey.to_s&.empty? @publicKey = publicKey @privateKey = privateKey @api_base = optionals[:api_base] || DEFAULT_API_BASE # failfast on a bad proxy proxy_uri = optionals[:proxy_uri] 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
#api_base ⇒ Object (readonly)
Returns the value of attribute api_base.
4 5 6 |
# File 'lib/trolley/Configuration.rb', line 4 def api_base @api_base end |
#environment ⇒ Object (readonly)
Returns the value of attribute environment.
4 5 6 |
# File 'lib/trolley/Configuration.rb', line 4 def environment @environment end |
#privateKey ⇒ Object
Returns the value of attribute privateKey.
27 28 29 |
# File 'lib/trolley/Configuration.rb', line 27 def privateKey @privateKey end |
#proxy ⇒ Object (readonly)
Returns the value of attribute proxy.
4 5 6 |
# File 'lib/trolley/Configuration.rb', line 4 def proxy @proxy end |
#publicKey ⇒ Object
Returns the value of attribute publicKey.
27 28 29 |
# File 'lib/trolley/Configuration.rb', line 27 def publicKey @publicKey end |
Instance Method Details
#useSsl? ⇒ Boolean
23 24 25 |
# File 'lib/trolley/Configuration.rb', line 23 def useSsl? api_base.start_with? 'https' end |