Class: Postmark::HttpClient
- Inherits:
-
Object
- Object
- Postmark::HttpClient
- Defined in:
- lib/postmark/http_client.rb
Constant Summary collapse
- DEFAULTS =
{ :auth_header_name => 'X-Postmark-Server-Token', :host => 'api.postmarkapp.com', :secure => true, :path_prefix => '/', :http_read_timeout => 60, :http_open_timeout => 60 }
Instance Attribute Summary collapse
-
#api_token ⇒ Object
(also: #api_key)
Returns the value of attribute api_token.
-
#auth_header_name ⇒ Object
readonly
Returns the value of attribute auth_header_name.
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#http ⇒ Object
readonly
Returns the value of attribute http.
-
#http_open_timeout ⇒ Object
readonly
Returns the value of attribute http_open_timeout.
-
#http_read_timeout ⇒ Object
readonly
Returns the value of attribute http_read_timeout.
-
#http_ssl_version ⇒ Object
readonly
Returns the value of attribute http_ssl_version.
-
#path_prefix ⇒ Object
readonly
Returns the value of attribute path_prefix.
-
#port ⇒ Object
readonly
Returns the value of attribute port.
-
#proxy_host ⇒ Object
readonly
Returns the value of attribute proxy_host.
-
#proxy_pass ⇒ Object
readonly
Returns the value of attribute proxy_pass.
-
#proxy_port ⇒ Object
readonly
Returns the value of attribute proxy_port.
-
#proxy_user ⇒ Object
readonly
Returns the value of attribute proxy_user.
-
#secure ⇒ Object
readonly
Returns the value of attribute secure.
Instance Method Summary collapse
- #delete(path, query = {}) ⇒ Object
- #get(path, query = {}) ⇒ Object
-
#initialize(api_token, options = {}) ⇒ HttpClient
constructor
A new instance of HttpClient.
- #patch(path, data = '') ⇒ Object
- #post(path, data = '') ⇒ Object
- #protocol ⇒ Object
- #put(path, data = '') ⇒ Object
Constructor Details
#initialize(api_token, options = {}) ⇒ HttpClient
Returns a new instance of HttpClient.
24 25 26 27 28 29 |
# File 'lib/postmark/http_client.rb', line 24 def initialize(api_token, = {}) @api_token = api_token @request_mutex = Mutex.new () @http = build_http end |
Instance Attribute Details
#api_token ⇒ Object Also known as: api_key
Returns the value of attribute api_token.
6 7 8 |
# File 'lib/postmark/http_client.rb', line 6 def api_token @api_token end |
#auth_header_name ⇒ Object (readonly)
Returns the value of attribute auth_header_name.
7 8 9 |
# File 'lib/postmark/http_client.rb', line 7 def auth_header_name @auth_header_name end |
#host ⇒ Object (readonly)
Returns the value of attribute host.
7 8 9 |
# File 'lib/postmark/http_client.rb', line 7 def host @host end |
#http ⇒ Object (readonly)
Returns the value of attribute http.
7 8 9 |
# File 'lib/postmark/http_client.rb', line 7 def http @http end |
#http_open_timeout ⇒ Object (readonly)
Returns the value of attribute http_open_timeout.
7 8 9 |
# File 'lib/postmark/http_client.rb', line 7 def http_open_timeout @http_open_timeout end |
#http_read_timeout ⇒ Object (readonly)
Returns the value of attribute http_read_timeout.
7 8 9 |
# File 'lib/postmark/http_client.rb', line 7 def http_read_timeout @http_read_timeout end |
#http_ssl_version ⇒ Object (readonly)
Returns the value of attribute http_ssl_version.
7 8 9 |
# File 'lib/postmark/http_client.rb', line 7 def http_ssl_version @http_ssl_version end |
#path_prefix ⇒ Object (readonly)
Returns the value of attribute path_prefix.
7 8 9 |
# File 'lib/postmark/http_client.rb', line 7 def path_prefix @path_prefix end |
#port ⇒ Object (readonly)
Returns the value of attribute port.
7 8 9 |
# File 'lib/postmark/http_client.rb', line 7 def port @port end |
#proxy_host ⇒ Object (readonly)
Returns the value of attribute proxy_host.
7 8 9 |
# File 'lib/postmark/http_client.rb', line 7 def proxy_host @proxy_host end |
#proxy_pass ⇒ Object (readonly)
Returns the value of attribute proxy_pass.
7 8 9 |
# File 'lib/postmark/http_client.rb', line 7 def proxy_pass @proxy_pass end |
#proxy_port ⇒ Object (readonly)
Returns the value of attribute proxy_port.
7 8 9 |
# File 'lib/postmark/http_client.rb', line 7 def proxy_port @proxy_port end |
#proxy_user ⇒ Object (readonly)
Returns the value of attribute proxy_user.
7 8 9 |
# File 'lib/postmark/http_client.rb', line 7 def proxy_user @proxy_user end |
#secure ⇒ Object (readonly)
Returns the value of attribute secure.
7 8 9 |
# File 'lib/postmark/http_client.rb', line 7 def secure @secure end |
Instance Method Details
#delete(path, query = {}) ⇒ Object
47 48 49 |
# File 'lib/postmark/http_client.rb', line 47 def delete(path, query = {}) do_request { |client| client.delete(url_path(path + to_query_string(query)), headers) } end |
#get(path, query = {}) ⇒ Object
43 44 45 |
# File 'lib/postmark/http_client.rb', line 43 def get(path, query = {}) do_request { |client| client.get(url_path(path + to_query_string(query)), headers) } end |
#patch(path, data = '') ⇒ Object
39 40 41 |
# File 'lib/postmark/http_client.rb', line 39 def patch(path, data = '') do_request { |client| client.patch(url_path(path), data, headers) } end |
#post(path, data = '') ⇒ Object
31 32 33 |
# File 'lib/postmark/http_client.rb', line 31 def post(path, data = '') do_request { |client| client.post(url_path(path), data, headers) } end |
#protocol ⇒ Object
51 52 53 |
# File 'lib/postmark/http_client.rb', line 51 def protocol self.secure ? 'https' : 'http' end |
#put(path, data = '') ⇒ Object
35 36 37 |
# File 'lib/postmark/http_client.rb', line 35 def put(path, data = '') do_request { |client| client.put(url_path(path), data, headers) } end |