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.
1347 1348 1349 |
# File 'lib/mailchimp/api.rb', line 1347 def initialize(master) @master = master end |
Instance Attribute Details
#master ⇒ Object
Returns the value of attribute master.
1345 1346 1347 |
# File 'lib/mailchimp/api.rb', line 1345 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
1362 1363 1364 1365 |
# File 'lib/mailchimp/api.rb', line 1362 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.
1460 1461 1462 1463 |
# File 'lib/mailchimp/api.rb', line 1460 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.
1469 1470 1471 1472 |
# File 'lib/mailchimp/api.rb', line 1469 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
1547 1548 1549 1550 |
# File 'lib/mailchimp/api.rb', line 1547 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
1556 1557 1558 1559 |
# File 'lib/mailchimp/api.rb', line 1556 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.
1569 1570 1571 1572 |
# File 'lib/mailchimp/api.rb', line 1569 def ready(cid) _params = {:cid => cid} return @master.call 'campaigns/ready', _params end |
#replicate(cid) ⇒ Hash
Replicate a campaign.
1577 1578 1579 1580 |
# File 'lib/mailchimp/api.rb', line 1577 def replicate(cid) _params = {:cid => cid} return @master.call 'campaigns/replicate', _params end |
#resume(cid) ⇒ Hash
Resume sending an AutoResponder or RSS campaign
1586 1587 1588 1589 |
# File 'lib/mailchimp/api.rb', line 1586 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
1597 1598 1599 1600 |
# File 'lib/mailchimp/api.rb', line 1597 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
1609 1610 1611 1612 |
# File 'lib/mailchimp/api.rb', line 1609 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
1622 1623 1624 1625 |
# File 'lib/mailchimp/api.rb', line 1622 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.
1631 1632 1633 1634 |
# File 'lib/mailchimp/api.rb', line 1631 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
1642 1643 1644 1645 |
# File 'lib/mailchimp/api.rb', line 1642 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.
1650 1651 1652 1653 |
# File 'lib/mailchimp/api.rb', line 1650 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
1659 1660 1661 1662 |
# File 'lib/mailchimp/api.rb', line 1659 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 campaigns/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 campaigns/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>
1674 1675 1676 1677 |
# File 'lib/mailchimp/api.rb', line 1674 def update(cid, name, value) _params = {:cid => cid, :name => name, :value => value} return @master.call 'campaigns/update', _params end |