Class: Mailchimp::Campaigns
- Inherits:
-
Object
- Object
- Mailchimp::Campaigns
- Defined in:
- lib/mailchimp/api.rb
Instance Attribute Summary collapse
-
#master ⇒ Object
Returns the value of attribute master.
Instance Method Summary collapse
-
#content(cid, options = []) ⇒ Hash
Get the content (both html and text) for a campaign either as it would appear in the campaign archive or as the raw, original content.
-
#create(type, options, content, segment_opts = nil, type_opts = nil) ⇒ Hash
Create a new draft campaign to send.
-
#delete(cid) ⇒ Hash
Delete a campaign.
-
#initialize(master) ⇒ Campaigns
constructor
A new instance of Campaigns.
-
#list(filters = [], start = 0, limit = 25, sort_field = 'create_time', sort_dir = 'DESC') ⇒ Hash
Get the list of campaigns and their details matching the specified filters.
-
#pause(cid) ⇒ Hash
Pause an AutoResponder or RSS campaign from sending.
-
#ready(cid) ⇒ Hash
Returns information on whether a campaign is ready to send and possible issues we may have detected with it - very similar to the confirmation step in the app.
-
#replicate(cid) ⇒ Hash
Replicate a campaign.
-
#resume(cid) ⇒ Hash
Resume sending an AutoResponder or RSS campaign.
-
#schedule(cid, schedule_time, schedule_time_b = nil) ⇒ Hash
Schedule a campaign to be sent in the future.
-
#schedule_batch(cid, schedule_time, num_batches = 2, stagger_mins = 5) ⇒ Hash
Schedule a campaign to be sent in batches sometime in the future.
-
#segment_test(list_id, options) ⇒ Hash
Allows one to test their segmentation rules before creating a campaign using them.
-
#send(cid) ⇒ Hash
Send a given campaign immediately.
-
#send_test(cid, test_emails = [], send_type = 'html') ⇒ Hash
Send a test of this campaign to the provided email addresses.
-
#template_content(cid) ⇒ Hash
Get the HTML template content sections for a campaign.
-
#unschedule(cid) ⇒ Hash
Unschedule a campaign that is scheduled to be sent in the future.
-
#update(cid, name, value) ⇒ Hash
Update just about any setting besides type for a campaign that has not been sent.
Constructor Details
#initialize(master) ⇒ Campaigns
Returns a new instance of Campaigns.
1271 1272 1273 |
# File 'lib/mailchimp/api.rb', line 1271 def initialize(master) @master = master end |
Instance Attribute Details
#master ⇒ Object
Returns the value of attribute master.
1269 1270 1271 |
# File 'lib/mailchimp/api.rb', line 1269 def master @master end |
Instance Method Details
#content(cid, options = []) ⇒ Hash
Get the content (both html and text) for a campaign either as it would appear in the campaign archive or as the raw, original content
1286 1287 1288 1289 |
# File 'lib/mailchimp/api.rb', line 1286 def content(cid, =[]) _params = {:cid => cid, :options => } return @master.call 'campaigns/content', _params end |
#create(type, options, content, segment_opts = nil, type_opts = nil) ⇒ Hash
Create a new draft campaign to send. You <strong>can not</strong> have more than 32,000 campaigns in your account.
1384 1385 1386 1387 |
# File 'lib/mailchimp/api.rb', line 1384 def create(type, , content, segment_opts=nil, type_opts=nil) _params = {:type => type, :options => , :content => content, :segment_opts => segment_opts, :type_opts => type_opts} return @master.call 'campaigns/create', _params end |
#delete(cid) ⇒ Hash
Delete a campaign. Seriously, “poof, gone!” - be careful! Seriously, no one can undelete these.
1393 1394 1395 1396 |
# File 'lib/mailchimp/api.rb', line 1393 def delete(cid) _params = {:cid => cid} return @master.call 'campaigns/delete', _params end |
#list(filters = [], start = 0, limit = 25, sort_field = 'create_time', sort_dir = 'DESC') ⇒ Hash
Get the list of campaigns and their details matching the specified filters
1465 1466 1467 1468 |
# File 'lib/mailchimp/api.rb', line 1465 def list(filters=[], start=0, limit=25, sort_field='create_time', sort_dir='DESC') _params = {:filters => filters, :start => start, :limit => limit, :sort_field => sort_field, :sort_dir => sort_dir} return @master.call 'campaigns/list', _params end |
#pause(cid) ⇒ Hash
Pause an AutoResponder or RSS campaign from sending
1474 1475 1476 1477 |
# File 'lib/mailchimp/api.rb', line 1474 def pause(cid) _params = {:cid => cid} return @master.call 'campaigns/pause', _params end |
#ready(cid) ⇒ Hash
Returns information on whether a campaign is ready to send and possible issues we may have detected with it - very similar to the confirmation step in the app.
1487 1488 1489 1490 |
# File 'lib/mailchimp/api.rb', line 1487 def ready(cid) _params = {:cid => cid} return @master.call 'campaigns/ready', _params end |
#replicate(cid) ⇒ Hash
Replicate a campaign.
1495 1496 1497 1498 |
# File 'lib/mailchimp/api.rb', line 1495 def replicate(cid) _params = {:cid => cid} return @master.call 'campaigns/replicate', _params end |
#resume(cid) ⇒ Hash
Resume sending an AutoResponder or RSS campaign
1504 1505 1506 1507 |
# File 'lib/mailchimp/api.rb', line 1504 def resume(cid) _params = {:cid => cid} return @master.call 'campaigns/resume', _params end |
#schedule(cid, schedule_time, schedule_time_b = nil) ⇒ Hash
Schedule a campaign to be sent in the future
1515 1516 1517 1518 |
# File 'lib/mailchimp/api.rb', line 1515 def schedule(cid, schedule_time, schedule_time_b=nil) _params = {:cid => cid, :schedule_time => schedule_time, :schedule_time_b => schedule_time_b} return @master.call 'campaigns/schedule', _params end |
#schedule_batch(cid, schedule_time, num_batches = 2, stagger_mins = 5) ⇒ Hash
Schedule a campaign to be sent in batches sometime in the future. Only valid for “regular” campaigns
1527 1528 1529 1530 |
# File 'lib/mailchimp/api.rb', line 1527 def schedule_batch(cid, schedule_time, num_batches=2, stagger_mins=5) _params = {:cid => cid, :schedule_time => schedule_time, :num_batches => num_batches, :stagger_mins => stagger_mins} return @master.call 'campaigns/schedule-batch', _params end |
#segment_test(list_id, options) ⇒ Hash
Allows one to test their segmentation rules before creating a campaign using them
1539 1540 1541 1542 |
# File 'lib/mailchimp/api.rb', line 1539 def segment_test(list_id, ) _params = {:list_id => list_id, :options => } return @master.call 'campaigns/segment-test', _params end |
#send(cid) ⇒ Hash
Send a given campaign immediately. For RSS campaigns, this will “start” them.
1548 1549 1550 1551 |
# File 'lib/mailchimp/api.rb', line 1548 def send(cid) _params = {:cid => cid} return @master.call 'campaigns/send', _params end |
#send_test(cid, test_emails = [], send_type = 'html') ⇒ Hash
Send a test of this campaign to the provided email addresses
1559 1560 1561 1562 |
# File 'lib/mailchimp/api.rb', line 1559 def send_test(cid, test_emails=[], send_type='html') _params = {:cid => cid, :test_emails => test_emails, :send_type => send_type} return @master.call 'campaigns/send-test', _params end |
#template_content(cid) ⇒ Hash
Get the HTML template content sections for a campaign. Note that this <strong>will</strong> return very jagged, non-standard results based on the template a campaign is using. You only want to use this if you want to allow editing template sections in your application.
1567 1568 1569 1570 |
# File 'lib/mailchimp/api.rb', line 1567 def template_content(cid) _params = {:cid => cid} return @master.call 'campaigns/template-content', _params end |
#unschedule(cid) ⇒ Hash
Unschedule a campaign that is scheduled to be sent in the future
1576 1577 1578 1579 |
# File 'lib/mailchimp/api.rb', line 1576 def unschedule(cid) _params = {:cid => cid} return @master.call 'campaigns/unschedule', _params end |
#update(cid, name, value) ⇒ Hash
Update just about any setting besides type for a campaign that has not been sent. See campaign/create for details. Caveats:<br/><ul class=‘bullets’> <li>If you set a new list_id, all segmentation options will be deleted and must be re-added.</li> <li>If you set template_id, you need to follow that up by setting it’s ‘content’</li> <li>If you set segment_opts, you should have tested your options against campaign/segment-test().</li> <li>To clear/unset segment_opts, pass an empty string or array as the value. Various wrappers may require one or the other.</li> </ul>
1591 1592 1593 1594 |
# File 'lib/mailchimp/api.rb', line 1591 def update(cid, name, value) _params = {:cid => cid, :name => name, :value => value} return @master.call 'campaigns/update', _params end |