class Nylas::Contacts

Nylas Contact API

Public Instance Methods

create(identifier:, request_body:) click to toggle source

Create a contact.

@param identifier [String] Grant ID or email account in which to create the object. @param request_body [Hash] The values to create the contact with. @return [Array(Hash, String)] The created contact and API Request ID.

# File lib/nylas/resources/contacts.rb, line 44
def create(identifier:, request_body:)
  post(
    path: "#{api_uri}/v3/grants/#{identifier}/contacts",
    request_body: request_body
  )
end
destroy(identifier:, contact_id:) click to toggle source

Delete a contact.

@param identifier [String] Grant ID or email account from which to delete an object. @param contact_id [String] The id of the contact to delete. @return [Array(TrueClass, String)] True and the API Request ID for the delete operation.

# File lib/nylas/resources/contacts.rb, line 69
def destroy(identifier:, contact_id:)
  _, request_id = delete(
    path: "#{api_uri}/v3/grants/#{identifier}/contacts/#{contact_id}"
  )

  [true, request_id]
end
find(identifier:, contact_id:, query_params: nil) click to toggle source

Return a contact.

@param identifier [String] Grant ID or email account to query. @param contact_id [String] The id of the contact to return. @param query_params [Hash, nil] Query params to pass to the request. @return [Array(Hash, String)] The contact and API request ID.

# File lib/nylas/resources/contacts.rb, line 32
def find(identifier:, contact_id:, query_params: nil)
  get(
    path: "#{api_uri}/v3/grants/#{identifier}/contacts/#{contact_id}",
    query_params: query_params
  )
end
list(identifier:, query_params: nil) click to toggle source

Return all contacts.

@param identifier [String] Grant ID or email account to query. @param query_params [Hash, nil] Query params to pass to the request. @return [Array(Array(Hash), String, String)] The list of contacts, API Request ID, and next cursor.

# File lib/nylas/resources/contacts.rb, line 19
def list(identifier:, query_params: nil)
  get_list(
    path: "#{api_uri}/v3/grants/#{identifier}/contacts",
    query_params: query_params
  )
end
list_groups(identifier:, query_params: nil) click to toggle source

Return all contact groups.

@param identifier [String] Grant ID or email account to query. @param query_params [Hash, nil] Query params to pass to the request. @return [Array(Array(Hash), String, String)] The list of contact groups and API Request ID.

# File lib/nylas/resources/contacts.rb, line 82
def list_groups(identifier:, query_params: nil)
  get_list(
    path: "#{api_uri}/v3/grants/#{identifier}/contacts/groups",
    query_params: query_params
  )
end
update(identifier:, contact_id:, request_body:) click to toggle source

Update a contact.

@param identifier [String] Grant ID or email account in which to update an object. @param contact_id [String] The id of the contact to update. @param request_body [Hash] The values to update the contact with @return [Array(Hash, String)] The updated contact and API Request ID.

# File lib/nylas/resources/contacts.rb, line 57
def update(identifier:, contact_id:, request_body:)
  put(
    path: "#{api_uri}/v3/grants/#{identifier}/contacts/#{contact_id}",
    request_body: request_body
  )
end