Class: MailchimpAPI::Campaign

Inherits:
Base
  • Object
show all
Extended by:
Support::Countable
Includes:
Support::PatchUpdate
Defined in:
lib/mailchimp_api/resources/campaign.rb

Instance Method Summary collapse

Methods included from Support::Countable

count

Methods inherited from Base

activate_session, exists?, headers, reset_session, #to_h

Instance Method Details

#schedule(time, use_timewarp = false, batch_delivery = false) ⇒ Object



32
33
34
35
# File 'lib/mailchimp_api/resources/campaign.rb', line 32

def schedule(time, use_timewarp = false, batch_delivery = false)
  path = element_path(prefix_options) + '/actions/schedule'
  connection.post path, { schedule_time: time.iso8601, timewarp: use_timewarp, batch_delivery: batch_delivery }.to_json, self.class.headers
end

#send_campaignObject

Calls the ‘/send’ endpoint, but we obviously can’t override the Ruby ‘send’ method.



27
28
29
30
# File 'lib/mailchimp_api/resources/campaign.rb', line 27

def send_campaign
  path = element_path(prefix_options) + '/actions/send'
  connection.post path, nil, self.class.headers
end

#test(emails = [], type = 'html') ⇒ Object

type: String. ‘html’ or ‘plaintext’



38
39
40
41
42
43
# File 'lib/mailchimp_api/resources/campaign.rb', line 38

def test(emails = [], type = 'html')
  return unless emails.present?

  path = element_path(prefix_options) + '/actions/test'
  connection.post path, { test_emails: emails, send_type: type }.to_json, self.class.headers
end