class Textmagic::REST::Lists

Public Instance Methods

contacts(uid, params={}) click to toggle source

Fetch user contacts by given list id. An useful synonym for “contacts/search” command with provided “list_id” parameter. Returns PaginateResource object, contains array of Contact objects.

uid

List ID. Required.

The following params keys are supported:

page

Fetch specified results page. Defaults 1

limit

How many results on page. Defaults 10

Example:

@lists = client.lists.contacts 123
    # File lib/textmagic-ruby/rest/lists.rb
110 def contacts(uid, params={})
111   response = @client.get "#{@path}/#{uid}/contacts", params
112   PaginateResource.new "#{@path}", @client, response, Textmagic::REST::Contact
113 end
create(params={}) click to toggle source

Create new List. Returns List object contains id and link to new List.

The following params keys are supported:

name

List name. Required.

shared

Should this list be shared with sub-accounts. Can be 1 or 0. Defaults 0

Example:

@list = client.lists.create {:name => 'MyList'}
Calls superclass method Textmagic::REST::ListResource#create
   # File lib/textmagic-ruby/rest/lists.rb
32 def create(params={})
33   super params
34 end
delete(uid) click to toggle source

Delete list by ID. Returns true if success.

uid

List ID. Required.

Example:

r = client.lists.delete 987
Calls superclass method Textmagic::REST::ListResource#delete
   # File lib/textmagic-ruby/rest/lists.rb
89 def delete(uid)
90   super uid
91 end
delete_contacts(uid, params={}) click to toggle source

Unassign contacts from the specified list. Returns true if success.

uid

List ID. Required.

The following params keys are supported:

contacts

Contact ID(s), separated by comma.

Example:

r = client.lists.delete_contacts 123, {:contacts => '122, 1212, 12122'}
    # File lib/textmagic-ruby/rest/lists.rb
129 def delete_contacts(uid, params={})
130   response = @client.delete "#{@path}/#{uid}/contacts", params
131 end
get(uid) click to toggle source

Get list by ID. Returns List object.

uid

List ID. Required.

Example:

@list = client.lists.get 987
Calls superclass method Textmagic::REST::ListResource#get
   # File lib/textmagic-ruby/rest/lists.rb
14 def get(uid)
15   super uid
16 end
list(params={}) click to toggle source

Get all user lists. Returns PaginateResource object, contains array of List objects.

The following params keys are supported:

search

If true then search lists using `ids` and/or `query`. Defaults false.

page

Fetch specified results page. Defaults 1

limit

How many results on page. Defaults 10

ids

Find list by ID(s). Using with `search`=true.

query

Find list by specified search query. Using with `search`=true..

Example:

@lists = client.lists.list
Calls superclass method Textmagic::REST::ListResource#list
   # File lib/textmagic-ruby/rest/lists.rb
56 def list(params={})
57   super params
58 end
put_contacts(uid, params={}) click to toggle source

Assign contacts to the specified list. Returns List object contains id and link to updated List.

uid

List ID. Required.

The following params keys are supported:

contacts

Contact ID(s), separated by comma.

Example:

r = client.lists.put_contacts 123, {:contacts => '122, 1212, 12122'}
    # File lib/textmagic-ruby/rest/lists.rb
147 def put_contacts(uid, params={})
148   response = @client.put "#{@path}/#{uid}/contacts", params
149   @instance_class.new "#{@path}", @client, response
150 end
update(uid, params={}) click to toggle source

Updates the existing List for the given unique id. Returns List object contains id and link to updated List.

uid

List ID. Required.

The following params keys are supported:

name

List name. Required.

shared

Should this list be shared with sub-accounts. Can be 1 or 0. Defaults 0

Example:

@list = client.lists.update 123, {:name => 'Updated List'}
Calls superclass method Textmagic::REST::ListResource#update
   # File lib/textmagic-ruby/rest/lists.rb
76 def update(uid, params={})
77   super uid, params
78 end