Class: SurgeAPI::Resources::Contacts
- Inherits:
-
Object
- Object
- SurgeAPI::Resources::Contacts
- Defined in:
- lib/surge_api/resources/contacts.rb,
sig/surge_api/resources/contacts.rbs
Instance Method Summary collapse
-
#create(account_id, phone_number:, email: nil, first_name: nil, last_name: nil, metadata: nil, outbound_disabled: nil, request_options: {}) ⇒ SurgeAPI::Models::Contact
Creates a new Contact object.
-
#initialize(client:) ⇒ Contacts
constructor
private
A new instance of Contacts.
-
#list(account_id, after: nil, before: nil, request_options: {}) ⇒ SurgeAPI::Internal::Cursor<SurgeAPI::Models::Contact>
Some parameter documentations has been truncated, see Models::ContactListParams for more details.
-
#retrieve(id, request_options: {}) ⇒ SurgeAPI::Models::Contact
Retrieves a Contact object.
-
#update(id, phone_number:, email: nil, first_name: nil, last_name: nil, metadata: nil, outbound_disabled: nil, request_options: {}) ⇒ SurgeAPI::Models::Contact
Updates the specified contact by setting the values of the parameters passed.
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.
129 130 131 |
# File 'lib/surge_api/resources/contacts.rb', line 129 def initialize(client:) @client = client end |
Instance Method Details
#create(account_id, phone_number:, email: nil, first_name: nil, last_name: nil, metadata: nil, outbound_disabled: nil, request_options: {}) ⇒ SurgeAPI::Models::Contact
Creates a new Contact object.
29 30 31 32 33 34 35 36 37 38 |
# File 'lib/surge_api/resources/contacts.rb', line 29 def create(account_id, params) parsed, = SurgeAPI::ContactCreateParams.dump_request(params) @client.request( method: :post, path: ["accounts/%1$s/contacts", account_id], body: parsed, model: SurgeAPI::Contact, options: ) end |
#list(account_id, after: nil, before: nil, request_options: {}) ⇒ SurgeAPI::Internal::Cursor<SurgeAPI::Models::Contact>
Some parameter documentations has been truncated, see Models::ContactListParams for more details.
List all contacts for an account with cursor-based pagination.
113 114 115 116 117 118 119 120 121 122 123 124 |
# File 'lib/surge_api/resources/contacts.rb', line 113 def list(account_id, params = {}) parsed, = SurgeAPI::ContactListParams.dump_request(params) query = SurgeAPI::Internal::Util.encode_query_params(parsed) @client.request( method: :get, path: ["accounts/%1$s/contacts", account_id], query: query, page: SurgeAPI::Internal::Cursor, model: SurgeAPI::Contact, options: ) end |
#retrieve(id, request_options: {}) ⇒ SurgeAPI::Models::Contact
Retrieves a Contact object.
51 52 53 54 55 56 57 58 |
# File 'lib/surge_api/resources/contacts.rb', line 51 def retrieve(id, params = {}) @client.request( method: :get, path: ["contacts/%1$s", id], model: SurgeAPI::Contact, options: params[:request_options] ) end |
#update(id, phone_number:, email: nil, first_name: nil, last_name: nil, metadata: nil, outbound_disabled: nil, request_options: {}) ⇒ SurgeAPI::Models::Contact
Updates the specified contact by setting the values of the parameters passed. Any parameters not provided will be left unchanged.
84 85 86 87 88 89 90 91 92 93 |
# File 'lib/surge_api/resources/contacts.rb', line 84 def update(id, params) parsed, = SurgeAPI::ContactUpdateParams.dump_request(params) @client.request( method: :patch, path: ["contacts/%1$s", id], body: parsed, model: SurgeAPI::Contact, options: ) end |