class Promoter::ContactList

Constants

API_URL

Attributes

id[R]
name[R]

Public Class Methods

all(page=1) click to toggle source
# File lib/promoter/contact_list.rb, line 14
def self.all(page=1)
  response = Request.get("#{API_URL}/?page=#{page}")
  response['results'].map {|attrs| new(attrs)}
end
contact_ids_for(contact_list_id) click to toggle source
# File lib/promoter/contact_list.rb, line 19
def self.contact_ids_for(contact_list_id)
  response = Request.get("#{API_URL}/#{contact_list_id}/contacts")
  response['results'].map {|attrs| attrs["id"]}
end
create(attributes) click to toggle source

Campaign Params Parameter Optional? Description name no The name of the campaign

# File lib/promoter/contact_list.rb, line 47
def self.create(attributes)
  response = Request.post(API_URL + "/", attributes)
  new(response)
end
new(attrs) click to toggle source
# File lib/promoter/contact_list.rb, line 9
def initialize(attrs)
  @id = attrs['id']
  @name = attrs['name']
end
remove_contact(params={}) click to toggle source
# File lib/promoter/contact_list.rb, line 24
def self.remove_contact(params={})
  contact_list_id = params[:contact_list_id]
  contact_id = params[:contact_id]
  contact_email = params[:email]

  if contact_list_id
    if contact_id
      Request.delete("#{API_URL}/#{contact_list_id}/contacts/#{contact_id}")
    elsif contact_email
      Request.post("#{API_URL}/#{contact_list_id}/remove/", {email: contact_email})
    else
      raise "Not enough information provided to remove a contact"
    end
  elsif contact_email
      Request.post("#{API_URL}/remove/", {email: contact_email})
  else
    raise "Not enough information provided to remove a contact"
  end
end