Class: Zavudev::Resources::Broadcasts::Contacts

Inherits:
Object
  • Object
show all
Defined in:
lib/zavudev/resources/broadcasts/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:



91
92
93
# File 'lib/zavudev/resources/broadcasts/contacts.rb', line 91

def initialize(client:)
  @client = client
end

Instance Method Details

#add(broadcast_id, contacts:, request_options: {}) ⇒ Zavudev::Models::Broadcasts::ContactAddResponse

Add contacts to a broadcast in batch. Maximum 1000 contacts per request.

Parameters:

Returns:

See Also:



50
51
52
53
54
55
56
57
58
59
# File 'lib/zavudev/resources/broadcasts/contacts.rb', line 50

def add(broadcast_id, params)
  parsed, options = Zavudev::Broadcasts::ContactAddParams.dump_request(params)
  @client.request(
    method: :post,
    path: ["v1/broadcasts/%1$s/contacts", broadcast_id],
    body: parsed,
    model: Zavudev::Models::Broadcasts::ContactAddResponse,
    options: options
  )
end

#list(broadcast_id, cursor: nil, limit: nil, status: nil, request_options: {}) ⇒ Zavudev::Internal::Cursor<Zavudev::Models::BroadcastContact>

List contacts in a broadcast with optional status filter.

Parameters:

Returns:

See Also:



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

def list(broadcast_id, params = {})
  parsed, options = Zavudev::Broadcasts::ContactListParams.dump_request(params)
  query = Zavudev::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: ["v1/broadcasts/%1$s/contacts", broadcast_id],
    query: query,
    page: Zavudev::Internal::Cursor,
    model: Zavudev::BroadcastContact,
    options: options
  )
end

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

Remove a contact from a broadcast in draft status.

Parameters:

  • contact_id (String)

    Broadcast contact ID (not the global contact ID)

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

Returns:

  • (nil)

See Also:



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

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