Class: CakeMail::Mailing
- Inherits:
-
Object
- Object
- CakeMail::Mailing
- Defined in:
- lib/cakemail/mailing.rb
Instance Attribute Summary collapse
-
#active_emails ⇒ Object
readonly
Returns the value of attribute active_emails.
-
#campaign_id ⇒ Object
Returns the value of attribute campaign_id.
-
#clickthru_html ⇒ Object
Returns the value of attribute clickthru_html.
-
#clickthru_text ⇒ Object
Returns the value of attribute clickthru_text.
-
#created_on ⇒ Object
readonly
Returns the value of attribute created_on.
-
#encoding ⇒ Object
Returns the value of attribute encoding.
-
#html_message ⇒ Object
Returns the value of attribute html_message.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#in_queue ⇒ Object
readonly
Returns the value of attribute in_queue.
-
#list_id ⇒ Object
Returns the value of attribute list_id.
-
#name ⇒ Object
Returns the value of attribute name.
-
#next_step ⇒ Object
Returns the value of attribute next_step.
-
#opening_stats ⇒ Object
Returns the value of attribute opening_stats.
-
#out_queue ⇒ Object
readonly
Returns the value of attribute out_queue.
-
#recipients ⇒ Object
readonly
Returns the value of attribute recipients.
-
#scheduled_for ⇒ Object
readonly
Returns the value of attribute scheduled_for.
-
#scheduled_on ⇒ Object
readonly
Returns the value of attribute scheduled_on.
-
#sender_email ⇒ Object
Returns the value of attribute sender_email.
-
#sender_name ⇒ Object
Returns the value of attribute sender_name.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
-
#subject ⇒ Object
Returns the value of attribute subject.
-
#sublist_id ⇒ Object
Returns the value of attribute sublist_id.
-
#suspended ⇒ Object
readonly
Returns the value of attribute suspended.
-
#text_message ⇒ Object
Returns the value of attribute text_message.
-
#unsub_bottom_link ⇒ Object
Returns the value of attribute unsub_bottom_link.
Class Method Summary collapse
-
.create(campaign, name, encoding = nil) ⇒ Object
Creates a mailing.
-
.get_list(args) ⇒ Object
Returns the list of mailings.
Instance Method Summary collapse
-
#delete ⇒ Object
Deletes a mailing.
-
#get_email_message ⇒ Object
Returns the subject and the message of the mailing.
-
#get_html_message ⇒ Object
Retrieves the html message of a mailing.
-
#get_info(id = @id) ⇒ Object
Retrieves the setting for a mailing.
-
#get_links(status = nil) ⇒ Object
Retrieves the links of a mailing.
-
#get_links_log(start_date = nil, end_date = nil) ⇒ Object
Retrieves statistics about the links of a mailing.
-
#get_log(args) ⇒ Object
Retrieves information about the log of a mailing.
-
#get_stats(information) ⇒ Object
Retrieves statistics about a mailing.
-
#get_text_message ⇒ Object
Retrieves the text message of a mailing.
-
#initialize(campaign, id) ⇒ Mailing
constructor
A new instance of Mailing.
-
#resume ⇒ Object
Resumes the delivery of a mailing.
- #save ⇒ Object
-
#schedule(date = nil) ⇒ Object
Schedules a mailing for delivery.
-
#send_test_email(test_email, test_type) ⇒ Object
Sends the mailing as a test to an email.
-
#set_info ⇒ Object
Modifies the settings of a mailing.
-
#suspend ⇒ Object
Suspends the delivery of a mailing.
-
#unschedule ⇒ Object
Unschedules a mailing from delivery.
Constructor Details
#initialize(campaign, id) ⇒ Mailing
Returns a new instance of Mailing.
40 41 42 43 44 |
# File 'lib/cakemail/mailing.rb', line 40 def initialize(campaign, id) @campaign = campaign @id = id get_info end |
Instance Attribute Details
#active_emails ⇒ Object (readonly)
Returns the value of attribute active_emails.
36 37 38 |
# File 'lib/cakemail/mailing.rb', line 36 def active_emails @active_emails end |
#campaign_id ⇒ Object
Returns the value of attribute campaign_id.
37 38 39 |
# File 'lib/cakemail/mailing.rb', line 37 def campaign_id @campaign_id end |
#clickthru_html ⇒ Object
Returns the value of attribute clickthru_html.
37 38 39 |
# File 'lib/cakemail/mailing.rb', line 37 def clickthru_html @clickthru_html end |
#clickthru_text ⇒ Object
Returns the value of attribute clickthru_text.
37 38 39 |
# File 'lib/cakemail/mailing.rb', line 37 def clickthru_text @clickthru_text end |
#created_on ⇒ Object (readonly)
Returns the value of attribute created_on.
36 37 38 |
# File 'lib/cakemail/mailing.rb', line 36 def created_on @created_on end |
#encoding ⇒ Object
Returns the value of attribute encoding.
37 38 39 |
# File 'lib/cakemail/mailing.rb', line 37 def encoding @encoding end |
#html_message ⇒ Object
Returns the value of attribute html_message.
37 38 39 |
# File 'lib/cakemail/mailing.rb', line 37 def @html_message end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
36 37 38 |
# File 'lib/cakemail/mailing.rb', line 36 def id @id end |
#in_queue ⇒ Object (readonly)
Returns the value of attribute in_queue.
36 37 38 |
# File 'lib/cakemail/mailing.rb', line 36 def in_queue @in_queue end |
#list_id ⇒ Object
Returns the value of attribute list_id.
37 38 39 |
# File 'lib/cakemail/mailing.rb', line 37 def list_id @list_id end |
#name ⇒ Object
Returns the value of attribute name.
37 38 39 |
# File 'lib/cakemail/mailing.rb', line 37 def name @name end |
#next_step ⇒ Object
Returns the value of attribute next_step.
37 38 39 |
# File 'lib/cakemail/mailing.rb', line 37 def next_step @next_step end |
#opening_stats ⇒ Object
Returns the value of attribute opening_stats.
37 38 39 |
# File 'lib/cakemail/mailing.rb', line 37 def opening_stats @opening_stats end |
#out_queue ⇒ Object (readonly)
Returns the value of attribute out_queue.
36 37 38 |
# File 'lib/cakemail/mailing.rb', line 36 def out_queue @out_queue end |
#recipients ⇒ Object (readonly)
Returns the value of attribute recipients.
36 37 38 |
# File 'lib/cakemail/mailing.rb', line 36 def recipients @recipients end |
#scheduled_for ⇒ Object (readonly)
Returns the value of attribute scheduled_for.
36 37 38 |
# File 'lib/cakemail/mailing.rb', line 36 def scheduled_for @scheduled_for end |
#scheduled_on ⇒ Object (readonly)
Returns the value of attribute scheduled_on.
36 37 38 |
# File 'lib/cakemail/mailing.rb', line 36 def scheduled_on @scheduled_on end |
#sender_email ⇒ Object
Returns the value of attribute sender_email.
37 38 39 |
# File 'lib/cakemail/mailing.rb', line 37 def sender_email @sender_email end |
#sender_name ⇒ Object
Returns the value of attribute sender_name.
37 38 39 |
# File 'lib/cakemail/mailing.rb', line 37 def sender_name @sender_name end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
36 37 38 |
# File 'lib/cakemail/mailing.rb', line 36 def status @status end |
#subject ⇒ Object
Returns the value of attribute subject.
37 38 39 |
# File 'lib/cakemail/mailing.rb', line 37 def subject @subject end |
#sublist_id ⇒ Object
Returns the value of attribute sublist_id.
37 38 39 |
# File 'lib/cakemail/mailing.rb', line 37 def sublist_id @sublist_id end |
#suspended ⇒ Object (readonly)
Returns the value of attribute suspended.
36 37 38 |
# File 'lib/cakemail/mailing.rb', line 36 def suspended @suspended end |
#text_message ⇒ Object
Returns the value of attribute text_message.
37 38 39 |
# File 'lib/cakemail/mailing.rb', line 37 def @text_message end |
#unsub_bottom_link ⇒ Object
Returns the value of attribute unsub_bottom_link.
37 38 39 |
# File 'lib/cakemail/mailing.rb', line 37 def unsub_bottom_link @unsub_bottom_link end |
Class Method Details
.create(campaign, name, encoding = nil) ⇒ Object
Creates a mailing.
190 191 192 193 194 195 |
# File 'lib/cakemail/mailing.rb', line 190 def create(campaign, name, encoding = nil) args = { :campaign_id => campaign.id, :name => name, :user_key => campaign.user.user_key } args[:encoding] = encoding unless encoding.nil? res = campaign.user.session.request("CakeMail::API::ClassMailing", "Create", args) Mailing.new(campaign, res['id'].first) end |
.get_list(args) ⇒ Object
Returns the list of mailings.
Arguments :
-
args = { :campaign => required, :status => optional, :campaign_id => optional, :list_id => optional, :limit => optional, :offset => optional, :count => optional }
201 202 203 204 205 206 207 208 209 210 211 212 |
# File 'lib/cakemail/mailing.rb', line 201 def get_list(args) raise ArgumentError if args.nil? or args[:campaign].nil? = { :user_key => args[:campaign].user.user_key } [:status] = args[:status] unless args[:status].nil? [:campaign_id] = args[:campaign_id] unless args[:campaign_id].nil? [:list_id] = args[:list_id] unless args[:list_id].nil? [:limit] = args[:limit] unless args[:limit].nil? [:offset] = args[:offset] unless args[:offset].nil? [:count] = args[:count] unless args[:count].nil? res = args[:campaign].user.session.request("CakeMail::API::ClassMailing", "GetList", ) res['mailing'] end |
Instance Method Details
#delete ⇒ Object
Deletes a mailing.
46 47 48 49 |
# File 'lib/cakemail/mailing.rb', line 46 def delete @campaign.user.session.request("CakeMail::API::ClassMailing", "Delete", { :mailing_id => @id, :user_key => @campaign.user.user_key }) self.freeze end |
#get_email_message ⇒ Object
Returns the subject and the message of the mailing.
51 52 53 54 55 56 |
# File 'lib/cakemail/mailing.rb', line 51 def @campaign.user.session.request("CakeMail::API::ClassMailing", "GetEmailMessage", { :mailing_id => @id, :user_key => @campaign.user.user_key }) @subject = res['subject'].first @message = res['message'].first end |
#get_html_message ⇒ Object
Retrieves the html message of a mailing.
58 59 60 61 62 |
# File 'lib/cakemail/mailing.rb', line 58 def @campaign.user.session.request("CakeMail::API::ClassMailing", "GetHtmlMessage", { :mailing_id => @id, :user_key => @campaign.user.user_key }) @html_message = res['html_message'].first end |
#get_info(id = @id) ⇒ Object
Retrieves the setting for a mailing.
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/cakemail/mailing.rb', line 70 def get_info(id = @id) res = @campaign.user.session.request("CakeMail::API::ClassMailing", "GetInfo", { :mailing_id => @id, :user_key => @campaign.user.user_key }) @active_emails = res['active_emails'].first @campaign_id = res['campaign_id'].first @clickthru_html = res['clickthru_html'].first @clickthru_text = res['clickthru_text'].first @created_on = res['created_on'].first @encoding = res['encoding'].first @html_message = res['html_message'].first @id = res['id'].first @in_queue = res['in_queue'].first @list_id = res['list_id'].first @name = res['name'].first @next_step = res['next_step'].first @opening_stats = res['opening_stats'].first @out_queue = res['out_queue'].first @recipients = res['recipients'].first @scheduled_for = res['scheduled_for'].first @scheduled_on = res['scheduled_on'].first @sender_name = res['sender_name'].first @status = res['status'].first @subject = res['subject'].first @sublist_id = res['sublist_id'].first @suspended = res['suspended'].first @text_message = res['text_message'].first @unsub_bottom_link = res['unsub_bottom_link'].first end |
#get_links(status = nil) ⇒ Object
Retrieves the links of a mailing.
124 125 126 127 128 129 |
# File 'lib/cakemail/mailing.rb', line 124 def get_links(status = nil) args = { :mailing_id => @id, :user_key => @campaign.user.user_key } args[:status] = status unless status.nil? res = @campaign.user.session.request("CakeMail::API::ClassMailing", "GetLinks", args) res['link'] end |
#get_links_log(start_date = nil, end_date = nil) ⇒ Object
Retrieves statistics about the links of a mailing.
116 117 118 119 120 121 122 |
# File 'lib/cakemail/mailing.rb', line 116 def get_links_log(start_date = nil, end_date = nil) args = { :mailing_id => @id, :user_key => @campaign.user.user_key } args[:start_date] = start_date unless start_date.nil? args[:end_date] = end_date unless end_date.nil? res = @campaign.user.session.request("CakeMail::API::ClassMailing", "GetLinksLog", args) res['link'] end |
#get_log(args) ⇒ Object
Retrieves information about the log of a mailing.
Arguments :
-
args = { :action => optional, :record_id => optional, :start_date => optional, :end_date => optional, :date => optional, :extra => optional, :limit => optional, :offset => optional, :count => optional, :uniques => optional }
103 104 105 106 107 108 109 110 111 112 113 114 |
# File 'lib/cakemail/mailing.rb', line 103 def get_log(args) = { :mailing_id => @id, :user_key => @campaign.user.user_key } [:action] = args[:action] unless args[:action].nil? [:record_id] = args[:record_id] unless args[:record_id].nil? [:start_date] = args[:start_date] unless args[:start_date].nil? [:end_date] = args[:end_date] unless args[:end_date].nil? [:date] = args[:date] unless args[:date].nil? [:extra] = args[:extra] unless args[:extra].nil? [:limit] = args[:limit] unless args[:limit].nil? res = @campaign.user.session.request("CakeMail::API::ClassMailing", "GetLog", ) res['log'] end |
#get_stats(information) ⇒ Object
Retrieves statistics about a mailing.
131 132 133 134 135 |
# File 'lib/cakemail/mailing.rb', line 131 def get_stats(information) res = @campaign.user.session.request("CakeMail::API::ClassMailing", "GetStats", { :information => information, :mailing_id => @id, :user_key => @campaign.user.user_key }) res[information].first end |
#get_text_message ⇒ Object
Retrieves the text message of a mailing.
64 65 66 67 68 |
# File 'lib/cakemail/mailing.rb', line 64 def @campaign.user.session.request("CakeMail::API::ClassMailing", "GetTextMessage", { :mailing_id => @id, :user_key => @campaign.user.user_key }) @text_message = res['text_message'].first end |
#resume ⇒ Object
Resumes the delivery of a mailing.
137 138 139 140 |
# File 'lib/cakemail/mailing.rb', line 137 def resume res = @campaign.user.session.request("CakeMail::API::ClassMailing", "Resume", { :mailing_id => @id, :user_key => @campaign.user.user_key }) end |
#save ⇒ Object
142 143 144 |
# File 'lib/cakemail/mailing.rb', line 142 def save self.set_info end |
#schedule(date = nil) ⇒ Object
Schedules a mailing for delivery.
146 147 148 149 150 |
# File 'lib/cakemail/mailing.rb', line 146 def schedule(date = nil) args = { :mailing_id => @id, :user_key => @campaign.user.user_key } args[:date] = date unless date.nil? res = @campaign.user.session.request("CakeMail::API::ClassMailing", "Schedule", args) end |
#send_test_email(test_email, test_type) ⇒ Object
Sends the mailing as a test to an email.
152 153 154 155 |
# File 'lib/cakemail/mailing.rb', line 152 def send_test_email(test_email, test_type) res = @campaign.user.session.request("CakeMail::API::ClassMailing", "SendTestEmail", { :mailing_id => @id, :user_key => @campaign.user.user_key, :test_email => test_email, :test_type => test_type }) end |
#set_info ⇒ Object
Modifies the settings of a mailing.
157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 |
# File 'lib/cakemail/mailing.rb', line 157 def set_info args = { :mailing_id => @id, :user_key => @campaign.user.user_key } args[:campaign_id] = @campaign_id unless @campaign_id.nil? args[:list_id] = @list_id unless @list_id.nil? or @list_id == '0' args[:sublist_id] = @sublist_id unless @sublist_id.nil? or @sublist_id == '0' args[:next_step] = @next_step unless @next_step.nil? args[:encoding] = @encoding unless @encoding.nil? args[:clickthru_html] = @clickthru_html unless @clickthru_html.nil? args[:clickthru_text] = @clickthru_text unless @clickthru_text.nil? args[:opening_stats] = @opening_stats unless @opening_stats.nil? args[:unsub_bottom_link] = @unsub_bottom_link unless @unsub_bottom_link.nil? args[:name] = @name unless @name.nil? args[:subject] = @subject unless @subject.nil? args[:sender_name] = @sender_name unless @sender_name.nil? args[:sender_email] = @sender_email unless @sender_email.nil? args[:html_message] = @html_message unless @html_message.nil? args[:text_message] = @text_message unless @text_message.nil? args[:campaign_id] = @campaign_id unless @campaign_id.nil? res = @campaign.user.session.request("CakeMail::API::ClassMailing", "SetInfo", args) end |
#suspend ⇒ Object
Suspends the delivery of a mailing.
178 179 180 181 |
# File 'lib/cakemail/mailing.rb', line 178 def suspend res = @campaign.user.session.request("CakeMail::API::ClassMailing", "Suspend", { :mailing_id => @id, :user_key => @campaign.user.user_key }) end |
#unschedule ⇒ Object
Unschedules a mailing from delivery.
183 184 185 186 |
# File 'lib/cakemail/mailing.rb', line 183 def unschedule res = @campaign.user.session.request("CakeMail::API::ClassMailing", "Unschedule", { :mailing_id => @id, :user_key => @campaign.user.user_key }) end |