lib/createsend/campaign.rb in createsend-2.3.0 vs lib/createsend/campaign.rb in createsend-2.4.0
- old
+ new
@@ -9,10 +9,25 @@
def initialize(campaign_id)
@campaign_id = campaign_id
end
# Creates a new campaign for a client.
+ # client_id - String representing the ID of the client for whom the
+ # campaign will be created.
+ # subject - String representing the subject of the campaign.
+ # name - String representing the name of the campaign.
+ # from_name - String representing the from name for the campaign.
+ # from_email - String representing the from address for the campaign.
+ # reply_to - String representing the reply-to address for the campaign.
+ # html_url - String representing the URL for the campaign HTML content.
+ # text_url - String representing the URL for the campaign text content.
+ # Note that text_url is optional and if nil or an empty string, text
+ # content will be automatically generated from the HTML content.
+ # list_ids - Array of Strings representing the IDs of the lists to
+ # which the campaign will be sent.
+ # segment_ids - Array of Strings representing the IDs of the segments to
+ # which the campaign will be sent.
def self.create(client_id, subject, name, from_name, from_email,
reply_to, html_url, text_url, list_ids, segment_ids)
options = { :body => {
:Subject => subject,
:Name => name,
@@ -26,10 +41,27 @@
response = CreateSend.post "/campaigns/#{client_id}.json", options
response.parsed_response
end
# Creates a new campaign for a client, from a template.
+ # client_id - String representing the ID of the client for whom the
+ # campaign will be created.
+ # subject - String representing the subject of the campaign.
+ # name - String representing the name of the campaign.
+ # from_name - String representing the from name for the campaign.
+ # from_email - String representing the from address for the campaign.
+ # reply_to - String representing the reply-to address for the campaign.
+ # list_ids - Array of Strings representing the IDs of the lists to
+ # which the campaign will be sent.
+ # segment_ids - Array of Strings representing the IDs of the segments to
+ # which the campaign will be sent.
+ # template_id - String representing the ID of the template on which
+ # the campaign will be based.
+ # template_content - Hash representing the content to be used for the
+ # editable areas of the template. See documentation at
+ # campaignmonitor.com/api/campaigns/#creating_a_campaign_from_template
+ # for full details of template content format.
def self.create_from_template(client_id, subject, name, from_name,
from_email, reply_to, list_ids, segment_ids, template_id,
template_content)
options = { :body => {
:Subject => subject,
@@ -78,10 +110,16 @@
def summary
response = get "summary", {}
Hashie::Mash.new(response)
end
+ # Gets the email clients that subscribers used to open the campaign
+ def email_client_usage
+ response = get "emailclientusage", {}
+ response.map{|item| Hashie::Mash.new(item)}
+ end
+
# Retrieves the lists and segments to which this campaaign will
# be (or was) sent.
def lists_and_segments
response = get "listsandsegments", {}
Hashie::Mash.new(response)
@@ -133,9 +171,22 @@
:page => page,
:pagesize => page_size,
:orderfield => order_field,
:orderdirection => order_direction } }
response = get "unsubscribes", options
+ Hashie::Mash.new(response)
+ end
+
+ # Retrieves the spam complaints for this campaign.
+ def spam(date, page=1, page_size=1000, order_field="date",
+ order_direction="asc")
+ options = { :query => {
+ :date => date,
+ :page => page,
+ :pagesize => page_size,
+ :orderfield => order_field,
+ :orderdirection => order_direction } }
+ response = get "spam", options
Hashie::Mash.new(response)
end
# Retrieves the bounces for this campaign.
def bounces(date="1900-01-01", page=1, page_size=1000, order_field="date",
\ No newline at end of file