Class: Amocrm::Resources::CustomFields

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

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ CustomFields

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

Parameters:



177
178
179
# File 'lib/amocrm/resources/custom_fields.rb', line 177

def initialize(client:)
  @client = client
end

Instance Method Details

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

Create custom fields.



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

def create(entity_type, params)
  parsed, options = Amocrm::CustomFieldCreateParams.dump_request(params)
  @client.request(
    method: :post,
    path: ["api/v4/%1$s/custom_fields", entity_type],
    body: parsed[:body],
    model: Amocrm::Models::CustomFieldCreateResponse,
    options: options
  )
end

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

Delete a custom field by id.

Parameters:

Returns:

See Also:



85
86
87
88
89
90
91
92
93
94
95
96
97
# File 'lib/amocrm/resources/custom_fields.rb', line 85

def delete_by_id(id, params)
  parsed, options = Amocrm::CustomFieldDeleteByIDParams.dump_request(params)
  entity_type =
    parsed.delete(:entity_type) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  @client.request(
    method: :delete,
    path: ["api/v4/%1$s/custom_fields/%2$s", entity_type, id],
    model: Amocrm::Models::CustomFieldDeleteByIDResponse,
    options: options
  )
end

#get_by_id(id, entity_type:, request_options: {}) ⇒ Amocrm::Models::CustomFieldGetByIDResponse::CustomField, Amocrm::Models::CustomFieldGetByIDResponse::Problem

Get custom field by id.

Parameters:

Returns:

See Also:



110
111
112
113
114
115
116
117
118
119
120
121
122
# File 'lib/amocrm/resources/custom_fields.rb', line 110

def get_by_id(id, params)
  parsed, options = Amocrm::CustomFieldGetByIDParams.dump_request(params)
  entity_type =
    parsed.delete(:entity_type) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  @client.request(
    method: :get,
    path: ["api/v4/%1$s/custom_fields/%2$s", entity_type, id],
    model: Amocrm::Models::CustomFieldGetByIDResponse,
    options: options
  )
end

#list(entity_type, limit: nil, page: nil, request_options: {}) ⇒ Amocrm::Models::CustomFieldListResponse::CustomFieldListResponse, Amocrm::Models::CustomFieldListResponse::Problem

Get custom fields list.

Parameters:

  • entity_type (String)
  • limit (Integer)
  • page (Integer)
  • request_options (Amocrm::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



62
63
64
65
66
67
68
69
70
71
72
# File 'lib/amocrm/resources/custom_fields.rb', line 62

def list(entity_type, params = {})
  parsed, options = Amocrm::CustomFieldListParams.dump_request(params)
  query = Amocrm::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: ["api/v4/%1$s/custom_fields", entity_type],
    query: query,
    model: Amocrm::Models::CustomFieldListResponse,
    options: options
  )
end

#update(entity_type, body:, request_options: {}) ⇒ Object, Amocrm::Models::CustomFieldUpdateResponse::Problem

Update custom fields (batch).

Parameters:

Returns:

See Also:



39
40
41
42
43
44
45
46
47
48
# File 'lib/amocrm/resources/custom_fields.rb', line 39

def update(entity_type, params)
  parsed, options = Amocrm::CustomFieldUpdateParams.dump_request(params)
  @client.request(
    method: :patch,
    path: ["api/v4/%1$s/custom_fields", entity_type],
    body: parsed[:body],
    model: Amocrm::Models::CustomFieldUpdateResponse,
    options: options
  )
end

#update_by_id(id, entity_type:, code: nil, enums: nil, group_id: nil, is_deletable: nil, is_multiple: nil, is_required: nil, is_visible: nil, name: nil, settings: nil, sort: nil, type: nil, request_options: {}) ⇒ Object, Amocrm::Models::CustomFieldUpdateByIDResponse::Problem

Update a custom field by id.

Parameters:

  • id (Integer)

    Path param

  • entity_type (String)

    Path param

  • code (String)

    Body param

  • enums (Array<Object>)

    Body param

  • group_id (Integer)

    Body param

  • is_deletable (Boolean)

    Body param

  • is_multiple (Boolean)

    Body param

  • is_required (Boolean)

    Body param

  • is_visible (Boolean)

    Body param

  • name (String)

    Body param

  • settings (Object)

    Body param

  • sort (Integer)

    Body param

  • type (String)

    Body param

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

Returns:

See Also:



159
160
161
162
163
164
165
166
167
168
169
170
171
172
# File 'lib/amocrm/resources/custom_fields.rb', line 159

def update_by_id(id, params)
  parsed, options = Amocrm::CustomFieldUpdateByIDParams.dump_request(params)
  entity_type =
    parsed.delete(:entity_type) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  @client.request(
    method: :patch,
    path: ["api/v4/%1$s/custom_fields/%2$s", entity_type, id],
    body: parsed,
    model: Amocrm::Models::CustomFieldUpdateByIDResponse,
    options: options
  )
end