Class: Amocrm::Resources::CustomerSegments

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

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ CustomerSegments

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

Parameters:



110
111
112
# File 'lib/amocrm/resources/customer_segments.rb', line 110

def initialize(client:)
  @client = client
end

Instance Method Details

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

Create segments.



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

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

#delete_by_id(id, request_options: {}) ⇒ Object, Amocrm::Models::CustomerSegmentDeleteByIDResponse::Problem

Delete a segment by id.

Parameters:

Returns:

See Also:



55
56
57
58
59
60
61
62
# File 'lib/amocrm/resources/customer_segments.rb', line 55

def delete_by_id(id, params = {})
  @client.request(
    method: :delete,
    path: ["api/v4/customers/segments/%1$s", id],
    model: Amocrm::Models::CustomerSegmentDeleteByIDResponse,
    options: params[:request_options]
  )
end

#get_by_id(id, request_options: {}) ⇒ Amocrm::Models::CustomerSegmentGetByIDResponse::CustomerSegment, Amocrm::Models::CustomerSegmentGetByIDResponse::Problem

Get segment by id.



74
75
76
77
78
79
80
81
# File 'lib/amocrm/resources/customer_segments.rb', line 74

def get_by_id(id, params = {})
  @client.request(
    method: :get,
    path: ["api/v4/customers/segments/%1$s", id],
    model: Amocrm::Models::CustomerSegmentGetByIDResponse,
    options: params[:request_options]
  )
end

#list(request_options: {}) ⇒ Amocrm::Models::CustomerSegmentListResponse::CustomerSegmentListResponse, Amocrm::Models::CustomerSegmentListResponse::Problem

Get segments list.



36
37
38
39
40
41
42
43
# File 'lib/amocrm/resources/customer_segments.rb', line 36

def list(params = {})
  @client.request(
    method: :get,
    path: "api/v4/customers/segments",
    model: Amocrm::Models::CustomerSegmentListResponse,
    options: params[:request_options]
  )
end

#update_by_id(id, color: nil, custom_fields_values: nil, name: nil, request_options: {}) ⇒ Object, Amocrm::Models::CustomerSegmentUpdateByIDResponse::Problem

Update a segment by id.

Parameters:

Returns:

See Also:



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

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