Class: Contactology::Campaigns::Transactional

Inherits:
Contactology::Campaign show all
Defined in:
lib/contactology/campaigns/transactional.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Contactology::Campaign

#destroy, find, find_by_name, #preview, #save!

Methods included from API

#query, #request_headers

Methods inherited from Stash

#[]=

Class Method Details

.create(attributes, options = {}) ⇒ Object



11
12
13
# File 'lib/contactology/campaigns/transactional.rb', line 11

def self.create(attributes, options = {})
  new(attributes).save(options)
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.



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/contactology/campaigns/transactional.rb', line 22

def save(options = {})
  self.class.query('Campaign_Create_Transactional', options.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 => process_send_campaign_result('success' => false, 'issues' => [{'text' => 'Connection error'}]),
    :on_success => Proc.new { |response| self.id = response; self }
  }))
end