Class: PostageApp::Configuration
- Inherits:
-
Object
- Object
- PostageApp::Configuration
- Defined in:
- lib/postageapp/configuration.rb
Instance Attribute Summary collapse
-
#environment ⇒ Object
Environment gem is running in.
-
#framework ⇒ Object
The framework PostageApp gem runs in.
-
#host ⇒ Object
The host to connect to (default: ‘api.postageapp.com’).
-
#http_open_timeout ⇒ Object
The HTTP open timeout in seconds (defaults to 2).
-
#http_read_timeout ⇒ Object
The HTTP read timeout in seconds (defaults to 5).
-
#logger ⇒ Object
The logger used by this gem.
-
#port ⇒ Object
Returns the port used to make API calls.
-
#project_root ⇒ Object
The file path of the project.
-
#protocol ⇒ Object
Returns the HTTP protocol used to make API calls.
-
#proxy_host ⇒ Object
The hostname of the proxy server (if using a proxy).
-
#proxy_pass ⇒ Object
The password for the proxy server (if using proxy).
-
#proxy_port ⇒ Object
The port of the proxy server (if using proxy).
-
#proxy_user ⇒ Object
The username for the proxy server (if using proxy).
-
#recipient_override ⇒ Object
The email address that all send_message method should address all messages while overriding original addresses.
-
#requests_to_resend ⇒ Object
A list of API method names payloads of which are captured and resent in case of service unavailability.
-
#secure ⇒ Object
(also: #secure?)
truefor https,falsefor http connections (default: istrue).
Instance Method Summary collapse
-
#api_key ⇒ Object
Returns the API key used to make API calls.
-
#api_key=(key) ⇒ Object
Assign which API key is used to make API calls.
-
#http ⇒ Object
Returns a properly config.
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
-
#url ⇒ Object
Returns the endpoint URL to make API calls.
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
55 56 57 58 59 60 61 62 63 |
# File 'lib/postageapp/configuration.rb', line 55 def initialize @secure = true @host = 'api.postageapp.com' @http_open_timeout = 5 @http_read_timeout = 10 @requests_to_resend = %w( send_message ) @framework = 'undefined framework' @environment = 'production' end |
Instance Attribute Details
#environment ⇒ Object
Environment gem is running in
50 51 52 |
# File 'lib/postageapp/configuration.rb', line 50 def environment @environment end |
#framework ⇒ Object
The framework PostageApp gem runs in
47 48 49 |
# File 'lib/postageapp/configuration.rb', line 47 def framework @framework end |
#host ⇒ Object
The host to connect to (default: ‘api.postageapp.com’)
10 11 12 |
# File 'lib/postageapp/configuration.rb', line 10 def host @host end |
#http_open_timeout ⇒ Object
The HTTP open timeout in seconds (defaults to 2).
29 30 31 |
# File 'lib/postageapp/configuration.rb', line 29 def http_open_timeout @http_open_timeout end |
#http_read_timeout ⇒ Object
The HTTP read timeout in seconds (defaults to 5).
32 33 34 |
# File 'lib/postageapp/configuration.rb', line 32 def http_read_timeout @http_read_timeout end |
#logger ⇒ Object
The logger used by this gem
53 54 55 |
# File 'lib/postageapp/configuration.rb', line 53 def logger @logger end |
#port ⇒ Object
Returns the port used to make API calls
85 86 87 |
# File 'lib/postageapp/configuration.rb', line 85 def port @port ||= (secure? ? 443 : 80) end |
#project_root ⇒ Object
The file path of the project. This is where logs and failed requests can be stored
44 45 46 |
# File 'lib/postageapp/configuration.rb', line 44 def project_root @project_root end |
#protocol ⇒ Object
Returns the HTTP protocol used to make API calls
7 8 9 |
# File 'lib/postageapp/configuration.rb', line 7 def protocol @protocol end |
#proxy_host ⇒ Object
The hostname of the proxy server (if using a proxy)
17 18 19 |
# File 'lib/postageapp/configuration.rb', line 17 def proxy_host @proxy_host end |
#proxy_pass ⇒ Object
The password for the proxy server (if using proxy)
26 27 28 |
# File 'lib/postageapp/configuration.rb', line 26 def proxy_pass @proxy_pass end |
#proxy_port ⇒ Object
The port of the proxy server (if using proxy)
20 21 22 |
# File 'lib/postageapp/configuration.rb', line 20 def proxy_port @proxy_port end |
#proxy_user ⇒ Object
The username for the proxy server (if using proxy)
23 24 25 |
# File 'lib/postageapp/configuration.rb', line 23 def proxy_user @proxy_user end |
#recipient_override ⇒ Object
The email address that all send_message method should address all messages while overriding original addresses
36 37 38 |
# File 'lib/postageapp/configuration.rb', line 36 def recipient_override @recipient_override end |
#requests_to_resend ⇒ Object
A list of API method names payloads of which are captured and resent in case of service unavailability
40 41 42 |
# File 'lib/postageapp/configuration.rb', line 40 def requests_to_resend @requests_to_resend end |
#secure ⇒ Object Also known as: secure?
true for https, false for http connections (default: is true)
3 4 5 |
# File 'lib/postageapp/configuration.rb', line 3 def secure @secure end |
Instance Method Details
#api_key ⇒ Object
Returns the API key used to make API calls. Can be specified as the ‘POSTAGEAPP_API_KEY` environment variable.
75 76 77 |
# File 'lib/postageapp/configuration.rb', line 75 def api_key @api_key ||= ENV['POSTAGEAPP_API_KEY'] end |
#api_key=(key) ⇒ Object
Assign which API key is used to make API calls. Can also be specified using the ‘POSTAGEAPP_API_KEY` environment variable.
69 70 71 |
# File 'lib/postageapp/configuration.rb', line 69 def api_key=(key) @api_key = key end |
#http ⇒ Object
Returns a properly config
95 96 97 98 99 100 101 102 103 104 105 106 107 108 |
# File 'lib/postageapp/configuration.rb', line 95 def http http = Net::HTTP::Proxy( self.proxy_host, self.proxy_port, self.proxy_user, self.proxy_pass ).new(self.host, self.port) http.read_timeout = self.http_read_timeout http.open_timeout = self.http_open_timeout http.use_ssl = self.secure? http end |
#url ⇒ Object
Returns the endpoint URL to make API calls
90 91 92 |
# File 'lib/postageapp/configuration.rb', line 90 def url "#{self.protocol}://#{self.host}:#{self.port}" end |