Class: Sentdm::Resources::Contacts
- Inherits:
-
Object
- Object
- Sentdm::Resources::Contacts
- Defined in:
- lib/sentdm/resources/contacts.rb
Overview
Create, update, and manage customer contact lists
Instance Method Summary collapse
-
#create(phone_number: nil, test_mode: nil, idempotency_key: nil, request_options: {}) ⇒ Sentdm::Models::APIResponseContact
Some parameter documentations has been truncated, see Models::ContactCreateParams for more details.
-
#delete(id, body:, request_options: {}) ⇒ nil
Dissociates a contact from the authenticated customer.
-
#initialize(client:) ⇒ Contacts
constructor
private
A new instance of Contacts.
-
#list(page:, page_size:, channel: nil, phone: nil, search: nil, request_options: {}) ⇒ Sentdm::Models::ContactListResponse
Retrieves a paginated list of contacts for the authenticated customer.
-
#retrieve(id, request_options: {}) ⇒ Sentdm::Models::APIResponseContact
Retrieves a specific contact by their unique identifier.
-
#update(id, default_channel: nil, opt_out: nil, test_mode: nil, idempotency_key: nil, request_options: {}) ⇒ Sentdm::Models::APIResponseContact
Some parameter documentations has been truncated, see Models::ContactUpdateParams for more details.
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.
158 159 160 |
# File 'lib/sentdm/resources/contacts.rb', line 158 def initialize(client:) @client = client end |
Instance Method Details
#create(phone_number: nil, test_mode: nil, idempotency_key: nil, request_options: {}) ⇒ Sentdm::Models::APIResponseContact
Some parameter documentations has been truncated, see Models::ContactCreateParams for more details.
Creates a new contact by phone number and associates it with the authenticated customer.
26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/sentdm/resources/contacts.rb', line 26 def create(params = {}) parsed, = Sentdm::ContactCreateParams.dump_request(params) header_params = {idempotency_key: "idempotency-key"} @client.request( method: :post, path: "v3/contacts", headers: parsed.slice(*header_params.keys).transform_keys(header_params), body: parsed.except(*header_params.keys), model: Sentdm::APIResponseContact, options: ) end |
#delete(id, body:, request_options: {}) ⇒ nil
Dissociates a contact from the authenticated customer. Inherited contacts cannot be deleted.
143 144 145 146 147 148 149 150 151 152 153 |
# File 'lib/sentdm/resources/contacts.rb', line 143 def delete(id, params) parsed, = Sentdm::ContactDeleteParams.dump_request(params) @client.request( method: :delete, path: ["v3/contacts/%1$s", id], headers: {"content-type" => "*/*"}, body: parsed[:body], model: NilClass, options: ) end |
#list(page:, page_size:, channel: nil, phone: nil, search: nil, request_options: {}) ⇒ Sentdm::Models::ContactListResponse
Retrieves a paginated list of contacts for the authenticated customer. Supports filtering by search term, channel, or phone number.
117 118 119 120 121 122 123 124 125 126 127 |
# File 'lib/sentdm/resources/contacts.rb', line 117 def list(params) parsed, = Sentdm::ContactListParams.dump_request(params) query = Sentdm::Internal::Util.encode_query_params(parsed) @client.request( method: :get, path: "v3/contacts", query: query.transform_keys(page_size: "pageSize"), model: Sentdm::Models::ContactListResponse, options: ) end |
#retrieve(id, request_options: {}) ⇒ Sentdm::Models::APIResponseContact
Retrieves a specific contact by their unique identifier. Returns detailed contact information including phone formats, available channels, and opt-out status.
52 53 54 55 56 57 58 59 |
# File 'lib/sentdm/resources/contacts.rb', line 52 def retrieve(id, params = {}) @client.request( method: :get, path: ["v3/contacts/%1$s", id], model: Sentdm::APIResponseContact, options: params[:request_options] ) end |
#update(id, default_channel: nil, opt_out: nil, test_mode: nil, idempotency_key: nil, request_options: {}) ⇒ Sentdm::Models::APIResponseContact
Some parameter documentations has been truncated, see Models::ContactUpdateParams for more details.
Updates a contact’s default channel and/or opt-out status. Inherited contacts cannot be updated.
84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/sentdm/resources/contacts.rb', line 84 def update(id, params = {}) parsed, = Sentdm::ContactUpdateParams.dump_request(params) header_params = {idempotency_key: "idempotency-key"} @client.request( method: :patch, path: ["v3/contacts/%1$s", id], headers: parsed.slice(*header_params.keys).transform_keys(header_params), body: parsed.except(*header_params.keys), model: Sentdm::APIResponseContact, options: ) end |