Class: VerticalResponse::API::Email
- Defined in:
- lib/email.rb
Constant Summary collapse
- MESSAGE_TYPE =
'email'
Instance Attribute Summary
Attributes inherited from Client
Class Method Summary collapse
-
.all(options = {}) ⇒ Object
The Email API does not support the ‘all’ method on its own for now.
-
.base_uri(*args) ⇒ Object
Base URI for the Email resource.
-
.resource_name ⇒ Object
Overwrite from parent class since it’s a special type of resource name (with messages at the beginning).
Instance Method Summary collapse
- #clicks_stats(options = {}) ⇒ Object
-
#initialize(*args) ⇒ Email
constructor
A new instance of Email.
-
#launch(params = {}) ⇒ Object
Launches an email and return the response object.
-
#lists(options = {}) ⇒ Object
Returns all the lists this email is targeted to.
- #opens_stats(options = {}) ⇒ Object
- #test_launch(params = {}) ⇒ Object
- #unschedule(params = {}) ⇒ Object
- #unsubscribes_stats(options = {}) ⇒ Object
Methods inherited from Resource
class_for_resource, class_name, create, #delete, exclude_methods, find, #id, id_attribute_name, id_regexp, object_collection, resource_id_from_url, #stats, #update, #url, validate_supported_method!
Methods inherited from Client
add_default_query_param, assign_headers, build_params, build_query_params, config, default_query_params, embed_resource, resource_uri
Constructor Details
#initialize(*args) ⇒ Email
36 37 38 39 |
# File 'lib/email.rb', line 36 def initialize(*args) super @list_class = self.class.class_for_resource(List, id) end |
Class Method Details
.all(options = {}) ⇒ Object
The Email API does not support the ‘all’ method on its own for now. To get all emails we need to do it through the Message API
29 30 31 |
# File 'lib/email.rb', line 29 def all( = {}) Message.all(.merge({ :message_type => MESSAGE_TYPE })) end |
.base_uri(*args) ⇒ Object
Base URI for the Email resource
17 18 19 |
# File 'lib/email.rb', line 17 def base_uri(*args) @base_uri ||= File.join(super.to_s, 'messages', 'emails') end |
.resource_name ⇒ Object
Overwrite from parent class since it’s a special type of resource name (with messages at the beginning)
23 24 25 |
# File 'lib/email.rb', line 23 def resource_name 'messages/emails' end |
Instance Method Details
#clicks_stats(options = {}) ⇒ Object
83 84 85 |
# File 'lib/email.rb', line 83 def clicks_stats( = {}) detailed_stat(:clicks) end |
#launch(params = {}) ⇒ Object
Launches an email and return the response object
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/email.rb', line 54 def launch(params = {}) # Supports receiving an array of List objects (Object Oriented) lists = params.delete(:lists) if lists params[:list_ids] ||= [] params[:list_ids] += lists.map do |list| list.respond_to?(:id) ? list.id : list.to_i end # Remove duplicate IDs, if any params[:list_ids].uniq! end Response.new self.class.post( self.class.resource_uri(id), self.class.build_params(params) ) end |
#lists(options = {}) ⇒ Object
Returns all the lists this email is targeted to
42 43 44 |
# File 'lib/email.rb', line 42 def lists( = {}) @list_class.all() end |
#opens_stats(options = {}) ⇒ Object
79 80 81 |
# File 'lib/email.rb', line 79 def opens_stats( = {}) detailed_stat(:opens) end |
#test_launch(params = {}) ⇒ Object
46 47 48 49 50 51 |
# File 'lib/email.rb', line 46 def test_launch(params = {}) Response.new self.class.post( self.class.resource_uri(id, 'test'), self.class.build_params(params) ) end |
#unschedule(params = {}) ⇒ Object
72 73 74 75 76 77 |
# File 'lib/email.rb', line 72 def unschedule(params = {}) Response.new self.class.post( self.class.resource_uri(id, 'unschedule'), self.class.build_params(params) ) end |
#unsubscribes_stats(options = {}) ⇒ Object
87 88 89 |
# File 'lib/email.rb', line 87 def unsubscribes_stats( = {}) detailed_stat(:unsubscribes) end |