Class: GetResponse::Campaign
- Inherits:
-
Object
- Object
- GetResponse::Campaign
- Defined in:
- lib/get_response/campaign.rb
Overview
GetResponse email campaign
Instance Attribute Summary collapse
-
#confirmation_body ⇒ Object
Returns the value of attribute confirmation_body.
-
#confirmation_subject ⇒ Object
Returns the value of attribute confirmation_subject.
-
#created_on ⇒ Object
readonly
Returns the value of attribute created_on.
-
#description ⇒ Object
Returns the value of attribute description.
-
#from_email ⇒ Object
readonly
Returns the value of attribute from_email.
-
#from_field ⇒ Object
Returns the value of attribute from_field.
-
#from_name ⇒ Object
readonly
Returns the value of attribute from_name.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#language_code ⇒ Object
Returns the value of attribute language_code.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#reply_to_email ⇒ Object
readonly
Returns the value of attribute reply_to_email.
-
#reply_to_field ⇒ Object
Returns the value of attribute reply_to_field.
Instance Method Summary collapse
-
#blacklist ⇒ GetResponse::Blacklist
Get the entire blacklisted emails list for this campaign.
-
#contacts ⇒ GetResponse::Contact
Get all contacts assigned to this campaign.
-
#create_follow_up(follow_up_attributes) ⇒ GetResponse::FollowUp
Create follow up message in campaign.
-
#deleted_contacts ⇒ Array
Get contacts deleted from this campaign.
-
#domain ⇒ GetResponse::Domain
Get domain assigned to this campaign.
-
#domain=(new_domain) ⇒ GetResponse::Domain
Set domain for this campaign.
-
#initialize(params, connection) ⇒ Campaign
constructor
A new instance of Campaign.
-
#messages(conditions = {}) ⇒ Object
Get messages assigned to this campaign.
-
#postal_address ⇒ Object
Get campaign’s postal address and and postal design (formatting).
-
#postal_address=(postal_address_hash) ⇒ Object
Set postal address and postal design (formatting) in campaign.
-
#save ⇒ GetResponse::Campaign
Saves new campaign.
-
#subscription_statistics(conditions = {}) ⇒ Hash
Get contacts subscription stats for this campaign aggregated by date, campaign and contact’s origin.
Constructor Details
#initialize(params, connection) ⇒ Campaign
Returns a new instance of Campaign.
10 11 12 13 14 15 16 17 18 |
# File 'lib/get_response/campaign.rb', line 10 def initialize(params, connection) @id = params["id"] @name = params["name"] @from_name = params["from_name"] @from_email = params["from_email"] @reply_to_email = params["reply_to_email"] @created_on = params["created_on"] @connection = connection end |
Instance Attribute Details
#confirmation_body ⇒ Object
Returns the value of attribute confirmation_body.
6 7 8 |
# File 'lib/get_response/campaign.rb', line 6 def confirmation_body @confirmation_body end |
#confirmation_subject ⇒ Object
Returns the value of attribute confirmation_subject.
6 7 8 |
# File 'lib/get_response/campaign.rb', line 6 def confirmation_subject @confirmation_subject end |
#created_on ⇒ Object (readonly)
Returns the value of attribute created_on.
5 6 7 |
# File 'lib/get_response/campaign.rb', line 5 def created_on @created_on end |
#description ⇒ Object
Returns the value of attribute description.
7 8 9 |
# File 'lib/get_response/campaign.rb', line 7 def description @description end |
#from_email ⇒ Object (readonly)
Returns the value of attribute from_email.
5 6 7 |
# File 'lib/get_response/campaign.rb', line 5 def from_email @from_email end |
#from_field ⇒ Object
Returns the value of attribute from_field.
6 7 8 |
# File 'lib/get_response/campaign.rb', line 6 def from_field @from_field end |
#from_name ⇒ Object (readonly)
Returns the value of attribute from_name.
5 6 7 |
# File 'lib/get_response/campaign.rb', line 5 def from_name @from_name end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
5 6 7 |
# File 'lib/get_response/campaign.rb', line 5 def id @id end |
#language_code ⇒ Object
Returns the value of attribute language_code.
7 8 9 |
# File 'lib/get_response/campaign.rb', line 7 def language_code @language_code end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
5 6 7 |
# File 'lib/get_response/campaign.rb', line 5 def name @name end |
#reply_to_email ⇒ Object (readonly)
Returns the value of attribute reply_to_email.
5 6 7 |
# File 'lib/get_response/campaign.rb', line 5 def reply_to_email @reply_to_email end |
#reply_to_field ⇒ Object
Returns the value of attribute reply_to_field.
6 7 8 |
# File 'lib/get_response/campaign.rb', line 6 def reply_to_field @reply_to_field end |
Instance Method Details
#blacklist ⇒ GetResponse::Blacklist
Get the entire blacklisted emails list for this campaign.
195 196 197 198 199 |
# File 'lib/get_response/campaign.rb', line 195 def blacklist params = {"campaign" => @id} entries = @connection.send_request("get_campaign_blacklist", params)["result"].values GetResponse::Blacklist.new(entries, @connection, self) end |
#contacts ⇒ GetResponse::Contact
Get all contacts assigned to this campaign.
24 25 26 27 |
# File 'lib/get_response/campaign.rb', line 24 def contacts @contact_proxy = ContactProxy.new(@connection) @contact_proxy.all(:campaigns => [@id]) end |
#create_follow_up(follow_up_attributes) ⇒ GetResponse::FollowUp
Create follow up message in campaign.
Example:
@campaing.create_follow_up({
"subject" => "My new followup",
"day_of_cycle" => 1024,
"contents" => {
"plain" => "Hello, it is my follow up!",
"html" => "<b>Hello</b>, it is my follow up!"
}
})
217 218 219 220 221 222 |
# File 'lib/get_response/campaign.rb', line 217 def create_follow_up(follow_up_attributes) follow_up_attributes.merge!("campaign_id" => @id) GetResponse::FollowUp.new(follow_up_attributes, @connection).tap do |follow_up| follow_up.save end end |
#deleted_contacts ⇒ Array
Get contacts deleted from this campaign
33 34 35 36 |
# File 'lib/get_response/campaign.rb', line 33 def deleted_contacts @contact_proxy = ContactProxy.new(@connection) @contact_proxy.deleted(:campaigns => [@id]) end |
#domain ⇒ GetResponse::Domain
Get domain assigned to this campaign.
42 43 44 45 46 47 48 |
# File 'lib/get_response/campaign.rb', line 42 def domain params = {"campaign" => self.id} domain = @connection.send_request("get_campaign_domain", params)["result"].map do |id, attrs| Domain.new(attrs.merge("id" => id)) end domain.first end |
#domain=(new_domain) ⇒ GetResponse::Domain
Set domain for this campaign.
55 56 57 58 59 60 61 |
# File 'lib/get_response/campaign.rb', line 55 def domain=(new_domain) params = { "domain" => new_domain.id, "campaign" => self.id } # there will be an exception if bad ids sent @connection.send_request("set_campaign_domain", params) new_domain end |
#messages(conditions = {}) ⇒ Object
Get messages assigned to this campaign. Optionally conditions Hash
can be passed, for example to get campaign messages which are newsletters only. Example:
@campaign.
@campaign.(:type => "newsletter")
- returns
- GetResponse::Message
71 72 73 74 75 |
# File 'lib/get_response/campaign.rb', line 71 def (conditions = {}) conditions[:campaigns]= [@id] @message_proxy = MessageProxy.new @connection @message_proxy.all(conditions) end |
#postal_address ⇒ Object
Get campaign’s postal address and and postal design (formatting). Postal address is returned as Hash
instance.
- returns
-
Hash
82 83 84 |
# File 'lib/get_response/campaign.rb', line 82 def postal_address @connection.send_request("get_campaign_postal_address", "campaign" => @id)["result"] end |
#postal_address=(postal_address_hash) ⇒ Object
Set postal address and postal design (formatting) in campaign. If something goes wrong exception GetResponse::GetResponseError
.
- postal_address_hash
-
Hash
- returns
-
Hash
92 93 94 95 96 |
# File 'lib/get_response/campaign.rb', line 92 def postal_address=(postal_address_hash) params = {"campaign" => @id}.merge(postal_address_hash) result = @connection.send_request("set_campaign_postal_address", params)["result"] result if result["updated"].to_i == 1 end |
#save ⇒ GetResponse::Campaign
Saves new campaign.
176 177 178 179 180 181 182 183 184 185 186 187 188 189 |
# File 'lib/get_response/campaign.rb', line 176 def save attributes = { "name" => name, "description" => description, "language_code" => language_code, "from_field" => from_field.id, "reply_to_field" => reply_to_field.id, "confirmation_subject" => confirmation_subject.id, "confirmation_body" => confirmation_body.id } save_result = @connection.send_request("add_campaign", attributes)["result"] @id = save_result["CAMPAIGN_ID"] self end |
#subscription_statistics(conditions = {}) ⇒ Hash
Get contacts subscription stats for this campaign aggregated by date, campaign and contact’s origin. Example:
# get stats for camapaign, any time period
@campaign.subscription_statistics
# get stats for specified date
@campaign.subscription_statistics(:created_on => {:at => Date.today})
@campaign.subscription_statistics(:created_on => {:from => "2011-01-01", :to => "2011-12-30"})
111 112 113 114 |
# File 'lib/get_response/campaign.rb', line 111 def subscription_statistics(conditions = {}) @contact_proxy = ContactProxy.new(@connection) @contact_proxy.statistics(conditions.merge(:campaigns => [@id])) end |