Class: Mailstro::Delivery
- Inherits:
-
Object
- Object
- Mailstro::Delivery
- Defined in:
- lib/mailstro/delivery.rb
Instance Attribute Summary collapse
-
#payload ⇒ Object
readonly
Returns the value of attribute payload.
-
#recipient ⇒ Object
readonly
Returns the value of attribute recipient.
-
#template ⇒ Object
readonly
Returns the value of attribute template.
Class Method Summary collapse
Instance Method Summary collapse
- #deliver ⇒ Object
-
#initialize(template, options) ⇒ Delivery
constructor
A new instance of Delivery.
Constructor Details
#initialize(template, options) ⇒ Delivery
Returns a new instance of Delivery.
13 14 15 16 17 |
# File 'lib/mailstro/delivery.rb', line 13 def initialize(template, ) @template = template @recipient = [:recipient] @payload = [:payload] end |
Instance Attribute Details
#payload ⇒ Object (readonly)
Returns the value of attribute payload.
7 8 9 |
# File 'lib/mailstro/delivery.rb', line 7 def payload @payload end |
#recipient ⇒ Object (readonly)
Returns the value of attribute recipient.
7 8 9 |
# File 'lib/mailstro/delivery.rb', line 7 def recipient @recipient end |
#template ⇒ Object (readonly)
Returns the value of attribute template.
7 8 9 |
# File 'lib/mailstro/delivery.rb', line 7 def template @template end |
Class Method Details
.deliver(*args) ⇒ Object
9 10 11 |
# File 'lib/mailstro/delivery.rb', line 9 def self.deliver(*args) new(*args).deliver end |
Instance Method Details
#deliver ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/mailstro/delivery.rb', line 19 def deliver http = Net::HTTP.new(endpoint_uri.host, endpoint_uri.port) http.use_ssl = endpoint_uri.scheme == "https" http.verify_mode = OpenSSL::SSL::VERIFY_NONE request = Net::HTTP::Post.new(endpoint_uri.request_uri, { 'Content-Type' =>'application/json' }) request.body = JSON.generate(post_data) response = http.request(request) # response.status # response["header-here"] # All headers are lowercase JSON.parse(response.body) end |