Class: Zavudev::Resources::Contacts::Channels

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

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Channels

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 Channels.

Parameters:



130
131
132
# File 'lib/zavudev/resources/contacts/channels.rb', line 130

def initialize(client:)
  @client = client
end

Instance Method Details

#add(contact_id, channel:, identifier:, country_code: nil, is_primary: nil, label: nil, request_options: {}) ⇒ Zavudev::Models::Contacts::ChannelAddResponse

Add a new communication channel to an existing contact.

Parameters:

  • contact_id (String)
  • channel (Symbol, Zavudev::Models::Contacts::ChannelAddParams::Channel)

    Channel type.

  • identifier (String)

    Channel identifier (phone number in E.164 format or email address).

  • country_code (String)

    ISO country code for phone numbers.

  • is_primary (Boolean)

    Whether this should be the primary channel for its type.

  • label (String)

    Optional label for the channel.

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

Returns:

See Also:



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

def add(contact_id, params)
  parsed, options = Zavudev::Contacts::ChannelAddParams.dump_request(params)
  @client.request(
    method: :post,
    path: ["v1/contacts/%1$s/channels", contact_id],
    body: parsed,
    model: Zavudev::Models::Contacts::ChannelAddResponse,
    options: options
  )
end

#remove(channel_id, contact_id:, request_options: {}) ⇒ nil

Remove a communication channel from a contact. Cannot remove the last channel.

Parameters:

  • channel_id (String)

    Channel ID.

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

Returns:

  • (nil)

See Also:



86
87
88
89
90
91
92
93
94
95
96
97
98
# File 'lib/zavudev/resources/contacts/channels.rb', line 86

def remove(channel_id, params)
  parsed, options = Zavudev::Contacts::ChannelRemoveParams.dump_request(params)
  contact_id =
    parsed.delete(:contact_id) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  @client.request(
    method: :delete,
    path: ["v1/contacts/%1$s/channels/%2$s", contact_id, channel_id],
    model: NilClass,
    options: options
  )
end

#set_primary(channel_id, contact_id:, request_options: {}) ⇒ Zavudev::Models::Contacts::ChannelSetPrimaryResponse

Set a channel as the primary channel for its type.

Parameters:

  • channel_id (String)

    Channel ID.

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

Returns:

See Also:



113
114
115
116
117
118
119
120
121
122
123
124
125
# File 'lib/zavudev/resources/contacts/channels.rb', line 113

def set_primary(channel_id, params)
  parsed, options = Zavudev::Contacts::ChannelSetPrimaryParams.dump_request(params)
  contact_id =
    parsed.delete(:contact_id) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  @client.request(
    method: :post,
    path: ["v1/contacts/%1$s/channels/%2$s/primary", contact_id, channel_id],
    model: Zavudev::Models::Contacts::ChannelSetPrimaryResponse,
    options: options
  )
end

#update(channel_id, contact_id:, label: nil, metadata: nil, verified: nil, request_options: {}) ⇒ Zavudev::Models::Contacts::ChannelUpdateResponse

Update a contact’s channel properties.

Parameters:

  • channel_id (String)

    Path param: Channel ID.

  • contact_id (String)

    Path param

  • label (String, nil)

    Body param: Optional label for the channel. Set to null to clear.

  • metadata (Hash{Symbol=>String})

    Body param

  • verified (Boolean)

    Body param: Whether the channel is verified.

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

Returns:

See Also:



26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/zavudev/resources/contacts/channels.rb', line 26

def update(channel_id, params)
  parsed, options = Zavudev::Contacts::ChannelUpdateParams.dump_request(params)
  contact_id =
    parsed.delete(:contact_id) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  @client.request(
    method: :patch,
    path: ["v1/contacts/%1$s/channels/%2$s", contact_id, channel_id],
    body: parsed,
    model: Zavudev::Models::Contacts::ChannelUpdateResponse,
    options: options
  )
end