class ConstantContact::Components::Campaign

Attributes

click_through_details[RW]
created_date[RW]
email_content[RW]
email_content_format[RW]
from_email[RW]
from_name[RW]
greeting_name[RW]
greeting_salutations[RW]
greeting_string[RW]
id[RW]
is_permission_reminder_enabled[RW]
is_view_as_webpage_enabled[RW]
last_run_date[RW]
modified_date[RW]
name[RW]
next_run_date[RW]
permission_reminder_text[RW]
reply_to_email[RW]
sent_to_contact_lists[RW]
status[RW]
style_sheet[RW]
subject[RW]
template_type[RW]
text_content[RW]
tracking_summary[RW]
view_as_web_page_text[RW]

Public Class Methods

create(props) click to toggle source

Factory method to create a Campaign object from an array @param [Hash] props - properties to create object from @return [Campaign]

# File lib/constantcontact/components/email_marketing/campaign.rb, line 22
def self.create(props)
  campaign = Campaign.new
  if props
    props.each do |key, value|
      if key == 'message_footer'
        campaign.message_footer = Components::MessageFooter.create(value)
      elsif key == 'tracking_summary'
        campaign.tracking_summary = Components::TrackingSummary.create(value)
      elsif key == 'sent_to_contact_lists'
        if value
          campaign.sent_to_contact_lists = []
          value.each do |sent_to_contact_list|
            campaign.sent_to_contact_lists << Components::ContactList.create(sent_to_contact_list)
          end
        end
      elsif key == 'click_through_details'
        if value
          campaign.click_through_details = []
          value.each do |click_through_details|
            campaign.click_through_details << Components::ClickThroughDetails.create(click_through_details)
          end
        end
      else
        campaign.send("#{key}=", value) if campaign.respond_to? key
      end
    end
  end
  campaign
end
create_summary(props) click to toggle source

Factory method to create a Campaign object from an array @param [Hash] props - hash of initial properties to set @return [Campaign]

# File lib/constantcontact/components/email_marketing/campaign.rb, line 56
def self.create_summary(props)
  campaign = Campaign.new
  if props
    props.each do |key, value|
      campaign.send("#{key}=", value) if campaign.respond_to? key
    end
  end
  campaign
end

Public Instance Methods

add_list(contact_list) click to toggle source

Add a contact list to set of lists associated with this email @param [Mixed] contact_list - Contact list id, or ContactList object

# File lib/constantcontact/components/email_marketing/campaign.rb, line 69
def add_list(contact_list)
  if contact_list.instance_of?(ContactList)
    list = contact_list
  elsif contact_list.to_i.to_s == contact_list
    list = ContactList.new(contact_list)
  else
    raise Exceptions::IllegalArgumentException, sprintf(Util::Config.get('errors.id_or_object'), 'ContactList')
  end

  @sent_to_contact_lists << list
end