Class: Zavudev::Resources::Contacts

Inherits:
Object
  • Object
show all
Defined in:
lib/zavudev/resources/contacts.rb

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Contacts

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Contacts.

Parameters:



99
100
101
# File 'lib/zavudev/resources/contacts.rb', line 99

def initialize(client:)
  @client = client
end

Instance Method Details

#list(cursor: nil, limit: nil, phone_number: nil, request_options: {}) ⇒ Zavudev::Internal::Cursor<Zavudev::Models::Contact>

List contacts with their communication channels.

Parameters:

  • cursor (String)
  • limit (Integer)
  • phone_number (String)
  • request_options (Zavudev::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/zavudev/resources/contacts.rb', line 63

def list(params = {})
  parsed, options = Zavudev::ContactListParams.dump_request(params)
  query = Zavudev::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: "v1/contacts",
    query: query.transform_keys(phone_number: "phoneNumber"),
    page: Zavudev::Internal::Cursor,
    model: Zavudev::Contact,
    options: options
  )
end

#retrieve(contact_id, request_options: {}) ⇒ Zavudev::Models::Contact

Get contact

Parameters:

Returns:

See Also:



16
17
18
19
20
21
22
23
# File 'lib/zavudev/resources/contacts.rb', line 16

def retrieve(contact_id, params = {})
  @client.request(
    method: :get,
    path: ["v1/contacts/%1$s", contact_id],
    model: Zavudev::Contact,
    options: params[:request_options]
  )
end

#retrieve_by_phone(phone_number, request_options: {}) ⇒ Zavudev::Models::Contact

Get contact by phone number

Parameters:

  • phone_number (String)

    E.164 phone number.

  • request_options (Zavudev::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



87
88
89
90
91
92
93
94
# File 'lib/zavudev/resources/contacts.rb', line 87

def retrieve_by_phone(phone_number, params = {})
  @client.request(
    method: :get,
    path: ["v1/contacts/phone/%1$s", phone_number],
    model: Zavudev::Contact,
    options: params[:request_options]
  )
end

#update(contact_id, default_channel: nil, metadata: nil, request_options: {}) ⇒ Zavudev::Models::Contact

Update contact

Parameters:

Returns:

See Also:



40
41
42
43
44
45
46
47
48
49
# File 'lib/zavudev/resources/contacts.rb', line 40

def update(contact_id, params = {})
  parsed, options = Zavudev::ContactUpdateParams.dump_request(params)
  @client.request(
    method: :patch,
    path: ["v1/contacts/%1$s", contact_id],
    body: parsed,
    model: Zavudev::Contact,
    options: options
  )
end