Class: Amocrm::Resources::Leads

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

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Leads

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

Parameters:



178
179
180
# File 'lib/amocrm/resources/leads.rb', line 178

def initialize(client:)
  @client = client
end

Instance Method Details

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

Create leads.



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

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

#create_complex(body:, request_options: {}) ⇒ Amocrm::Models::LeadCreateComplexResponse::LeadComplexCreateResponse, Amocrm::Models::LeadCreateComplexResponse::Problem

Create leads using the complex method (supports unsorted metadata).



91
92
93
94
95
96
97
98
99
100
# File 'lib/amocrm/resources/leads.rb', line 91

def create_complex(params)
  parsed, options = Amocrm::LeadCreateComplexParams.dump_request(params)
  @client.request(
    method: :post,
    path: "api/v4/leads/complex",
    body: parsed[:body],
    model: Amocrm::Models::LeadCreateComplexResponse,
    options: options
  )
end

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

Get a lead by id.

Parameters:

  • id (Integer)
  • with (String)

    Expand related entities; comma-separated values

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

Returns:

See Also:



115
116
117
118
119
120
121
122
123
124
125
# File 'lib/amocrm/resources/leads.rb', line 115

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

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

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

Parameters:

  • filter (Object)

    Filtering parameters, see filters API

  • 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/leads.rb', line 69

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

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

Update leads (batch).



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

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

#update_by_id(id, _embedded: nil, closed_at: nil, custom_fields_values: nil, group_id: nil, loss_reason_id: nil, name: nil, pipeline_id: nil, price: nil, responsible_user_id: nil, status_id: nil, tags_to_add: nil, tags_to_delete: nil, updated_at: nil, request_options: {}) ⇒ Amocrm::Models::LeadUpdateByIDResponse::LeadUpdateResponse, Amocrm::Models::LeadUpdateByIDResponse::Problem

Update a lead by id.

Parameters:

Returns:

See Also:



164
165
166
167
168
169
170
171
172
173
# File 'lib/amocrm/resources/leads.rb', line 164

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