Class: Textmagic::REST::Lists
- Inherits:
-
ListResource
- Object
- ListResource
- Textmagic::REST::Lists
- Defined in:
- lib/textmagic-ruby/rest/lists.rb
Instance Method Summary collapse
-
#contacts(uid, params = {}) ⇒ Object
Fetch user contacts by given list id.
-
#create(params = {}) ⇒ Object
Create new List.
-
#delete(uid) ⇒ Object
Delete list by ID.
-
#delete_contacts(uid, params = {}) ⇒ Object
Unassign contacts from the specified list.
-
#get(uid) ⇒ Object
Get list by ID.
-
#list(params = {}) ⇒ Object
Get all user lists.
-
#put_contacts(uid, params = {}) ⇒ Object
Assign contacts to the specified list.
-
#update(uid, params = {}) ⇒ Object
Updates the existing List for the given unique id.
Methods inherited from ListResource
Methods included from Utils
#key_map, #resource, #to_camel_case, #to_underscore_case
Constructor Details
This class inherits a constructor from Textmagic::REST::ListResource
Instance Method Details
#contacts(uid, params = {}) ⇒ Object
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
110 111 112 113 |
# File 'lib/textmagic-ruby/rest/lists.rb', line 110 def contacts(uid, params={}) response = @client.get "#{@path}/#{uid}/contacts", params PaginateResource.new "#{@path}", @client, response, Textmagic::REST::Contact end |
#create(params = {}) ⇒ Object
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'}
32 33 34 |
# File 'lib/textmagic-ruby/rest/lists.rb', line 32 def create(params={}) super params end |
#delete(uid) ⇒ Object
Delete list by ID. Returns true if success.
- uid
-
List ID. Required.
Example:
r = client.lists.delete 987
89 90 91 |
# File 'lib/textmagic-ruby/rest/lists.rb', line 89 def delete(uid) super uid end |
#delete_contacts(uid, params = {}) ⇒ Object
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'}
129 130 131 |
# File 'lib/textmagic-ruby/rest/lists.rb', line 129 def delete_contacts(uid, params={}) response = @client.delete "#{@path}/#{uid}/contacts", params end |
#get(uid) ⇒ Object
Get list by ID. Returns List object.
- uid
-
List ID. Required.
Example:
@list = client.lists.get 987
14 15 16 |
# File 'lib/textmagic-ruby/rest/lists.rb', line 14 def get(uid) super uid end |
#list(params = {}) ⇒ Object
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
56 57 58 |
# File 'lib/textmagic-ruby/rest/lists.rb', line 56 def list(params={}) super params end |
#put_contacts(uid, params = {}) ⇒ Object
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'}
147 148 149 150 |
# File 'lib/textmagic-ruby/rest/lists.rb', line 147 def put_contacts(uid, params={}) response = @client.put "#{@path}/#{uid}/contacts", params @instance_class.new "#{@path}", @client, response end |
#update(uid, params = {}) ⇒ Object
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'}
76 77 78 |
# File 'lib/textmagic-ruby/rest/lists.rb', line 76 def update(uid, params={}) super uid, params end |