Class: SurgeAPI::Resources::Contacts
- Inherits:
-
Object
- Object
- SurgeAPI::Resources::Contacts
- Defined in:
- lib/surge_api/resources/contacts.rb
Instance Method Summary collapse
-
#create(account_id, phone_number:, email: nil, first_name: nil, last_name: nil, metadata: 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, 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.
124 125 126 |
# File 'lib/surge_api/resources/contacts.rb', line 124 def initialize(client:) @client = client end |
Instance Method Details
#create(account_id, phone_number:, email: nil, first_name: nil, last_name: nil, metadata: nil, request_options: {}) ⇒ SurgeAPI::Models::Contact
Creates a new Contact object.
27 28 29 30 31 32 33 34 35 36 |
# File 'lib/surge_api/resources/contacts.rb', line 27 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.
109 110 111 112 113 114 115 116 117 118 119 |
# File 'lib/surge_api/resources/contacts.rb', line 109 def list(account_id, params = {}) parsed, = SurgeAPI::ContactListParams.dump_request(params) @client.request( method: :get, path: ["accounts/%1$s/contacts", account_id], query: parsed, page: SurgeAPI::Internal::Cursor, model: SurgeAPI::Contact, options: ) end |
#retrieve(id, request_options: {}) ⇒ SurgeAPI::Models::Contact
Retrieves a Contact object.
49 50 51 52 53 54 55 56 |
# File 'lib/surge_api/resources/contacts.rb', line 49 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, 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.
80 81 82 83 84 85 86 87 88 89 |
# File 'lib/surge_api/resources/contacts.rb', line 80 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 |