Method: BaseCRM::ContactsService#where

Defined in:
lib/basecrm/services/contacts_service.rb

#where(options = {}) ⇒ Array<Contact>

Retrieve all contacts

get ‘/contacts’

Returns all contacts available to the user according to the parameters provided

Parameters:

  • options (Hash) (defaults to: {})

    Search options

Options Hash (options):

  • :"address[city]" (String)

    City name.

  • :"address[country]" (String)

    Country name.

  • :"address[postal_code]" (String)

    Zip code or equivalent

  • :contact_id (Integer)

    The unique identifier of the organization that the contact belongs to.

  • :email (String)

    Email address of the contact.

  • :first_name (String)

    First name of the contact.

  • :ids (String)

    Comma-separated list of the IDs for the contacts you want to be returned in your request.

  • :is_organization (Boolean)

    Indicates whether or not this contact refers to an organization or an individual.

  • :last_name (String)

    Last name of the contact.

  • :name (String)

    Name of the contact.

  • :page (Integer) — default: 1

    The page number to start from. Page numbering is 1-based and omitting the ‘page` parameter will return the first page.

  • :per_page (Integer) — default: 25

    The number of records to return per page. Default limit is 25 and maximum number that can be returned is 100.

  • :sort_by (String) — default: last_name:asc

    A field to sort by. Default ordering is ascending. If you want to change the sort order to descending, append ‘:desc` to the field e.g. `sort_by=last_name:desc`.

Returns:

  • (Array<Contact>)

    The list of Contacts for the first page, unless otherwise specified.



42
43
44
45
46
# File 'lib/basecrm/services/contacts_service.rb', line 42

def where(options = {})
  _, _, root = @client.get("/contacts", options)

  root[:items].map{ |item| Contact.new(item[:data]) }
end