Class: Emarsys::Email
- Inherits:
-
DataObject
- Object
- DataObject
- Emarsys::Email
- Defined in:
- lib/emarsys/data_objects/email.rb
Overview
Methods for the Email API
Class Method Summary collapse
-
.collection(account: nil, **params) ⇒ Hash
List email campaigns.
-
.create(account: nil, **params) ⇒ Hash
Create a new email campaign.
-
.delivery_status(id, account: nil, **params) ⇒ Hash
Returns the delivery status of an email.
- .email_launches(id, account: nil) ⇒ Object
-
.export_responses(distribution_method:, time_range:, contact_fields:, sources:, analysis_fields:, account: nil, **params) ⇒ Hash
Exports the selected fields of all contacts who responded to emails within the specified time range.
-
.launch(id, account: nil, **params) ⇒ Hash
Launches an email.
-
.preview(id, version: 'html', account: nil) ⇒ Hash
Preview an email.
-
.resource(id, account: nil) ⇒ Hash
Get Email attirbutes of a specific email.
- .response_summary(id, launch_id: nil, start_date: nil, end_date: nil, account: nil) ⇒ Object
- .responses(type:, start_date: nil, end_date: nil, campaign_id: nil, account: nil) ⇒ Object
- .responses_result(query_id, account: nil) ⇒ Object
-
.send_test_mail(id, account: nil, **params) ⇒ Hash
Instruct emarsys to send a test mail.
-
.unsubscribe(account: nil, **params) ⇒ Hash
Tracking email campaign unsubscribes.
Methods inherited from DataObject
delete, get, parameterize_params, post, put, #request
Class Method Details
.collection(account: nil, **params) ⇒ Hash
List email campaigns
20 21 22 |
# File 'lib/emarsys/data_objects/email.rb', line 20 def collection(account: nil, **params) get account, 'email', params end |
.create(account: nil, **params) ⇒ Hash
Create a new email campaign
56 57 58 |
# File 'lib/emarsys/data_objects/email.rb', line 56 def create(account: nil, **params) post account, "email", params end |
.delivery_status(id, account: nil, **params) ⇒ Hash
Returns the delivery status of an email
128 129 130 |
# File 'lib/emarsys/data_objects/email.rb', line 128 def delivery_status(id, account: nil, **params) post account, "email/#{id}/getdeliverystatus", params end |
.email_launches(id, account: nil) ⇒ Object
146 147 148 |
# File 'lib/emarsys/data_objects/email.rb', line 146 def email_launches(id, account: nil) post account, "email/getlaunchesofemail", emailId: id end |
.export_responses(distribution_method:, time_range:, contact_fields:, sources:, analysis_fields:, account: nil, **params) ⇒ Hash
Exports the selected fields of all contacts who responded to emails within the specified time range.
168 169 170 171 172 173 174 175 176 177 |
# File 'lib/emarsys/data_objects/email.rb', line 168 def export_responses(distribution_method:, time_range:, contact_fields:, sources:, analysis_fields:, account: nil, **params) params.merge!( :distribution_method => distribution_method, :time_range => time_range, :contact_fields => Emarsys::ParamsConverter.new(contact_fields).convert_to_ids, :sources => sources, :analysis_fields => analysis_fields ) post account, "email/getresponses", params end |
.launch(id, account: nil, **params) ⇒ Hash
Launches an email
69 70 71 |
# File 'lib/emarsys/data_objects/email.rb', line 69 def launch(id, account: nil, **params) post account, "email/#{id}/launch", params end |
.preview(id, version: 'html', account: nil) ⇒ Hash
Preview an email
80 81 82 |
# File 'lib/emarsys/data_objects/email.rb', line 80 def preview(id, version: 'html', account: nil) post account, "email/#{id}/preview", {:version => version} end |
.resource(id, account: nil) ⇒ Hash
Get Email attirbutes of a specific email
30 31 32 |
# File 'lib/emarsys/data_objects/email.rb', line 30 def resource(id, account: nil) get account, "email/#{id}", {} end |
.response_summary(id, launch_id: nil, start_date: nil, end_date: nil, account: nil) ⇒ Object
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/emarsys/data_objects/email.rb', line 85 def response_summary(id, launch_id: nil, start_date: nil, end_date: nil, account: nil) params = {} if !launch_id.nil? params.merge!(launch_id: launch_id) end if !start_date.nil? params.merge!(start_date: start_date) end if !end_date.nil? params.merge!(end_date: end_date) end get account, "email/#{id}/responsesummary", params end |
.responses(type:, start_date: nil, end_date: nil, campaign_id: nil, account: nil) ⇒ Object
180 181 182 183 184 185 186 187 188 189 190 |
# File 'lib/emarsys/data_objects/email.rb', line 180 def responses(type:, start_date: nil, end_date: nil, campaign_id: nil, account: nil) params = { type: type } if !campaign_id.nil? params.merge!(campaign_id: campaign_id) elsif !start_date.nil? && !end_date.nil? params.merge!(start_date: start_date, end_date: end_date) else raise "Either campaign_id OR start_date/end_date must be provided" end post account, "email/responses", params end |
.responses_result(query_id, account: nil) ⇒ Object
193 194 195 |
# File 'lib/emarsys/data_objects/email.rb', line 193 def responses_result(query_id, account: nil) get account, "email/#{query_id}/responses", {} end |
.send_test_mail(id, account: nil, **params) ⇒ Hash
Instruct emarsys to send a test mail
Only one of the three parameters must be sent.
115 116 117 |
# File 'lib/emarsys/data_objects/email.rb', line 115 def send_test_mail(id, account: nil, **params) post account, "email/#{id}/sendtestmail", params end |
.unsubscribe(account: nil, **params) ⇒ Hash
Tracking email campaign unsubscribes
141 142 143 |
# File 'lib/emarsys/data_objects/email.rb', line 141 def unsubscribe(account: nil, **params) post account, "email/unsubscribe", params end |