Class: Iterable::Config
- Inherits:
-
Object
- Object
- Iterable::Config
- Defined in:
- lib/iterable/config.rb
Overview
Config provides a class to configre the API calls when interacting with REST endpoints
Constant Summary collapse
- DEFAULT_VERSION =
'1.8'.freeze
- DEFAULT_HOST =
'https://api.iterable.com'.freeze
- DEFAULT_URI =
"#{DEFAULT_HOST}/api".freeze
- DEFAULT_PORT =
443
Instance Attribute Summary collapse
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#port ⇒ Object
readonly
Returns the value of attribute port.
-
#token ⇒ Object
Returns the value of attribute token.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Instance Method Summary collapse
-
#initialize(token: nil) ⇒ Iterable::Config
constructor
initialize a new [Iterable::Config] object for requests.
-
#uri ⇒ URI
Creates a [URI] for the API host.
Constructor Details
#initialize(token: nil) ⇒ Iterable::Config
initialize a new [Iterable::Config] object for requests
23 24 25 26 27 28 |
# File 'lib/iterable/config.rb', line 23 def initialize(token: nil) @host = DEFAULT_HOST @port = DEFAULT_PORT @version = DEFAULT_VERSION @token = token end |
Instance Attribute Details
#host ⇒ Object (readonly)
Returns the value of attribute host.
15 16 17 |
# File 'lib/iterable/config.rb', line 15 def host @host end |
#port ⇒ Object (readonly)
Returns the value of attribute port.
15 16 17 |
# File 'lib/iterable/config.rb', line 15 def port @port end |
#token ⇒ Object
Returns the value of attribute token.
14 15 16 |
# File 'lib/iterable/config.rb', line 14 def token @token end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
15 16 17 |
# File 'lib/iterable/config.rb', line 15 def version @version end |
Instance Method Details
#uri ⇒ URI
Creates a [URI] for the API host
35 36 37 |
# File 'lib/iterable/config.rb', line 35 def uri URI.parse("#{@host || DEFAULT_HOST}:#{@port || DEFAULT_PORT}/api") end |