Class: Contactology::Campaigns::Transactional
- Inherits:
-
Contactology::Campaign
- Object
- Hashie::Trash
- Stash
- Contactology::Campaign
- Contactology::Campaigns::Transactional
- Defined in:
- lib/contactology/campaigns/transactional.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#save(options = {}) ⇒ Object
Public: Stores the campaign information onto Contactology.
-
#send_campaign(*contacts) ⇒ Object
Public: Sends the campaign.
Methods inherited from Contactology::Campaign
#destroy, find, find_by_name, #preview, #save!, #start_time
Methods included from API
Methods inherited from Stash
Class Method Details
.create(attributes, options = {}) ⇒ Object
37 38 39 |
# File 'lib/contactology/campaigns/transactional.rb', line 37 def self.create(attributes, = {}) new(attributes).save() end |
Instance Method Details
#save(options = {}) ⇒ Object
Public: Stores the campaign information onto Contactology.
Returns a Transactional instance with the campaign ID when successful. Returns a Contactology::SendResult instance with issues on failure.
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/contactology/campaigns/transactional.rb', line 48 def save( = {}) self.class.query('Campaign_Create_Transactional', .merge({ 'campaignName' => name, 'content' => content, 'senderEmail' => sender_email, 'senderName' => sender_name, 'subject' => subject, 'testContact' => test_contact, 'testReplacements' => test_replacements, 'optionalParameters' => { 'authenticate' => authenticate, 'automaticTweet' => automatic_tweet, 'clickTaleCustomFields' => click_tale_custom_fields, 'clickTaleName' => click_tale_name, 'googleAnalyticsName' => google_analytics_name, 'recipientName' => recipient_name, 'replyToEmail' => reply_to_email, 'replyToName' => reply_to_name, 'showInArchive' => show_in_archive, 'trackClickThruHTML' => track_click_thru_html, 'trackClickThruText' => track_click_thru_text, 'trackOpens' => track_opens, 'trackReplies' => track_replies, 'viewInBrowser' => view_in_browser }, :on_error => Proc.new { |response| process_send_campaign_result response }, :on_timeout => Proc.new { process_send_campaign_result('success' => false, 'issues' => {'issues' => [{'text' => 'Connection error'}]}) }, :on_success => Proc.new { |response| self.id = response; self } })) end |
#send_campaign(*contacts) ⇒ Object
Public: Sends the campaign.
Returns an empty collection when successful. Returns a collection of issues when unsuccessful.
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
# File 'lib/contactology/campaigns/transactional.rb', line 86 def send_campaign(*contacts) = contacts. replacements = [.delete(:replacements)].flatten.compact self.class.query('Campaign_Send_Transactional_Multiple', .merge({ 'campaignId' => id, 'contacts' => contacts.collect { |c| {'email' => c.email} }, 'source' => [:source] || 'Customer', 'replacements' => replacements, 'optionalParameters' => { 'continueOnError' => true }, :on_error => Proc.new { |response| process_send_campaign_result response }, :on_timeout => Proc.new { process_send_campaign_result('success' => false, 'issues' => {'issues' => [{'text' => 'Connection error'}]}) }, :on_success => Proc.new { process_send_campaign_result({'success' => true}) } })) end |