Class: Amocrm::Resources::CatalogElements

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

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ CatalogElements

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

Parameters:



144
145
146
# File 'lib/amocrm/resources/catalog_elements.rb', line 144

def initialize(client:)
  @client = client
end

Instance Method Details

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

Create catalog elements.



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

def create(catalog_id, params)
  parsed, options = Amocrm::CatalogElementCreateParams.dump_request(params)
  @client.request(
    method: :post,
    path: ["api/v4/catalogs/%1$s/elements", catalog_id],
    body: parsed[:body],
    model: Amocrm::Models::CatalogElementCreateResponse,
    options: options
  )
end

#get_by_id(id, catalog_id:, with: nil, request_options: {}) ⇒ Amocrm::Models::CatalogElementGetByIDResponse::CatalogElement, Amocrm::Models::CatalogElementGetByIDResponse::Problem

Get catalog element by id.

Parameters:

  • id (Integer)

    Path param

  • catalog_id (Integer)

    Path param

  • with (String)

    Query param: Additional data to include (comma-separated).

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

Returns:

See Also:



91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
# File 'lib/amocrm/resources/catalog_elements.rb', line 91

def get_by_id(id, params)
  parsed, options = Amocrm::CatalogElementGetByIDParams.dump_request(params)
  query = Amocrm::Internal::Util.encode_query_params(parsed)
  catalog_id =
    parsed.delete(:catalog_id) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  @client.request(
    method: :get,
    path: ["api/v4/catalogs/%1$s/elements/%2$s", catalog_id, id],
    query: query,
    model: Amocrm::Models::CatalogElementGetByIDResponse,
    options: options
  )
end

#list(catalog_id, filter: nil, limit: nil, page: nil, query: nil, request_options: {}) ⇒ Amocrm::Models::CatalogElementListResponse::CatalogElementListResponse, Amocrm::Models::CatalogElementListResponse::Problem

Get catalog elements list.

Parameters:

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

Returns:

See Also:



64
65
66
67
68
69
70
71
72
73
74
# File 'lib/amocrm/resources/catalog_elements.rb', line 64

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

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

Update catalog elements (batch).



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

def update(catalog_id, params)
  parsed, options = Amocrm::CatalogElementUpdateParams.dump_request(params)
  @client.request(
    method: :patch,
    path: ["api/v4/catalogs/%1$s/elements", catalog_id],
    body: parsed[:body],
    model: Amocrm::Models::CatalogElementUpdateResponse,
    options: options
  )
end

#update_by_id(id, catalog_id:, custom_fields_values: nil, name: nil, request_id: nil, request_options: {}) ⇒ Amocrm::Models::CatalogElementUpdateByIDResponse::CatalogElementUpdateResponse, Amocrm::Models::CatalogElementUpdateByIDResponse::Problem

Update catalog element by id.

Parameters:

Returns:

See Also:



126
127
128
129
130
131
132
133
134
135
136
137
138
139
# File 'lib/amocrm/resources/catalog_elements.rb', line 126

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