Class: Amocrm::Resources::Contacts

Inherits:
Object
  • Object
show all
Defined in:
lib/amocrm/resources/contacts.rb

Instance Method Summary collapse

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.

Parameters:



155
156
157
# File 'lib/amocrm/resources/contacts.rb', line 155

def initialize(client:)
  @client = client
end

Instance Method Details

#create(body:, request_options: {}) ⇒ Amocrm::Models::ContactCreateResponse::ContactCreateResponse, Amocrm::Models::ContactCreateResponse::Problem

Create contacts.



16
17
18
19
20
21
22
23
24
25
# File 'lib/amocrm/resources/contacts.rb', line 16

def create(params)
  parsed, options = Amocrm::ContactCreateParams.dump_request(params)
  @client.request(
    method: :post,
    path: "api/v4/contacts",
    body: parsed[:body],
    model: Amocrm::Models::ContactCreateResponse,
    options: options
  )
end

#get_by_id(id, with: nil, request_options: {}) ⇒ Amocrm::Models::ContactGetByIDResponse::Contact, Amocrm::Models::ContactGetByIDResponse::Problem

Get a contact by id.

Parameters:

  • id (Integer)
  • with (String)

    Expand related entities; comma-separated values

  • request_options (Amocrm::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



94
95
96
97
98
99
100
101
102
103
104
# File 'lib/amocrm/resources/contacts.rb', line 94

def get_by_id(id, params = {})
  parsed, options = Amocrm::ContactGetByIDParams.dump_request(params)
  query = Amocrm::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: ["api/v4/contacts/%1$s", id],
    query: query,
    model: Amocrm::Models::ContactGetByIDResponse,
    options: options
  )
end

#list(filter: nil, limit: nil, order: nil, page: nil, query: nil, with: nil, request_options: {}) ⇒ Amocrm::Models::ContactListResponse::ContactListResponse, Amocrm::Models::ContactListResponse::Problem

Get a list of contacts (pagination, sorting, filtering).

Parameters:

  • filter (Object)

    Filtering parameters

  • limit (Integer)

    Pagination limit

  • order (Object)

    Sorting, e.g. order=asc

  • page (Integer)

    Pagination page

  • query (String, Integer)

    Search by query string or id

  • with (String)

    Expand related entities; comma-separated values

  • request_options (Amocrm::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



69
70
71
72
73
74
75
76
77
78
79
# File 'lib/amocrm/resources/contacts.rb', line 69

def list(params = {})
  parsed, options = Amocrm::ContactListParams.dump_request(params)
  query = Amocrm::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: "api/v4/contacts",
    query: query,
    model: Amocrm::Models::ContactListResponse,
    options: options
  )
end

#update(body:, request_options: {}) ⇒ Amocrm::Models::ContactUpdateResponse::ContactUpdateResponse, Amocrm::Models::ContactUpdateResponse::Problem

Update contacts (batch).



37
38
39
40
41
42
43
44
45
46
# File 'lib/amocrm/resources/contacts.rb', line 37

def update(params)
  parsed, options = Amocrm::ContactUpdateParams.dump_request(params)
  @client.request(
    method: :patch,
    path: "api/v4/contacts",
    body: parsed[:body],
    model: Amocrm::Models::ContactUpdateResponse,
    options: options
  )
end

#update_by_id(id, _embedded: nil, created_at: nil, created_by: nil, custom_fields_values: nil, first_name: nil, last_name: nil, name: nil, responsible_user_id: nil, tags_to_add: nil, tags_to_delete: nil, updated_at: nil, updated_by: nil, request_options: {}) ⇒ Amocrm::Models::ContactUpdateByIDResponse::ContactUpdateResponse, Amocrm::Models::ContactUpdateByIDResponse::Problem

Update a contact by id.

Parameters:

Returns:

See Also:



141
142
143
144
145
146
147
148
149
150
# File 'lib/amocrm/resources/contacts.rb', line 141

def update_by_id(id, params = {})
  parsed, options = Amocrm::ContactUpdateByIDParams.dump_request(params)
  @client.request(
    method: :patch,
    path: ["api/v4/contacts/%1$s", id],
    body: parsed,
    model: Amocrm::Models::ContactUpdateByIDResponse,
    options: options
  )
end