Class: Textmagic::REST::Contacts

Inherits:
ListResource show all
Defined in:
lib/textmagic-ruby/rest/contacts.rb

Instance Method Summary collapse

Methods inherited from ListResource

#initialize, #inspect

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

#create(params = {}) ⇒ Object

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

The following params keys are supported:

first_name
last_name
phone

Contact’s phone number. Required.

email
company_name
country

2-letter ISO country code.

lists

String of Lists separated by commas to assign contact. Required.

Example:

@contact = client.contacts.create {:phone => '9999999', :lists => '123, 456'}


42
43
44
# File 'lib/textmagic-ruby/rest/contacts.rb', line 42

def create(params={})
  super params
end

#delete(uid) ⇒ Object

Delete contact by ID. Returns true if success.

uid

Contact ID. Required.

Example:

r = client.contacts.delete 987


113
114
115
# File 'lib/textmagic-ruby/rest/contacts.rb', line 113

def delete(uid)
  super uid
end

#get(uid) ⇒ Object

Get contact by ID. Returns Contact object.

uid

Contact ID. Required.

Example:

@contact = client.contacts.get 987


14
15
16
# File 'lib/textmagic-ruby/rest/contacts.rb', line 14

def get(uid)
  super uid
end

#list(params = {}) ⇒ Object

Get all user contacts. Returns PaginateResource object, contains array of Contact objects.

The following params keys are supported:

search

If true then search contacts using query, ids and/or group_id. Defaults false.

page

Fetch specified results page. Defaults 1

limit

How many results on page. Defaults 10

shared

Should contacts in shared lists to be included. Defaults 0

ids

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

list_id

Find contact by List ID. Using with search=true.

query

Find contact by specified search query. Using with search=true..

Example:

@contacts = client.contacts.list


70
71
72
# File 'lib/textmagic-ruby/rest/contacts.rb', line 70

def list(params={})
  super params
end

#lists(uid, params = {}) ⇒ Object

Fetch lists which contact belongs to. Returns PaginateResource object, contains array of List objects.

uid

Contact ID. Required.

The following params keys are supported:

page

Fetch specified results page. Defaults 1

limit

How many results on page. Defaults 10

Example:

@contact = client.contacts.lists 123


133
134
135
136
# File 'lib/textmagic-ruby/rest/contacts.rb', line 133

def lists(uid, params={})
  response = @client.get "#{@path}/#{uid}/lists", params
  PaginateResource.new "#{@path}", @client, response, Textmagic::REST::List
end

#update(uid, params = {}) ⇒ Object

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

uid

Contact ID. Required.

The following params keys are supported:

first_name
last_name
phone

Contact’s phone number. Required.

email
company_name
country

2-letter ISO country code.

lists

String of Lists separated by commas to assign contact. Required.

Example:

@contact = client.contacts.update 123, {:phone => '9999999', :lists => '123, 456'}


100
101
102
# File 'lib/textmagic-ruby/rest/contacts.rb', line 100

def update(uid, params={})
  super uid, params
end