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!, #start_time

Methods included from API

#query, #request_headers

Instance Method Details

#[]=(property, value) ⇒ Object



41
42
43
44
45
46
47
# File 'lib/contactology/campaigns/standard.rb', line 41

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

#save(options = {}) ⇒ Object



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

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.



85
86
87
88
89
90
91
92
# File 'lib/contactology/campaigns/standard.rb', line 85

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' => {'issues' => [{'text' => 'Connection timeout'}]}}),
    :on_success => Proc.new { |response| process_send_campaign_result response }
  }))
end