Class: Amocrm::Resources::Customers

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

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Customers

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 Customers.

Parameters:



143
144
145
# File 'lib/amocrm/resources/customers.rb', line 143

def initialize(client:)
  @client = client
end

Instance Method Details

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

Create customers.



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

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

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

Get a customer 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/customers.rb', line 94

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

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

Get a list of customers.

Parameters:

  • filter (Object)
  • limit (Integer)
  • order (Object)
  • page (Integer)
  • query (String, Integer)
  • 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/customers.rb', line 69

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

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

Update customers (batch).



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

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

#update_by_id(id, _embedded: nil, custom_fields_values: nil, main_user_id: nil, name: nil, next_date: nil, next_price: nil, periodicity: nil, responsible_user_id: nil, status_id: nil, tags_to_add: nil, tags_to_delete: nil, updated_at: nil, updated_by: nil, request_options: {}) ⇒ Amocrm::Models::CustomerUpdateByIDResponse::CustomerUpdateResponse, Amocrm::Models::CustomerUpdateByIDResponse::Problem

Update a customer by id.

Parameters:

Returns:

See Also:



129
130
131
132
133
134
135
136
137
138
# File 'lib/amocrm/resources/customers.rb', line 129

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