class ConstantContact::Api

Attributes

access_token[RW]
api_key[RW]

Public Class Methods

new(api_key = nil, access_token = nil) click to toggle source

Class constructor @param [String] api_key - Constant Contact API Key @param [String] access_token - Constant Contact OAuth2 access token @return

# File lib/constantcontact/api.rb, line 16
def initialize(api_key = nil, access_token = nil)
  @api_key = api_key || Util::Config.get('auth.api_key')
  @access_token = access_token
  if @api_key.nil? || @api_key == ''
    raise ArgumentError.new(Util::Config.get('errors.api_key_missing'))
  end
  if @access_token.nil? || @access_token == ''
    raise ArgumentError.new(Util::Config.get('errors.access_token_missing'))
  end
  
  @account_service = Services::AccountService.new(self)
  @activity_service = Services::ActivityService.new(self)
  @campaign_tracking_service = Services::CampaignTrackingService.new(self)
  @campaign_schedule_service = Services::CampaignScheduleService.new(self)
  @contact_service = Services::ContactService.new(self)
  @contact_tracking_service = Services::ContactTrackingService.new(self)
  @email_marketing_service = Services::EmailMarketingService.new(self)
  @event_spot_service = Services::EventSpotService.new(self)
  @library_service = Services::LibraryService.new(self)
  @list_service = Services::ListService.new(self)
end

Public Instance Methods

add_clear_lists_activity(lists) click to toggle source

Add a ClearLists Activity to remove all contacts from the provided lists @param [Array<Lists>] lists - Add Contacts Activity @return [Activity]

# File lib/constantcontact/api.rb, line 532
def add_clear_lists_activity(lists)
  @activity_service.add_clear_lists_activity(lists)
end
add_contact(contact, action_by_visitor = false) click to toggle source

Add a new contact to an account @param [Contact] contact - Contact to add @param [Boolean] action_by_visitor - if the action is being taken by the visitor @return [Contact]

# File lib/constantcontact/api.rb, line 90
def add_contact(contact, action_by_visitor = false)
  params = {}
  params['action_by'] = 'ACTION_BY_VISITOR' if action_by_visitor
  @contact_service.add_contact(contact, params)
end
add_create_contacts_activity(add_contacts) click to toggle source

Add an AddContacts activity to add contacts in bulk @param [AddContacts] add_contacts - Add Contacts Activity @return [Activity]

# File lib/constantcontact/api.rb, line 514
def add_create_contacts_activity(add_contacts)
  @activity_service.create_add_contacts_activity(add_contacts)
end
add_create_contacts_activity_from_file(file_name, contents, lists) click to toggle source

Create an Add Contacts Activity from a file. Valid file types are txt, csv, xls, xlsx @param [String] file_name - The name of the file (ie: contacts.csv) @param [String] contents - The content of the file @param [String] lists - Comma separated list of ContactList id's to add the contacts to @return [Activity]

# File lib/constantcontact/api.rb, line 524
def add_create_contacts_activity_from_file(file_name, contents, lists)
  @activity_service.create_add_contacts_activity_from_file(file_name, contents, lists)
end
add_email_campaign(campaign) click to toggle source

Create a new campaign @param [Campaign] campaign - Campaign to be created @return [Campaign] - created campaign

# File lib/constantcontact/api.rb, line 229
def add_email_campaign(campaign)
  @email_marketing_service.add_campaign(campaign)
end
add_email_campaign_schedule(campaign, schedule) click to toggle source

Schedule a campaign to be sent @param [Mixed] campaign - Id of a campaign or a Campaign object @param [Schedule] schedule - Schedule to be associated with the provided campaign @return [Campaign] - updated campaign

# File lib/constantcontact/api.rb, line 246
def add_email_campaign_schedule(campaign, schedule)
  campaign_id = to_id(campaign, 'Campaign')
  @campaign_schedule_service.add_schedule(campaign_id, schedule)
end
add_event(event) click to toggle source

Create an event @param [Hash] event - Event data stored in an object which respods to to_json @return [Event]

# File lib/constantcontact/api.rb, line 582
def add_event(event)
  @event_spot_service.add_event(event)
end
add_event_fee(event, fee) click to toggle source

Create an event fee @param [Event] event - Event fee corresponds to @param [Hash] fee - Fee details @return [EventFee]

# File lib/constantcontact/api.rb, line 632
def add_event_fee(event, fee)
  @event_spot_service.add_fee(event, fee)
end
add_event_item(event_id, event_item) click to toggle source

Create a new event item for an event @param [Integer] event_id - id of event to be associated with the event item @param [EventItem] event_item - event item to be created @return [EventItem]

# File lib/constantcontact/api.rb, line 693
def add_event_item(event_id, event_item)
  @event_spot_service.add_event_item(event_id, event_item)
end
add_event_item_attribute(event_id, item_id, event_item_attribute) click to toggle source

Create a new event item attribute for an event item @param [Integer] event_id - id of event to be associated with the event item attribute @param [Integer] item_id - id of event item to be associated with the event item attribute @param [EventItemAttribute] event_item_attribute - event item attribute to be created @return [EventItemAttribute]

# File lib/constantcontact/api.rb, line 740
def add_event_item_attribute(event_id, item_id, event_item_attribute)
  @event_spot_service.add_event_item_attribute(event_id, item_id, event_item_attribute)
end
add_export_contacts_activity(export_contacts) click to toggle source

Create an Export Contacts Activity @param [<Array>Contacts] export_contacts - Contacts to be exported @return [Activity]

# File lib/constantcontact/api.rb, line 559
def add_export_contacts_activity(export_contacts)
  @activity_service.add_export_contacts_activity(export_contacts)
end
add_library_file(file_name, folder_id, description, source, file_type, contents) click to toggle source

Adds a new MyLibrary file using the multipart content-type @param [String] file_name - The name of the file (ie: dinnerplate-special.jpg) @param [String] folder_id - Folder id to add the file to @param [String] description - The description of the file provided by user @param [String] source - indicates the source of the original file;

image files can be uploaded from the following sources :
MyComputer, StockImage, Facebook - MyLibrary Plus customers only,
Instagram - MyLibrary Plus customers only, Shutterstock, Mobile

@param [String] file_type - Specifies the file type, valid values are: JPEG, JPG, GIF, PDF, PNG @param [String] contents - The content of the file @return [LibraryFile]

# File lib/constantcontact/api.rb, line 943
def add_library_file(file_name, folder_id, description, source, file_type, contents)
  @library_service.add_library_file(file_name, folder_id, description, source, file_type, contents)
end
add_library_folder(folder) click to toggle source

Create a new MyLibrary folder @param [LibraryFolder] folder - Library Folder to be created @return [LibraryFolder]

# File lib/constantcontact/api.rb, line 836
def add_library_folder(folder)
  @library_service.add_library_folder(folder)
end
add_list(list) click to toggle source

Add a new list to an account @param [ContactList] list - List to add @return [ContactList]

# File lib/constantcontact/api.rb, line 161
def add_list(list)
  @list_service.add_list(list)
end
add_promocode(event_id, promocode) click to toggle source

Create a new promocode for an event @param [Integer] event_id - id of event to be associated with the promocode @param [Promocode] promocode - promocode to be created @return [Promocode]

# File lib/constantcontact/api.rb, line 786
def add_promocode(event_id, promocode)
  @event_spot_service.add_promocode(event_id, promocode)
end
add_remove_contacts_from_lists_activity(email_addresses, lists) click to toggle source

Add a Remove Contacts From Lists Activity @param [Array<EmailAddress>] email_addresses - email addresses to be removed @param [Array<Lists>] lists - lists to remove the provided email addresses from @return [Activity]

# File lib/constantcontact/api.rb, line 541
def add_remove_contacts_from_lists_activity(email_addresses, lists)
  @activity_service.add_remove_contacts_from_lists_activity(email_addresses, lists)
end
add_remove_contacts_from_lists_activity_from_file(file_name, contents, lists) click to toggle source

Add a Remove Contacts From Lists Activity from a file. Valid file types are txt, csv, xls, xlsx @param [String] file_name - The name of the file (ie: contacts.csv) @param [String] contents - The content of the file @param [String] lists - Comma separated list of ContactList id' to add the contacts too @return [Activity]

# File lib/constantcontact/api.rb, line 551
def add_remove_contacts_from_lists_activity_from_file(file_name, contents, lists)
  @activity_service.add_remove_contacts_from_lists_activity_from_file(file_name, contents, lists)
end
cancel_event(event) click to toggle source

Cancel an event @param [Event] event - Event to cancel @return [Event]

# File lib/constantcontact/api.rb, line 606
def cancel_event(event)
  @event_spot_service.cancel_event(event)
end
delete_contact(contact) click to toggle source

Sets an individual contact to 'REMOVED' status @param [Mixed] contact - Either a Contact id or the Contact itself @raise [IllegalArgumentException] If contact is not an integer or a Contact object @return [Boolean]

# File lib/constantcontact/api.rb, line 101
def delete_contact(contact)
  contact_id = to_id(contact, 'Contact')
  @contact_service.delete_contact(contact_id)
end
delete_contact_from_list(contact, list) click to toggle source

Delete a contact from all contact lists @param [Mixed] contact - Contact id or a Contact object @param [Mixed] list - ContactList id or a ContactList object @raise [IllegalArgumentException] If contact is not an integer or a Contact object @return [Boolean]

# File lib/constantcontact/api.rb, line 122
def delete_contact_from_list(contact, list)
  contact_id = to_id(contact, 'Contact')
  list_id = to_id(list, 'ContactList')
  @contact_service.delete_contact_from_list(contact_id, list_id)
end
delete_contact_from_lists(contact) click to toggle source

Delete a contact from all contact lists @param [Mixed] contact - Contact id or the Contact object itself @raise [IllegalArgumentException] If contact is not an integer or a Contact object @return [Boolean]

# File lib/constantcontact/api.rb, line 111
def delete_contact_from_lists(contact)
  contact_id = to_id(contact, 'Contact')
  @contact_service.delete_contact_from_lists(contact_id)
end
delete_email_campaign(campaign) click to toggle source

Delete an individual campaign @param [Mixed] campaign - Id of a campaign or a Campaign object @raise IllegalArgumentException - if a Campaign object or campaign id is not passed @return [Boolean]

# File lib/constantcontact/api.rb, line 220
def delete_email_campaign(campaign)
  campaign_id = to_id(campaign, 'Campaign')
  @email_marketing_service.delete_campaign(campaign_id)
end
delete_email_campaign_schedule(campaign, schedule) click to toggle source

Delete a specific schedule associated with a given campaign @param [Mixed] campaign - Campaign id or Campaign object itself @param [Mixed] schedule - Schedule id or Schedule object itself @raise IllegalArgumentException @return [Boolean]

# File lib/constantcontact/api.rb, line 288
def delete_email_campaign_schedule(campaign, schedule)
  campaign_id = to_id(campaign, 'Campaign')
  schedule_id = to_id(schedule, 'Schedule')
  @campaign_schedule_service.delete_schedule(campaign_id, schedule_id)
end
delete_event_fee(event, fee) click to toggle source

Delete an event fee @param [Event] event - Event fee corresponds to @param [EventFee] fee - Fee details @return [Boolean]

# File lib/constantcontact/api.rb, line 650
def delete_event_fee(event, fee)
  @event_spot_service.delete_fee(event, fee)
end
delete_event_item(event_id, item_id) click to toggle source

Delete a specific event item for an event @param [Integer] event_id - id of event to delete an event item for @param [Integer] item_id - id of event item to be deleted @return [Boolean]

# File lib/constantcontact/api.rb, line 702
def delete_event_item(event_id, item_id)
  @event_spot_service.delete_event_item(event_id, item_id)
end
delete_event_item_attribute(event_id, item_id, attribute_id) click to toggle source

Delete a specific event item for an event @param [Integer] event_id - id of event to delete an event item attribute for @param [Integer] item_id - id of event item to delete an event item attribute for @param [Integer] attribute_id - id of attribute to be deleted @return [Boolean]

# File lib/constantcontact/api.rb, line 750
def delete_event_item_attribute(event_id, item_id, attribute_id)
  @event_spot_service.delete_event_item_attribute(event_id, item_id, attribute_id)
end
delete_library_file(file_id) click to toggle source

Delete one or more MyLibrary files specified by the fileId path parameter; separate multiple file IDs with a comma. Deleted files are moved from their current folder into the system Trash folder, and its status is set to Deleted. @param [String] file_id - Specifies the MyLibrary file to delete @return [Boolean]

# File lib/constantcontact/api.rb, line 961
def delete_library_file(file_id)
  @library_service.delete_library_file(file_id)
end
delete_library_folder(folder_id) click to toggle source

Delete a MyLibrary folder @param [String] folder_id - The ID for the MyLibrary folder to delete @return [Boolean]

# File lib/constantcontact/api.rb, line 860
def delete_library_folder(folder_id)
  @library_service.delete_library_folder(folder_id)
end
delete_library_trash() click to toggle source

Permanently deletes all files in the Trash folder @return [Boolean]

# File lib/constantcontact/api.rb, line 889
def delete_library_trash()
  @library_service.delete_library_trash()
end
delete_promocode(event_id, promocode_id) click to toggle source

Delete a specific promocode for an event @param [Integer] event_id - id of event to delete a promocode for @param [Integer] promocode_id - id of promocode to be deleted @return [Boolean]

# File lib/constantcontact/api.rb, line 795
def delete_promocode(event_id, promocode_id)
  @event_spot_service.delete_promocode(event_id, promocode_id)
end
get_account_info() click to toggle source

Get a summary of account information @return [AccountInfo]

# File lib/constantcontact/api.rb, line 41
def get_account_info()
  @account_service.get_account_info()
end
get_activities(params = {}) click to toggle source

Get an array of activities @param [Hash] params - hash of query parameters and values to append to the request.

Allowed parameters include:
status - Status of the activity, must be one of UNCONFIRMED, PENDING, QUEUED, RUNNING, COMPLETE, ERROR
type - Type of activity, must be one of ADD_CONTACTS, REMOVE_CONTACTS_FROM_LISTS, CLEAR_CONTACTS_FROM_LISTS,
       EXPORT_CONTACTS

@return [Array<Activity>]

# File lib/constantcontact/api.rb, line 498
def get_activities(params = {})
  @activity_service.get_activities(params)
end
get_activity(activity_id) click to toggle source

Get a single activity by id @param [String] activity_id - Activity id @return [Activity]

# File lib/constantcontact/api.rb, line 506
def get_activity(activity_id)
  @activity_service.get_activity(activity_id)
end
get_contact(contact_id) click to toggle source

Get an individual contact @param [Integer] contact_id - Id of the contact to retrieve @return [Contact]

# File lib/constantcontact/api.rb, line 73
def get_contact(contact_id)
  @contact_service.get_contact(contact_id)
end
get_contact_bounces(contact, params = {}) click to toggle source

Get bounces for a Contact @param [Mixed] contact - Contact id or Contact object itself @param [Hash] params - hash of query parameters and values to append to the request.

Allowed parameters include:
limit - Specifies the number of results displayed per page of output, from 1 - 500, default = 50.
created_since - Used to retrieve a list of events since the date and time specified (in ISO-8601 format).
next - the next link returned from a previous paginated call. May only be used by itself.

@return [ResultSet<BounceActivity>]

# File lib/constantcontact/api.rb, line 420
def get_contact_bounces(contact, params = {})
  contact_id = to_id(contact, 'Contact')
  @contact_tracking_service.get_bounces(contact_id, params)
end
get_contact_by_email(email) click to toggle source

Get contacts with a specified email eaddress @param [String] email - contact email address to search for @return [ResultSet<Contact>] a ResultSet of Contacts

# File lib/constantcontact/api.rb, line 81
def get_contact_by_email(email)
  @contact_service.get_contacts({'email' => email})
end
get_contact_clicks(contact, params = {}) click to toggle source

Get clicks for a Contact @param [Mixed] contact - Contact id or Contact object itself @param [Hash] params - hash of query parameters and values to append to the request.

Allowed parameters include:
limit - Specifies the number of results displayed per page of output, from 1 - 500, default = 50.
created_since - Used to retrieve a list of events since the date and time specified (in ISO-8601 format).
next - the next link returned from a previous paginated call. May only be used by itself.

@return [ResultSet<ClickActivity>]

# File lib/constantcontact/api.rb, line 434
def get_contact_clicks(contact, params = {})
  contact_id = to_id(contact, 'Contact')
  @contact_tracking_service.get_clicks(contact_id, params)
end
get_contact_forwards(contact, params = {}) click to toggle source

Get forwards for a Contact @param [Mixed] contact - Contact id or Contact object itself @param [Hash] params - hash of query parameters and values to append to the request.

Allowed parameters include:
limit - Specifies the number of results displayed per page of output, from 1 - 500, default = 50.
created_since - Used to retrieve a list of events since the date and time specified (in ISO-8601 format).
next - the next link returned from a previous paginated call. May only be used by itself.

@return [ResultSet<ForwardActivity>]

# File lib/constantcontact/api.rb, line 462
def get_contact_forwards(contact, params = {})
  contact_id = to_id(contact, 'Contact')
  @contact_tracking_service.get_forwards(contact_id, params)
end
get_contact_opens(contact, params = {}) click to toggle source

Get opens for a Contact @param [Mixed] contact - Contact id or Contact object itself @param [Hash] params - hash of query parameters and values to append to the request.

Allowed parameters include:
limit - Specifies the number of results displayed per page of output, from 1 - 500, default = 50.
created_since - Used to retrieve a list of events since the date and time specified (in ISO-8601 format).
next - the next link returned from a previous paginated call. May only be used by itself.

@return [ResultSet<OpenActivity>]

# File lib/constantcontact/api.rb, line 448
def get_contact_opens(contact, params = {})
  contact_id = to_id(contact, 'Contact')
  @contact_tracking_service.get_opens(contact_id, params)
end
get_contact_sends(contact, params = {}) click to toggle source

Get sends for a Contact @param [Mixed] contact - Contact id or Contact object itself @param [Hash] params - hash of query parameters and values to append to the request.

Allowed parameters include:
limit - Specifies the number of results displayed per page of output, from 1 - 500, default = 50.
created_since - Used to retrieve a list of events since the date and time specified (in ISO-8601 format).
next - the next link returned from a previous paginated call. May only be used by itself.

@return [ResultSet<SendActivity>]

# File lib/constantcontact/api.rb, line 406
def get_contact_sends(contact, params = {})
  contact_id = to_id(contact, 'Contact')
  @contact_tracking_service.get_sends(contact_id, params)
end
get_contact_summary_report(contact) click to toggle source

Get a reporting summary for a Contact @param [Mixed] contact - Contact id or Contact object itself @return [TrackingSummary]

# File lib/constantcontact/api.rb, line 485
def get_contact_summary_report(contact)
  contact_id = to_id(contact, 'Contact')
  @contact_tracking_service.get_summary(contact_id)
end
get_contact_unsubscribes(contact, params = {}) click to toggle source

Get unsubscribes for a Contact @param [Mixed] contact - Contact id or Contact object itself @param [Hash] params - hash of query parameters and values to append to the request.

Allowed parameters include:
limit - Specifies the number of results displayed per page of output, from 1 - 500, default = 50.
created_since - Used to retrieve a list of events since the date and time specified (in ISO-8601 format).
next - the next link returned from a previous paginated call. May only be used by itself.

@return [UnsubscribeActivity] - Containing a results array of UnsubscribeActivity

# File lib/constantcontact/api.rb, line 476
def get_contact_unsubscribes(contact, params = {})
  contact_id = to_id(contact, 'Contact')
  @contact_tracking_service.get_unsubscribes(contact_id, params)
end
get_contacts(params = {}) click to toggle source

Get a set of contacts @param [Hash] params - hash of query parameters and values to append to the request. Allowed parameters include:

limit - Specifies the number of results displayed per page of output, from 1 - 500, default = 50.
modified_since - ISO-8601 formatted timestamp.
next - the next link returned from a previous paginated call. May only be used by itself.
email - the contact by email address to retrieve information for.
status - a contact status to filter results by. Must be one of ACTIVE, OPTOUT, REMOVED, UNCONFIRMED.

@return [ResultSet<Contact>] a ResultSet of Contacts

# File lib/constantcontact/api.rb, line 65
def get_contacts(params = {})
  @contact_service.get_contacts(params)
end
get_contacts_from_list(list, param = nil) click to toggle source

Get contact that belong to a specific list @param [Mixed] list - Integer id of the list or ContactList object @param [Mixed] param - denotes the number of results per set, limited to 50, or a next parameter provided from a previous getContactsFromList call @raise [IllegalArgumentException] If contact is not an integer or contact @return [Array<Contact>] An array of contacts

# File lib/constantcontact/api.rb, line 180
def get_contacts_from_list(list, param = nil)
  list_id = to_id(list, 'ContactList')
  param = determine_param(param)
  @list_service.get_contacts_from_list(list_id, param)
end
get_email_campaign(campaign_id) click to toggle source

Get an individual campaign @param [Integer] campaign_id - Valid campaign id @return [Campaign]

# File lib/constantcontact/api.rb, line 203
def get_email_campaign(campaign_id)
  @email_marketing_service.get_campaign(campaign_id)
end
get_email_campaign_bounces(campaign, params = {}) click to toggle source

Get bounces for a campaign @param [Mixed] campaign - Campaign id or Campaign object itself @param [Hash] params - hash of query parameters and values to append to the request.

Allowed parameters include:
limit - Specifies the number of results displayed per page of output, from 1 - 500, default = 50.
created_since - Used to retrieve a list of events since the date and time specified (in ISO-8601 format).
next - the next link returned from a previous paginated call. May only be used by itself.

@return [ResultSet<BounceActivity>]

# File lib/constantcontact/api.rb, line 327
def get_email_campaign_bounces(campaign, params = {})
  campaign_id = to_id(campaign, 'Campaign')
  @campaign_tracking_service.get_bounces(campaign_id, params)
end
get_email_campaign_clicks(campaign, params = {}) click to toggle source

Get clicks for a campaign @param [Mixed] campaign - Campaign id or Campaign object itself @param [Hash] params - hash of query parameters and values to append to the request.

Allowed parameters include:
limit - Specifies the number of results displayed per page of output, from 1 - 500, default = 50.
created_since - Used to retrieve a list of events since the date and time specified (in ISO-8601 format).
next - the next link returned from a previous paginated call. May only be used by itself.

@return [ResultSet<ClickActivity>]

# File lib/constantcontact/api.rb, line 341
def get_email_campaign_clicks(campaign, params = {})
  campaign_id = to_id(campaign, 'Campaign')
  @campaign_tracking_service.get_clicks(campaign_id, params)
end
get_email_campaign_forwards(campaign, params = {}) click to toggle source

Get forwards for a campaign @param [Mixed] campaign - Campaign id or Campaign object itself @param [Hash] params - hash of query parameters and values to append to the request.

Allowed parameters include:
limit - Specifies the number of results displayed per page of output, from 1 - 500, default = 50.
created_since - Used to retrieve a list of events since the date and time specified (in ISO-8601 format).
next - the next link returned from a previous paginated call. May only be used by itself.

@return [ResultSet<ForwardActivity>]

# File lib/constantcontact/api.rb, line 369
def get_email_campaign_forwards(campaign, params = {})
  campaign_id = to_id(campaign, 'Campaign')
  @campaign_tracking_service.get_forwards(campaign_id, params)
end
get_email_campaign_opens(campaign, params = {}) click to toggle source

Get opens for a campaign @param [Mixed] campaign - Campaign id or Campaign object itself @param [Hash] params - hash of query parameters and values to append to the request.

Allowed parameters include:
limit - Specifies the number of results displayed per page of output, from 1 - 500, default = 50.
created_since - Used to retrieve a list of events since the date and time specified (in ISO-8601 format).
next - the next link returned from a previous paginated call. May only be used by itself.

@return [ResultSet<OpenActivity>]

# File lib/constantcontact/api.rb, line 355
def get_email_campaign_opens(campaign, params = {})
  campaign_id = to_id(campaign, 'Campaign')
  @campaign_tracking_service.get_opens(campaign_id, params)
end
get_email_campaign_preview(campaign_id) click to toggle source

Get the preview of an existing campaign @param [Integer] campaign_id - Valid campaign id @return [CampaignPreview]

# File lib/constantcontact/api.rb, line 211
def get_email_campaign_preview(campaign_id)
  @email_marketing_service.get_campaign_preview(campaign_id)
end
get_email_campaign_schedule(campaign, schedule) click to toggle source

Get a specific schedule associated with a given campaign @param [Mixed] campaign - Campaign id or Campaign object itself @param [Mixed] schedule - Schedule id or Schedule object itself @raise IllegalArgumentException @return [Schedule]

# File lib/constantcontact/api.rb, line 266
def get_email_campaign_schedule(campaign, schedule)
  campaign_id = to_id(campaign, 'Campaign')
  schedule_id = to_id(schedule, 'Schedule')
  @campaign_schedule_service.get_schedule(campaign_id, schedule_id)
end
get_email_campaign_schedules(campaign) click to toggle source

Get an array of schedules associated with a given campaign @param [Mixed] campaign - Campaign id or Campaign object itself @return [Array<Schedule>]

# File lib/constantcontact/api.rb, line 255
def get_email_campaign_schedules(campaign)
  campaign_id = to_id(campaign, 'Campaign')
  @campaign_schedule_service.get_schedules(campaign_id)
end
get_email_campaign_sends(campaign, params = {}) click to toggle source

Get sends for a campaign @param [Mixed] campaign - Campaign id or Campaign object itself @param [Hash] params - hash of query parameters and values to append to the request.

Allowed parameters include:
limit - Specifies the number of results displayed per page of output, from 1 - 500, default = 50.
created_since - Used to retrieve a list of events since the date and time specified (in ISO-8601 format).
next - the next link returned from a previous paginated call. May only be used by itself.

@return [ResultSet<SendActivity>]

# File lib/constantcontact/api.rb, line 313
def get_email_campaign_sends(campaign, params = {})
  campaign_id = to_id(campaign, 'Campaign')
  @campaign_tracking_service.get_sends(campaign_id, params)
end
get_email_campaign_summary_report(campaign) click to toggle source

Get a reporting summary for a campaign @param [Mixed] campaign - Campaign id or Campaign object itself @return [TrackingSummary]

# File lib/constantcontact/api.rb, line 392
def get_email_campaign_summary_report(campaign)
  campaign_id = to_id(campaign, 'Campaign')
  @campaign_tracking_service.get_summary(campaign_id)
end
get_email_campaign_unsubscribes(campaign, params = {}) click to toggle source

Get unsubscribes for a campaign @param [Mixed] campaign - Campaign id or Campaign object itself @param [Hash] params - hash of query parameters and values to append to the request.

Allowed parameters include:
limit - Specifies the number of results displayed per page of output, from 1 - 500, default = 50.
created_since - Used to retrieve a list of events since the date and time specified (in ISO-8601 format).
next - the next link returned from a previous paginated call. May only be used by itself.

@return [ResultSet<UnsubscribeActivity>] - Containing a results array of UnsubscribeActivity

# File lib/constantcontact/api.rb, line 383
def get_email_campaign_unsubscribes(campaign, params = {})
  campaign_id = to_id(campaign, 'Campaign')
  @campaign_tracking_service.get_unsubscribes(campaign_id, params)
end
get_email_campaigns(params = {}) click to toggle source

Get a set of campaigns @param [Mixed] params - hash of query parameters and values to append to the request.

Allowed parameters include:
limit - Specifies the number of results displayed per page of output, from 1 - 500, default = 50.
modified_since - ISO-8601 formatted timestamp.
next - the next link returned from a previous paginated call. May only be used by itself.
email - the contact by email address to retrieve information for

@return [ResultSet<Campaign>]

# File lib/constantcontact/api.rb, line 195
def get_email_campaigns(params = {})
  @email_marketing_service.get_campaigns(params)
end
get_event(event) click to toggle source

Get an event @param [Event] event - event id or object to be retrieved @return [Event]

# File lib/constantcontact/api.rb, line 574
def get_event(event)
  @event_spot_service.get_event(event)
end
get_event_fee(event, fee) click to toggle source

Get an event fee @param [Event] event - Event fee corresponds to @param [EventFee] fee - Fee to retrieve @return [EventFee]

# File lib/constantcontact/api.rb, line 623
def get_event_fee(event, fee)
  @event_spot_service.get_fee(event, fee)
end
get_event_fees(event) click to toggle source

Get a list of event fees @param [Event] event - Event to get fees of @return [<Array>EventFee]

# File lib/constantcontact/api.rb, line 614
def get_event_fees(event)
  @event_spot_service.get_fees(event)
end
get_event_item(event_id, item_id) click to toggle source

Get an individual event item @param [Integer] event_id - id of event to retrieve item for @param [Integer] item_id - id of item to be retrieved @return [EventItem]

# File lib/constantcontact/api.rb, line 684
def get_event_item(event_id, item_id)
  @event_spot_service.get_event_item(event_id, item_id)
end
get_event_item_attribute(event_id, item_id, attribute_id) click to toggle source

Get an individual event item attribute @param [Integer] event_id - id of event to retrieve item for @param [Integer] item_id - id of item to retrieve attribute for @param [Integer] attribute_id - id of attribute to be retrieved @return [EventItemAttribute]

# File lib/constantcontact/api.rb, line 730
def get_event_item_attribute(event_id, item_id, attribute_id)
  @event_spot_service.get_event_item_attribute(event_id, item_id, attribute_id)
end
get_event_item_attributes(event_id, item_id) click to toggle source

Get an array of attributes for an individual event item @param [Integer] event_id - event id to retrieve item for @param [Integer] item_id - event item id to retrieve attributes for @return [Array<EventItemAttribute>]

# File lib/constantcontact/api.rb, line 720
def get_event_item_attributes(event_id, item_id)
  @event_spot_service.get_event_item_attributes(event_id, item_id)
end
get_event_items(event_id) click to toggle source

Get an array of event items for an individual event @param [Integer] event_id - event id to retrieve items for @return [Array<EventItem>]

# File lib/constantcontact/api.rb, line 675
def get_event_items(event_id)
  @event_spot_service.get_event_items(event_id)
end
get_event_registrant(event, registrant) click to toggle source

Get an event registrant @param [Event] event - Event registrant corresponds to @param [Registrant] registrant - registrant details @return [Registrant]

# File lib/constantcontact/api.rb, line 667
def get_event_registrant(event, registrant)
  @event_spot_service.get_registrant(event, registrant)
end
get_event_registrants(event) click to toggle source

Get a set of event registrants @param [Event] event - Event fee corresponds to @return [ResultSet<Registrant>]

# File lib/constantcontact/api.rb, line 658
def get_event_registrants(event)
  @event_spot_service.get_registrants(event)
end
get_events() click to toggle source

Get a list of events @return [ResultSet<Event>]

# File lib/constantcontact/api.rb, line 566
def get_events()
  @event_spot_service.get_events()
end
get_library_file(file_id) click to toggle source

Retrieve a MyLibrary file using the file_id path parameter @param [String] file_id - Specifies the MyLibrary file for which to retrieve information @return [LibraryFile]

# File lib/constantcontact/api.rb, line 927
def get_library_file(file_id)
  @library_service.get_library_file(file_id)
end
get_library_files(params = {}) click to toggle source

Retrieve a collection of Library files in the Constant Contact account @param [Hash] params - hash of query parameters and values to append to the request.

Allowed parameters include:
type - Specifies the type of files to retrieve, valid values are : ALL, IMAGES, or DOCUMENTS
source - Specifies to retrieve files from a particular source, valid values are :
    ALL - (default) files from all sources
    MyComputer
    StockImage
    Facebook
    Instagram
    Shutterstock
    Mobile
limit -  Specifies the number of results displayed per page of output, from 1 - 1000, default = 50.

@return [ResultSet<LibraryFile>]

# File lib/constantcontact/api.rb, line 908
def get_library_files(params = {})
  @library_service.get_library_files(params)
end
get_library_files_by_folder(folder_id, params = {}) click to toggle source

Retrieves all files from a MyLibrary folder specified by the folder_id path parameter @param [String] folder_id - Specifies the folder from which to retrieve files @param [Hash] params - hash of query parameters and values to append to the request.

Allowed parameters include:
limit - Specifies the number of results displayed per page of output, from 1 - 50, default = 50.

@return [ResultSet<LibraryFile>]

# File lib/constantcontact/api.rb, line 919
def get_library_files_by_folder(folder_id, params = {})
  @library_service.get_library_files_by_folder(folder_id, params)
end
get_library_files_upload_status(file_id) click to toggle source

Retrieve the upload status for one or more MyLibrary files using the file_id path parameter; separate multiple file IDs with a comma @param [String] file_id - Specifies the files for which to retrieve upload status information @return [Array<UploadStatus>]

# File lib/constantcontact/api.rb, line 970
def get_library_files_upload_status(file_id)
  @library_service.get_library_files_upload_status(file_id)
end
get_library_folder(folder_id) click to toggle source

Retrieve a specific MyLibrary folder using the folder_id path parameter @param [String] folder_id - The ID for the folder to return @return [LibraryFolder]

# File lib/constantcontact/api.rb, line 844
def get_library_folder(folder_id)
  @library_service.get_library_folder(folder_id)
end
get_library_folders(params = {}) click to toggle source

Retrieve a list of MyLibrary folders @param [Hash] params - hash of query parameters and values to append to the request.

Allowed parameters include:
sort_by - The method to sort by, valid values are :
    CREATED_DATE - sorts by date folder was added, ascending (earliest to latest)
    CREATED_DATE_DESC - (default) sorts by date folder was added, descending (latest to earliest)
    MODIFIED_DATE - sorts by date folder was last modified, ascending (earliest to latest)
    MODIFIED_DATE_DESC - sorts by date folder was last modified, descending (latest to earliest)
    NAME - sorts alphabetically by folder name, a to z
    NAME_DESC - sorts alphabetically by folder name, z to a
limit -  Specifies the number of results displayed per page of output, from 1 - 50, default = 50.

@return [ResultSet<LibraryFolder>]

# File lib/constantcontact/api.rb, line 828
def get_library_folders(params = {})
  @library_service.get_library_folders(params)
end
get_library_info() click to toggle source

Retrieve MyLibrary usage information @return [LibrarySummary]

# File lib/constantcontact/api.rb, line 811
def get_library_info()
  @library_service.get_library_info()
end
get_library_trash(params = {}) click to toggle source

Retrieve all files in the Trash folder @param [Hash] params - hash of query parameters and values to append to the request.

Allowed parameters include:
type - Specifies the type of files to retrieve, valid values are : ALL, IMAGES, or DOCUMENTS
sort_by - The method to sort by, valid values are :
    ADDED_DATE - sorts by date folder was added, ascending (earliest to latest)
    ADDED_DATE_DESC - (default) sorts by date folder was added, descending (latest to earliest)
    MODIFIED_DATE - sorts by date folder was last modified, ascending (earliest to latest)
    MODIFIED_DATE_DESC - sorts by date folder was last modified, descending (latest to earliest)
    NAME - sorts alphabetically by file name, a to z
    NAME_DESC - sorts alphabetically by file name, z to a
    SIZE - sorts by file size, smallest to largest
    SIZE_DESC - sorts by file size, largest to smallest
    DIMENSION - sorts by file dimensions (hxw), smallest to largest
    DIMENSION_DESC - sorts by file dimensions (hxw), largest to smallest
limit -  Specifies the number of results displayed per page of output, from 1 - 50, default = 50.

@return [ResultSet<LibraryFile>]

# File lib/constantcontact/api.rb, line 882
def get_library_trash(params = {})
  @library_service.get_library_trash(params)
end
get_list(list_id) click to toggle source

Get an individual list @param [Integer] list_id - Id of the list to retrieve @return [ContactList]

# File lib/constantcontact/api.rb, line 153
def get_list(list_id)
  @list_service.get_list(list_id)
end
get_lists(params = {}) click to toggle source

Get lists @param [Hash] params - hash of query parameters and values to append to the request.

Allowed parameters include:
- modified_since - ISO-8601 formatted timestamp.

@return [Array<ContactList>] Array of ContactList objects

# File lib/constantcontact/api.rb, line 145
def get_lists(params = {})
  @list_service.get_lists(params)
end
get_promocode(event_id, promocode_id) click to toggle source

Get an individual promocode @param [Integer] event_id - id of event to retrieve item for @param [Integer] promocode_id - id of item to be retrieved @return [Promocode]

# File lib/constantcontact/api.rb, line 777
def get_promocode(event_id, promocode_id)
  @event_spot_service.get_promocode(event_id, promocode_id)
end
get_promocodes(event_id) click to toggle source

Get an array of promocodes for an individual event @param [Integer] event_id - event id to retrieve promocodes for @return [Array<Promocode>]

# File lib/constantcontact/api.rb, line 768
def get_promocodes(event_id)
  @event_spot_service.get_promocodes(event_id)
end
get_verified_email_addresses(status = nil) click to toggle source

Get verified addresses for the account @param [String] status - status to filter query results by @return [Array<VerifiedEmailAddress>] an array of email addresses

# File lib/constantcontact/api.rb, line 49
def get_verified_email_addresses(status = nil)
  params = {}
  params['status'] = status if status
  @account_service.get_verified_email_addresses(params)
end
move_library_files(folder_id, file_id) click to toggle source

Move one or more MyLibrary files to a different folder in the user's account specify the destination folder using the folder_id path parameter. @param [String] folder_id - Specifies the destination MyLibrary folder to which the files will be moved @param [String] file_id - Specifies the files to move, in a string of comma separated file ids (e.g. 8,9) @return [Array<MoveResults>]

# File lib/constantcontact/api.rb, line 980
def move_library_files(folder_id, file_id)
  @library_service.move_library_files(folder_id, file_id)
end
publish_event(event) click to toggle source

Publish an event @param [Event] event - Event to publish @return [Event]

# File lib/constantcontact/api.rb, line 598
def publish_event(event)
  @event_spot_service.publish_event(event)
end
send_email_campaign_test(campaign, test_send) click to toggle source

Send a test send of a campaign @param [Mixed] campaign - Campaign id or Campaign object itself @param [TestSend] test_send - test send details @return [TestSend]

# File lib/constantcontact/api.rb, line 299
def send_email_campaign_test(campaign, test_send)
  campaign_id = to_id(campaign, 'Campaign')
  @campaign_schedule_service.send_test(campaign_id, test_send)
end
update_contact(contact, action_by_visitor = false) click to toggle source

Update an individual contact @param [Contact] contact - Contact to update @param [Boolean] action_by_visitor - if the action is being taken by the visitor @return [Contact]

# File lib/constantcontact/api.rb, line 133
def update_contact(contact, action_by_visitor = false)
  params = {}
  params['action_by'] = 'ACTION_BY_VISITOR' if action_by_visitor
  @contact_service.update_contact(contact, params)
end
update_email_campaign(campaign) click to toggle source

Update a specific campaign @param [Campaign] campaign - Campaign to be updated @return [Campaign] - updated campaign

# File lib/constantcontact/api.rb, line 237
def update_email_campaign(campaign)
  @email_marketing_service.update_campaign(campaign)
end
update_email_campaign_schedule(campaign, schedule) click to toggle source

Update a specific schedule associated with a given campaign @param [Mixed] campaign - Campaign id or Campaign object itself @param [Schedule] schedule - Schedule to be updated @return [Schedule]

# File lib/constantcontact/api.rb, line 277
def update_email_campaign_schedule(campaign, schedule)
  campaign_id = to_id(campaign, 'Campaign')
  @campaign_schedule_service.update_schedule(campaign_id, schedule)
end
update_event(event) click to toggle source

Update an event @param [Event|Hash] event - Event details stored in an object that responds to to_json and has an :id attribute @return [Event]

# File lib/constantcontact/api.rb, line 590
def update_event(event)
  @event_spot_service.update_event(event)
end
update_event_fee(event, fee) click to toggle source

Update an event fee @param [Event] event - Event fee corresponds to @param [EventFee] fee - Fee details @return [EventFee]

# File lib/constantcontact/api.rb, line 641
def update_event_fee(event, fee)
  @event_spot_service.update_fee(event, fee)
end
update_event_item(event_id, event_item) click to toggle source

Update a specific event item for an event @param [Integer] event_id - id of event associated with the event item @param [EventItem] event_item - event item to be updated @return [EventItem]

# File lib/constantcontact/api.rb, line 711
def update_event_item(event_id, event_item)
  @event_spot_service.update_event_item(event_id, event_item)
end
update_event_item_attribute(event_id, item_id, event_item_attribute) click to toggle source

Update a specific event item attribute for an event item @param [Integer] event_id - id of event associated with the event item @param [Integer] item_id - id of event item associated with the event item attribute @param [EventItemAttribute] event_item_attribute - event item to be updated @return [EventItemAttribute]

# File lib/constantcontact/api.rb, line 760
def update_event_item_attribute(event_id, item_id, event_item_attribute)
  @event_spot_service.update_event_item_attribute(event_id, item_id, event_item_attribute)
end
update_library_file(file) click to toggle source

Update information for a specific MyLibrary file @param [LibraryFile] file - Library File to be updated @return [LibraryFile]

# File lib/constantcontact/api.rb, line 951
def update_library_file(file)
  @library_service.update_library_file(file)
end
update_library_folder(folder) click to toggle source

Update a specific MyLibrary folder @param [LibraryFolder] folder - MyLibrary folder to be updated @return [LibraryFolder]

# File lib/constantcontact/api.rb, line 852
def update_library_folder(folder)
  @library_service.update_library_folder(folder)
end
update_list(list) click to toggle source

Update a contact list @param [ContactList] list - ContactList to update @return [ContactList]

# File lib/constantcontact/api.rb, line 169
def update_list(list)
  @list_service.update_list(list)
end
update_promocode(event_id, promocode) click to toggle source

Update a specific promocode for an event @param [Integer] event_id - id of event associated with the promocode @param [Promocode] promocode - promocode to be updated @return [Promocode]

# File lib/constantcontact/api.rb, line 804
def update_promocode(event_id, promocode)
  @event_spot_service.update_promocode(event_id, promocode)
end

Private Instance Methods

determine_param(param) click to toggle source

Append the limit parameter, if the value is an integer @param [String] param - parameter value @return [Hash] the parameters as a hash object

# File lib/constantcontact/api.rb, line 1011
def determine_param(param)
  params = {}
  if param
    param = param.to_s
    if param[0, 1] == '?'
      hash_params = CGI::parse(param[1..-1])
      params = Hash[*hash_params.collect {|key, value| [key, value.first] }.flatten]
    else
      params['limit'] = param
    end
  end
  params
end
to_id(item, class_name) click to toggle source

Get the id of object, or attempt to convert the argument to an int @param [Mixed] item - object or a numeric value @param [String] class_name - class name to test the given object against @raise IllegalArgumentException - if the item is not an instance of the class name given, or cannot be converted to a numeric value @return [Integer]

# File lib/constantcontact/api.rb, line 995
def to_id(item, class_name)
  item_id = nil
  if item.is_a?(Integer)
    item_id = item
  elsif item.class.to_s.split('::').last == class_name
    item_id = item.id
  else
    raise Exceptions::IllegalArgumentException.new(sprintf(Util::Config.get('errors.id_or_object'), class_name))
  end
  item_id
end