Class: PyrxSynapse::ContactsClient
- Inherits:
-
Object
- Object
- PyrxSynapse::ContactsClient
- Defined in:
- lib/pyrx_synapse/contacts_client.rb
Overview
Contact management sub-client.
Instance Method Summary collapse
-
#delete(external_id) ⇒ Object
Delete a contact by external ID.
-
#get(contact_id) ⇒ Object
Get a single contact by ID.
-
#initialize(client) ⇒ ContactsClient
constructor
A new instance of ContactsClient.
-
#list(search: nil, page: nil, per_page: nil, sort_by: nil, sort_order: nil) ⇒ Object
List contacts with optional filtering, pagination, and sorting.
-
#update(external_id, data) ⇒ Object
Update a contact by external ID.
Constructor Details
#initialize(client) ⇒ ContactsClient
Returns a new instance of ContactsClient.
6 7 8 |
# File 'lib/pyrx_synapse/contacts_client.rb', line 6 def initialize(client) @client = client end |
Instance Method Details
#delete(external_id) ⇒ Object
Delete a contact by external ID.
36 37 38 39 |
# File 'lib/pyrx_synapse/contacts_client.rb', line 36 def delete(external_id) @client.request(:delete, "/v1/contacts/#{external_id}") nil end |
#get(contact_id) ⇒ Object
Get a single contact by ID.
24 25 26 27 |
# File 'lib/pyrx_synapse/contacts_client.rb', line 24 def get(contact_id) raw = @client.request(:get, "/v1/contacts/#{contact_id}") Parsers.parse_contact(raw) end |
#list(search: nil, page: nil, per_page: nil, sort_by: nil, sort_order: nil) ⇒ Object
List contacts with optional filtering, pagination, and sorting.
11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/pyrx_synapse/contacts_client.rb', line 11 def list(search: nil, page: nil, per_page: nil, sort_by: nil, sort_order: nil) params = {} params["search"] = search if search params["page"] = page.to_s if page params["per_page"] = per_page.to_s if per_page params["sort_by"] = sort_by if sort_by params["sort_order"] = sort_order if sort_order raw = @client.request(:get, "/v1/contacts", params: params) Parsers.parse_contact_list(raw) end |
#update(external_id, data) ⇒ Object
Update a contact by external ID.
30 31 32 33 |
# File 'lib/pyrx_synapse/contacts_client.rb', line 30 def update(external_id, data) raw = @client.request(:patch, "/v1/contacts/#{external_id}", body: data) Parsers.parse_contact(raw) end |