Class: Mailchimp::Campaigns

Inherits:
Object
  • Object
show all
Defined in:
lib/mailchimp/api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(master) ⇒ Campaigns

Returns a new instance of Campaigns.



1426
1427
1428
# File 'lib/mailchimp/api.rb', line 1426

def initialize(master)
    @master = master
end

Instance Attribute Details

#masterObject

Returns the value of attribute master.



1424
1425
1426
# File 'lib/mailchimp/api.rb', line 1424

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

Parameters:

  • cid (String)

    the campaign id to get content for (can be gathered using campaigns/list())

  • options (Hash) (defaults to: [])

    various options to control this call

    • [String] view optional one of "archive" (default), "preview" (like our popup-preview) or "raw"
    • [Hash] email optional if provided, view is "archive" or "preview", the campaign's list still exists, and the requested record is subscribed to the list. the returned content will be populated with member data populated. a struct with one of the following keys - failing to provide anything will produce an error relating to the email address. If multiple keys are provided, the first one from the following list that we find will be used, the rest will be ignored.
      • [String] email an email address
      • [String] euid the unique id for an email address (not list related) - the email "id" returned from listMemberInfo, Webhooks, Campaigns, etc.
      • [String] leid the list email id (previously called web_id) for a list-member-info type call. this doesn't change when the email address changes

Returns:

  • (Hash)

    containing all content for the campaign

    • [String] html The HTML content used for the campaign with merge tags intact
    • [String] text The Text content used for the campaign with merge tags intact


1441
1442
1443
1444
# File 'lib/mailchimp/api.rb', line 1441

def content(cid, options=[])
    _params = {:cid => cid, :options => 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 can not have more than 32,000 campaigns in your account.

Parameters:

  • type (String)

    the Campaign Type to create - one of "regular", "plaintext", "absplit", "rss", "auto"

  • options (Hash)

    a struct of the standard options for this campaign :

    • [String] list_id the list to send this campaign to- get lists using lists/list()
    • [String] subject the subject line for your campaign message
    • [String] from_email the From: email address for your campaign message
    • [String] from_name the From: name for your campaign message (not an email address)
    • [String] to_name the To: name recipients will see (not email address)
    • [Int] template_id optional - use this user-created template to generate the HTML content of the campaign (takes precendence over other template options)
    • [Int] gallery_template_id optional - use a template from the public gallery to generate the HTML content of the campaign (takes precendence over base template options)
    • [Int] base_template_id optional - use this a base/start-from-scratch template to generate the HTML content of the campaign
    • [Int] folder_id optional - automatically file the new campaign in the folder_id passed. Get using folders/list() - note that Campaigns and Autoresponders have separate folder setups
    • [Hash] tracking optional - set which recipient actions will be tracked. Click tracking can not be disabled for Free accounts.
      • [Bool] opens whether to track opens, defaults to true
      • [Bool] html_clicks whether to track clicks in HTML content, defaults to true
      • [Bool] text_clicks whether to track clicks in Text content, defaults to false
    • [String] title optional - an internal name to use for this campaign. By default, the campaign subject will be used.
    • [Boolean] authenticate optional - set to true to enable SenderID, DomainKeys, and DKIM authentication, defaults to false.
    • [Hash] analytics optional - one or more of these keys set to the tag to use - that can be any custom text (up to 50 bytes)
      • [String] google for Google Analytics tracking
      • [String] clicktale for ClickTale tracking
      • [String] gooal for Goal tracking (the extra 'o' in the param name is not a typo)
    • [Boolean] auto_footer optional Whether or not we should auto-generate the footer for your content. Mostly useful for content from URLs or Imports
    • [Boolean] inline_css optional Whether or not css should be automatically inlined when this campaign is sent, defaults to false.
    • [Boolean] generate_text optional Whether of not to auto-generate your Text content from the HTML content. Note that this will be ignored if the Text part of the content passed is not empty, defaults to false.
    • [Boolean] auto_tweet optional If set, this campaign will be auto-tweeted when it is sent - defaults to false. Note that if a Twitter account isn't linked, this will be silently ignored.
    • [Array] auto_fb_post optional If set, this campaign will be auto-posted to the page_ids contained in the array. If a Facebook account isn't linked or the account does not have permission to post to the page_ids requested, those failures will be silently ignored.
    • [Boolean] fb_comments optional If true, the Facebook comments (and thus the archive bar will be displayed. If false, Facebook comments will not be enabled (does not imply no archive bar, see previous link). Defaults to "true".
    • [Boolean] timewarp optional If set, this campaign must be scheduled 24 hours in advance of sending - default to false. Only valid for "regular" campaigns and "absplit" campaigns that split on schedule_time.
    • [Boolean] ecomm360 optional If set, our Ecommerce360 tracking will be enabled for links in the campaign
    • [Hash] crm_tracking optional If set, a struct to enable CRM tracking for:
      - [Hash] salesforce optional Enable SalesForce push back
        - [Bool] campaign optional - if true, create a Campaign object and update it with aggregate stats
        - [Bool] notes optional - if true, attempt to update Contact notes based on email address
      - [Hash] highrise optional Enable Highrise push back
        - [Bool] campaign optional - if true, create a Kase object and update it with aggregate stats
        - [Bool] notes optional - if true, attempt to update Contact notes based on email address
      - [Hash] capsule optional Enable Capsule push back (only notes are supported)
        - [Bool] notes optional - if true, attempt to update Contact notes based on email address
  • content (Hash)

    the content for this campaign - use a struct with the one of the following keys:

    • [String] html for raw/pasted HTML content
    • [Hash] sections when using a template instead of raw HTML, each key should be the unique mc:edit area name from the template.
    • [String] text for the plain-text version
    • [String] url to have us pull in content from a URL. Note, this will override any other content options - for lists with Email Format options, you'll need to turn on generate_text as well
    • [String] archive to send a Base64 encoded archive file for us to import all media from. Note, this will override any other content options - for lists with Email Format options, you'll need to turn on generate_text as well
    • [String] archive_type optional - only necessary for the "archive" option. Supported formats are: zip, tar.gz, tar.bz2, tar, tgz, tbz . If not included, we will default to zip
  • segment_opts (Hash) (defaults to: nil)

    if you wish to do Segmentation with this campaign this array should contain: see campaigns/segment-test(). It's suggested that you test your options against campaigns/segment-test().

  • type_opts (Hash) (defaults to: nil)

    various extra options based on the campaign type

    • [Hash] rss For RSS Campaigns this, struct should contain:
      - [String] url the URL to pull RSS content from - it will be verified and must exist
      - [String] schedule optional one of "daily", "weekly", "monthly" - defaults to "daily"
      - [String] schedule_hour optional an hour between 0 and 24 - default to 4 (4am <em>local time</em>) - applies to all schedule types
      - [String] schedule_weekday optional for "weekly" only, a number specifying the day of the week to send: 0 (Sunday) - 6 (Saturday) - defaults to 1 (Monday)
      - [String] schedule_monthday optional for "monthly" only, a number specifying the day of the month to send (1 - 28) or "last" for the last day of a given month. Defaults to the 1st day of the month
      - [Hash] days optional used for "daily" schedules only, an array of the <a href="http://en.wikipedia.org/wiki/ISO-8601#Week_dates" target="_blank">ISO-8601 weekday numbers</a> to send on
        - [Bool] 1 optional Monday, defaults to true
        - [Bool] 2 optional Tuesday, defaults to true
        - [Bool] 3 optional Wednesday, defaults to true
        - [Bool] 4 optional Thursday, defaults to true
        - [Bool] 5 optional Friday, defaults to true
        - [Bool] 6 optional Saturday, defaults to true
        - [Bool] 7 optional Sunday, defaults to true
      
    • [Hash] absplit For A/B Split campaigns, this struct should contain:
      - [String] split_test The values to segment based on. Currently, one of: "subject", "from_name", "schedule". NOTE, for "schedule", you will need to call campaigns/schedule() separately!
      - [String] pick_winner How the winner will be picked, one of: "opens" (by the open_rate), "clicks" (by the click rate), "manual" (you pick manually)
      - [Int] wait_units optional the default time unit to wait before auto-selecting a winner - use "3600" for hours, "86400" for days. Defaults to 86400.
      - [Int] wait_time optional the number of units to wait before auto-selecting a winner - defaults to 1, so if not set, a winner will be selected after 1 Day.
      - [Int] split_size optional this is a percentage of what size the Campaign's List plus any segmentation options results in. "schedule" type forces 50%, all others default to 10%
      - [String] from_name_a optional sort of, required when split_test is "from_name"
      - [String] from_name_b optional sort of, required when split_test is "from_name"
      - [String] from_email_a optional sort of, required when split_test is "from_name"
      - [String] from_email_b optional sort of, required when split_test is "from_name"
      - [String] subject_a optional sort of, required when split_test is "subject"
      - [String] subject_b optional sort of, required when split_test is "subject"
      
    • [Hash] auto For AutoResponder campaigns, this struct should contain:
      - [String] offset-units one of "hourly", "day", "week", "month", "year" - required
      - [String] offset-time optional, sort of - the number of units must be a number greater than 0 for signup based autoresponders, ignored for "hourly"
      - [String] offset-dir either "before" or "after", ignored for "hourly"
      - [String] event optional "signup" (default) to base this members added to a list, "date", "annual", or "birthday" to base this on merge field in the list, "campaignOpen" or "campaignClicka" to base this on any activity for a campaign, "campaignClicko" to base this on clicks on a specific URL in a campaign, "mergeChanged" to base this on a specific merge field being changed to a specific value
      - [String] event-datemerge optional sort of, this is required if the event is "date", "annual", "birthday", or "mergeChanged"
      - [String] campaign_id optional sort of, required for "campaignOpen", "campaignClicka", or "campaignClicko"
      - [String] campaign_url optional sort of, required for "campaignClicko"
      - [Int] schedule_hour The hour of the day - 24 hour format in GMT - the autoresponder should be triggered, ignored for "hourly"
      - [Boolean] use_import_time whether or not imported subscribers (ie, <em>any</em> non-double optin subscribers) will receive
      - [Hash] days optional used for "daily" schedules only, an array of the <a href="http://en.wikipedia.org/wiki/ISO-8601#Week_dates" target="_blank">ISO-8601 weekday numbers</a> to send on<
        - [Bool] 1 optional Monday, defaults to true
        - [Bool] 2 optional Tuesday, defaults to true
        - [Bool] 3 optional Wednesday, defaults to true
        - [Bool] 4 optional Thursday, defaults to true
        - [Bool] 5 optional Friday, defaults to true
        - [Bool] 6 optional Saturday, defaults to true
        - [Bool] 7 optional Sunday, defaults to true

Returns:

  • (Hash)

    the new campaign's details - will return same data as single campaign from campaigns/list()



1539
1540
1541
1542
# File 'lib/mailchimp/api.rb', line 1539

def create(type, options, content, segment_opts=nil, type_opts=nil)
    _params = {:type => type, :options => 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.

Parameters:

  • cid (String)

    the Campaign Id to delete

Returns:

  • (Hash)

    with a single entry:

    • [Bool] complete whether the call worked. reallistically this will always be true as errors will be thrown otherwise.


1548
1549
1550
1551
# File 'lib/mailchimp/api.rb', line 1548

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

Parameters:

  • filters (Hash) (defaults to: [])

    a struct of filters to apply to this query - all are optional:

    • [String] campaign_id optional - return the campaign using a know campaign_id. Accepts multiples separated by commas when not using exact matching.
    • [String] parent_id optional - return the child campaigns using a known parent campaign_id. Accepts multiples separated by commas when not using exact matching.
    • [String] list_id optional - the list to send this campaign to - get lists using lists/list(). Accepts multiples separated by commas when not using exact matching.
    • [Int] folder_id optional - only show campaigns from this folder id - get folders using folders/list(). Accepts multiples separated by commas when not using exact matching.
    • [Int] template_id optional - only show campaigns using this template id - get templates using templates/list(). Accepts multiples separated by commas when not using exact matching.
    • [String] status optional - return campaigns of a specific status - one of "sent", "save", "paused", "schedule", "sending". Accepts multiples separated by commas when not using exact matching.
    • [String] type optional - return campaigns of a specific type - one of "regular", "plaintext", "absplit", "rss", "auto". Accepts multiples separated by commas when not using exact matching.
    • [String] from_name optional - only show campaigns that have this "From Name"
    • [String] from_email optional - only show campaigns that have this "Reply-to Email"
    • [String] title optional - only show campaigns that have this title
    • [String] subject optional - only show campaigns that have this subject
    • [String] sendtime_start optional - only show campaigns that have been sent since this date/time (in GMT) - - 24 hour format in GMT, eg "2013-12-30 20:30:00" - if this is invalid the whole call fails
    • [String] sendtime_end optional - only show campaigns that have been sent before this date/time (in GMT) - - 24 hour format in GMT, eg "2013-12-30 20:30:00" - if this is invalid the whole call fails
    • [Boolean] uses_segment - whether to return just campaigns with or without segments
    • [Boolean] exact optional - flag for whether to filter on exact values when filtering, or search within content for filter values - defaults to true. Using this disables the use of any filters that accept multiples.
  • start (Int) (defaults to: 0)

    optional - control paging of campaigns, start results at this campaign #, defaults to 1st page of data (page 0)

  • limit (Int) (defaults to: 25)

    optional - control paging of campaigns, number of campaigns to return with each call, defaults to 25 (max=1000)

  • sort_field (String) (defaults to: 'create_time')

    optional - one of "create_time", "send_time", "title", "subject" . Invalid values will fall back on "create_time" - case insensitive.

  • sort_dir (String) (defaults to: 'DESC')

    optional - "DESC" for descending (default), "ASC" for Ascending. Invalid values will fall back on "DESC" - case insensitive.

Returns:

  • (Hash)

    containing a count of all matching campaigns, the specific ones for the current page, and any errors from the filters provided

    • [Int] total the total number of campaigns matching the filters passed in
    • [Array] data structs for each campaign being returned
      • [String] id Campaign Id (used for all other campaign functions)
      • [Int] web_id The Campaign id used in our web app, allows you to create a link directly to it
      • [String] list_id The List used for this campaign
      • [Int] folder_id The Folder this campaign is in
      • [Int] template_id The Template this campaign uses
      • [String] content_type How the campaign's content is put together - one of 'template', 'html', 'url'
      • [String] title Title of the campaign
      • [String] type The type of campaign this is (regular,plaintext,absplit,rss,inspection,auto)
      • [String] create_time Creation time for the campaign
      • [String] send_time Send time for the campaign - also the scheduled time for scheduled campaigns.
      • [Int] emails_sent Number of emails email was sent to
      • [String] status Status of the given campaign (save,paused,schedule,sending,sent)
      • [String] from_name From name of the given campaign
      • [String] from_email Reply-to email of the given campaign
      • [String] subject Subject of the given campaign
      • [String] to_name Custom "To:" email string using merge variables
      • [String] archive_url Archive link for the given campaign
      • [Boolean] inline_css Whether or not the campaign content's css was auto-inlined
      • [String] analytics Either "google" if enabled or "N" if disabled
      • [String] analytics_tag The name/tag the campaign's links were tagged with if analytics were enabled.
      • [Boolean] authenticate Whether or not the campaign was authenticated
      • [Boolean] ecomm360 Whether or not ecomm360 tracking was appended to links
      • [Boolean] auto_tweet Whether or not the campaign was auto tweeted after sending
      • [String] auto_fb_post A comma delimited list of Facebook Profile/Page Ids the campaign was posted to after sending. If not used, blank.
      • [Boolean] auto_footer Whether or not the auto_footer was manually turned on
      • [Boolean] timewarp Whether or not the campaign used Timewarp
      • [String] timewarp_schedule The time, in GMT, that the Timewarp campaign is being sent. For A/B Split campaigns, this is blank and is instead in their schedule_a and schedule_b in the type_opts array
      • [String] parent_id the unique id of the parent campaign (currently only valid for rss children). Will be blank for non-rss child campaigns or parent campaign has been deleted.
      • [Boolean] is_child true if this is an RSS child campaign. Will return true even if the parent campaign has been deleted.
      • [String] tests_sent tests sent
      • [Int] tests_remain test sends remaining
      • [Hash] tracking the various tracking options used
        • [Boolean] html_clicks whether or not tracking for html clicks was enabled.
        • [Boolean] text_clicks whether or not tracking for text clicks was enabled.
        • [Boolean] opens whether or not opens tracking was enabled.
      • [String] segment_text a string marked-up with HTML explaining the segment used for the campaign in plain English
      • [Array] segment_opts the segment used for the campaign - can be passed to campaigns/segment-test or campaigns/create()
      • [Hash] saved_segment if a saved segment was used (match+conditions returned above):
        - [Int] id the saved segment id
        - [String] type the saved segment type
        - [String] name the saved segment name
        
      • [Hash] type_opts the type-specific options for the campaign - can be passed to campaigns/create()
      • [Int] comments_total total number of comments left on this campaign
      • [Int] comments_unread total number of unread comments for this campaign based on the login the apikey belongs to
      • [Hash] summary if available, the basic aggregate stats returned by reports/summary
      • [Hash] social_card If a social card has been attached to this campaign:
        - [String] title The title of the campaign used with the card
        - [String] description The description used with the card
        - [String] image_url The URL of the image used with the card
        - [String] enabled Whether or not the social card is enabled for this campaign.
        
    • [Array] errors structs of any errors found while loading lists - usually just from providing invalid list ids
      • [String] filter the filter that caused the failure
      • [String] value the filter value that caused the failure
      • [Int] code the error code
      • [String] error the error message


1632
1633
1634
1635
# File 'lib/mailchimp/api.rb', line 1632

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

Parameters:

  • cid (String)

    the id of the campaign to pause

Returns:

  • (Hash)

    with a single entry:

    • [Bool] complete whether the call worked. reallistically this will always be true as errors will be thrown otherwise.


1641
1642
1643
1644
# File 'lib/mailchimp/api.rb', line 1641

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.

Parameters:

  • cid (String)

    the Campaign Id to replicate

Returns:

  • (Hash)

    containing:

    • [Bool] is_ready whether or not you're going to be able to send this campaign
    • [Array] items an array of structs explaining basically what the app's confirmation step would
      • [String] type the item type - generally success, warning, or error
      • [String] heading the item's heading in the app
      • [String] details the item's details from the app, sans any html tags/links


1654
1655
1656
1657
# File 'lib/mailchimp/api.rb', line 1654

def ready(cid)
    _params = {:cid => cid}
    return @master.call 'campaigns/ready', _params
end

#replicate(cid) ⇒ Hash

Replicate a campaign.

Parameters:

  • cid (String)

    the Campaign Id to replicate

Returns:

  • (Hash)

    the matching campaign's details - will return same data as single campaign from campaigns/list()



1662
1663
1664
1665
# File 'lib/mailchimp/api.rb', line 1662

def replicate(cid)
    _params = {:cid => cid}
    return @master.call 'campaigns/replicate', _params
end

#resume(cid) ⇒ Hash

Resume sending an AutoResponder or RSS campaign

Parameters:

  • cid (String)

    the id of the campaign to resume

Returns:

  • (Hash)

    with a single entry:

    • [Bool] complete whether the call worked. reallistically this will always be true as errors will be thrown otherwise.


1671
1672
1673
1674
# File 'lib/mailchimp/api.rb', line 1671

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

Parameters:

  • cid (String)

    the id of the campaign to schedule

  • schedule_time (String)

    the time to schedule the campaign. For A/B Split "schedule" campaigns, the time for Group A - 24 hour format in GMT, eg "2013-12-30 20:30:00"

  • schedule_time_b (String) (defaults to: nil)

    optional -the time to schedule Group B of an A/B Split "schedule" campaign - 24 hour format in GMT, eg "2013-12-30 20:30:00"

Returns:

  • (Hash)

    with a single entry:

    • [Bool] complete whether the call worked. reallistically this will always be true as errors will be thrown otherwise.


1682
1683
1684
1685
# File 'lib/mailchimp/api.rb', line 1682

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

Parameters:

  • cid (String)

    the id of the campaign to schedule

  • schedule_time (String)

    the time to schedule the campaign.

  • num_batches (Int) (defaults to: 2)

    optional - the number of batches between 2 and 26 to send. defaults to 2

  • stagger_mins (Int) (defaults to: 5)

    optional - the number of minutes between each batch - 5, 10, 15, 20, 25, 30, or 60. defaults to 5

Returns:

  • (Hash)

    with a single entry:

    • [Bool] complete whether the call worked. reallistically this will always be true as errors will be thrown otherwise.


1694
1695
1696
1697
# File 'lib/mailchimp/api.rb', line 1694

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.

Parameters:

  • list_id (String)

    the list to test segmentation on - get lists using lists/list()

  • options (Hash)

    with 1 or 2 keys:

    • [String] saved_segment_id a saved segment id from lists/segments() - this will take precendence, otherwise the match+conditions are required.
    • [String] match controls whether to use AND or OR when applying your options - expects "any" (for OR) or "all" (for AND)
    • [Array] conditions of up to 5 structs for different criteria to apply while segmenting. Each criteria row must contain 3 keys - "field", "op", and "value" - and possibly a fourth, "extra", based on these definitions:

Returns:

  • (Hash)

    with a single entry:

    • [Int] total The total number of subscribers matching your segmentation options


1707
1708
1709
1710
# File 'lib/mailchimp/api.rb', line 1707

def segment_test(list_id, options)
    _params = {:list_id => list_id, :options => options}
    return @master.call 'campaigns/segment-test', _params
end

#send(cid) ⇒ Hash

Send a given campaign immediately. For RSS campaigns, this will "start" them.

Parameters:

  • cid (String)

    the id of the campaign to send

Returns:

  • (Hash)

    with a single entry:

    • [Bool] complete whether the call worked. reallistically this will always be true as errors will be thrown otherwise.


1716
1717
1718
1719
# File 'lib/mailchimp/api.rb', line 1716

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

Parameters:

  • cid (String)

    the id of the campaign to test

  • test_emails (Array) (defaults to: [])

    an array of email address to receive the test message

  • send_type (String) (defaults to: 'html')

    by default just html is sent - can be "html" or "text" send specify the format

Returns:

  • (Hash)

    with a single entry:

    • [Bool] complete whether the call worked. reallistically this will always be true as errors will be thrown otherwise.


1727
1728
1729
1730
# File 'lib/mailchimp/api.rb', line 1727

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 will 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.

Parameters:

  • cid (String)

    the campaign id to get content for (can be gathered using campaigns/list())

Returns:

  • (Hash)

    content containing all content section for the campaign - section name are dependent upon the template used and thus can't be documented



1735
1736
1737
1738
# File 'lib/mailchimp/api.rb', line 1735

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

Parameters:

  • cid (String)

    the id of the campaign to unschedule

Returns:

  • (Hash)

    with a single entry:

    • [Bool] complete whether the call worked. reallistically this will always be true as errors will be thrown otherwise.


1744
1745
1746
1747
# File 'lib/mailchimp/api.rb', line 1744

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:

  • If you set a new list_id, all segmentation options will be deleted and must be re-added.
  • If you set template_id, you need to follow that up by setting it's 'content'
  • If you set segment_opts, you should have tested your options against campaigns/segment-test().
  • To clear/unset segment_opts, pass an empty string or array as the value. Various wrappers may require one or the other.

Parameters:

  • cid (String)

    the Campaign Id to update

  • name (String)

    the parameter name ( see campaigns/create() ). This will be that parameter name (options, content, segment_opts) except "type_opts", which will be the name of the type - rss, auto, etc. The campaign "type" can not be changed.

  • value (Array)

    an appropriate set of values for the parameter ( see campaigns/create() ). For additional parameters, this is the same value passed to them.

Returns:

  • (Hash)

    updated campaign details and any errors

    • [Hash] data the update campaign details - will return same data as single campaign from campaigns/list()
    • [Array] errors for "options" only - structs containing:
      - [Int] code the error code
      - [String] message the full error message
      - [String] name the parameter name that failed


1759
1760
1761
1762
# File 'lib/mailchimp/api.rb', line 1759

def update(cid, name, value)
    _params = {:cid => cid, :name => name, :value => value}
    return @master.call 'campaigns/update', _params
end