Class: Zavudev::Resources::Contacts

Inherits:
Object
  • Object
show all
Defined in:
lib/zavudev/resources/contacts.rb,
lib/zavudev/resources/contacts/channels.rb,
sig/zavudev/resources/contacts.rbs,
sig/zavudev/resources/contacts/channels.rbs

Defined Under Namespace

Classes: Channels

Instance Attribute Summary collapse

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:



196
197
198
199
# File 'lib/zavudev/resources/contacts.rb', line 196

def initialize(client:)
  @client = client
  @channels = Zavudev::Resources::Contacts::Channels.new(client: client)
end

Instance Attribute Details

#channels ⇒ Zavudev::Resources::Contacts::Channels (readonly)



7
8
9
# File 'lib/zavudev/resources/contacts.rb', line 7

def channels
  @channels
end

Instance Method Details

#create(channels:, display_name: nil, metadata: nil, request_options: {}) ⇒ Zavudev::Models::Contact

Create a new contact with one or more communication channels.

Parameters:

Returns:

See Also:



24
25
26
27
28
29
30
31
32
33
# File 'lib/zavudev/resources/contacts.rb', line 24

def create(params)
  parsed, options = Zavudev::ContactCreateParams.dump_request(params)
  @client.request(
    method: :post,
    path: "v1/contacts",
    body: parsed,
    model: Zavudev::Contact,
    options: options
  )
end

#delete(contact_id, request_options: {}) ⇒ nil

Permanently delete a contact and its communication channels. Implements right-to-erasure obligations under GDPR Art. 17, Ley 19.628 (Chile) Art. 12, CCPA § 1798.105, and LGPD Art. 18.VI. The contact, its channels, and any associated agent flow sessions and conversation threads are removed. Past message records and broadcast delivery logs are retained for billing/audit but no longer reference the deleted contact.

Parameters:

Returns:

  • (nil)

See Also:



135
136
137
138
139
140
141
142
# File 'lib/zavudev/resources/contacts.rb', line 135

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

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

Some parameter documentations has been truncated, see Models::ContactListParams for more details.

List contacts with their communication channels.

Parameters:

  • cursor (String) —

    Opaque cursor from a previous response's nextCursor. Do not construct it.

  • limit (Integer)
  • phone_number (String) —

    Exact match on the contact's primary phone number, in E.164.

  • search (String) —

    Free-text match over the contact's name (displayName and the WhatsApp profile

  • tag (Array<String>) —

    Tag name. Repeatable: ?tag=vip&tag=chile returns contacts carrying every t

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

Returns:

See Also:



107
108
109
110
111
112
113
114
115
116
117
118
# File 'lib/zavudev/resources/contacts.rb', line 107

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

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

Some parameter documentations has been truncated, see Models::ContactMergeParams for more details.

Merge a source contact into this contact. All channels from the source contact will be moved to the target contact, and the source contact will be marked as merged.

Parameters:

  • contact_id (String)
  • source_contact_id (String) —

    ID of the contact to merge into the target contact. The source contact will be m

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

Returns:

See Also:



162
163
164
165
166
167
168
169
170
171
# File 'lib/zavudev/resources/contacts.rb', line 162

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

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

Get contact

Parameters:

Returns:

See Also:



45
46
47
48
49
50
51
52
# File 'lib/zavudev/resources/contacts.rb', line 45

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:



184
185
186
187
188
189
190
191
# File 'lib/zavudev/resources/contacts.rb', line 184

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, display_name: nil, metadata: nil, request_options: {}) ⇒ Zavudev::Models::Contact

Some parameter documentations has been truncated, see Models::ContactUpdateParams for more details.

Update contact

Parameters:

  • contact_id (String)
  • default_channel (Symbol, Zavudev::Models::ContactUpdateParams::DefaultChannel, nil) —

    Preferred channel for this contact. Set to null to clear.

  • display_name (String, nil) —

    Human-readable name for this contact. Set to null to clear it and fall back to t

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

Returns:

See Also:



74
75
76
77
78
79
80
81
82
83
# File 'lib/zavudev/resources/contacts.rb', line 74

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