Class: SmtpLw::Client
- Inherits:
-
Object
- Object
- SmtpLw::Client
- Includes:
- Messages
- Defined in:
- lib/smtp_lw/client.rb,
lib/smtp_lw/client/messages.rb
Defined Under Namespace
Modules: Messages
Instance Attribute Summary collapse
-
#api_endpoint ⇒ Object
Returns the value of attribute api_endpoint.
-
#api_token ⇒ Object
Returns the value of attribute api_token.
-
#per_page ⇒ Object
Returns the value of attribute per_page.
-
#timeout ⇒ Object
Returns the value of attribute timeout.
Instance Method Summary collapse
-
#get(uri, options = {}) ⇒ Faraday::Response
Make a HTTP GET request.
-
#initialize(options = {}) ⇒ Client
constructor
A new instance of Client.
- #next_page(raw) ⇒ Object
-
#post(uri, options = {}) ⇒ Faraday::Response
Make a HTTP POST request.
-
#put(uri, options = {}) ⇒ Faraday::Response
Make a HTTP PUT request.
Methods included from Messages
#get_message, #list_messages, #send_message
Constructor Details
#initialize(options = {}) ⇒ Client
Returns a new instance of Client.
10 11 12 13 14 15 16 |
# File 'lib/smtp_lw/client.rb', line 10 def initialize( = {}) SmtpLw::Configurable.keys.each do |key| instance_variable_set( :"@#{key}", [key] || SmtpLw.instance_variable_get(:"@#{key}") ) end end |
Instance Attribute Details
#api_endpoint ⇒ Object
Returns the value of attribute api_endpoint.
7 8 9 |
# File 'lib/smtp_lw/client.rb', line 7 def api_endpoint @api_endpoint end |
#api_token ⇒ Object
Returns the value of attribute api_token.
7 8 9 |
# File 'lib/smtp_lw/client.rb', line 7 def api_token @api_token end |
#per_page ⇒ Object
Returns the value of attribute per_page.
7 8 9 |
# File 'lib/smtp_lw/client.rb', line 7 def per_page @per_page end |
#timeout ⇒ Object
Returns the value of attribute timeout.
7 8 9 |
# File 'lib/smtp_lw/client.rb', line 7 def timeout @timeout end |
Instance Method Details
#get(uri, options = {}) ⇒ Faraday::Response
Make a HTTP GET request
23 24 25 |
# File 'lib/smtp_lw/client.rb', line 23 def get(uri, = {}) connection.get(uri, ) end |
#next_page(raw) ⇒ Object
45 46 47 48 49 50 |
# File 'lib/smtp_lw/client.rb', line 45 def next_page(raw) next_uri = raw['links']['next'] return nil unless next_uri response = connection.get(next_uri) response.body end |
#post(uri, options = {}) ⇒ Faraday::Response
Make a HTTP POST request
32 33 34 |
# File 'lib/smtp_lw/client.rb', line 32 def post(uri, = {}) connection.post(uri, ) end |
#put(uri, options = {}) ⇒ Faraday::Response
Make a HTTP PUT request
41 42 43 |
# File 'lib/smtp_lw/client.rb', line 41 def put(uri, = {}) connection.put(uri, ) end |