Class: Contactology::Campaigns::Standard

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

Instance Method Summary collapse

Methods inherited from Contactology::Campaign

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

Methods included from API

#query, #request_headers

Instance Method Details

#[]=(property, value) ⇒ Object



15
16
17
18
19
20
21
# File 'lib/contactology/campaigns/standard.rb', line 15

def []=(property, value)
  if property.to_s == 'recipients'
    super 'recipients', normalize_recipients(value)
  else
    super
  end
end

#save(options = {}) ⇒ Object



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/standard.rb', line 23

def save(options = {})
  self.class.query('Campaign_Create_Standard', options.merge({
    'recipients' => recipients,
    'campaignName' => name,
    'subject' => subject,
    'senderEmail' => sender_email,
    'senderName' => sender_name,
    'content' => content,
    'optionalParameters' => {
      'authenticate' => authenticate,
      'replyToEmail' => reply_to_email,
      'replyToName' => reply_to_name,
      'trackReplies' => track_replies,
      'recipientName' => recipient_name,
      'showInArchive' => show_in_archive,
      'viewInBrowser' => view_in_browser,
      'trackOpens' => track_opens,
      'trackClickThruHTML' => track_click_thru_html,
      'trackClickThruText' => track_click_thru_text,
      'googleAnalyticsName' => google_analytics_name,
      'clickTaleName' => click_tale_name,
      'clickTaleCustomFields' => click_tale_custom_fields,
      'automaticTweet' => automatic_tweet
    },
    :on_error => false,
    :on_timeout => false,
    :on_success => Proc.new { |response| self.id = response; self }
  }))
end

#send_campaign(options = {}) ⇒ Object

Public: Sends the campaign.

Returns an empty collection when successful. Returns a collection of issues when unsuccessful.



59
60
61
62
63
64
65
66
# File 'lib/contactology/campaigns/standard.rb', line 59

def send_campaign(options = {})
  self.class.query('Campaign_Send', options.merge({
    'campaignId' => id,
    :on_error => Proc.new { |response| process_send_campaign_result response },
    :on_timeout => process_send_campaign_result({'success' => false, 'issues' => [{'text' => 'Connection timeout'}]}),
    :on_success => Proc.new { |response| process_send_campaign_result response }
  }))
end