Class: Amocrm::Resources::Companies

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

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Companies

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

Parameters:



151
152
153
# File 'lib/amocrm/resources/companies.rb', line 151

def initialize(client:)
  @client = client
end

Instance Method Details

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

Create companies.



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

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

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

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

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

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

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

Parameters:

  • filter (Object)

    Filtering parameters

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

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

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

Update companies (batch).



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

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

#update_by_id(id, _embedded: nil, created_at: nil, created_by: nil, custom_fields_values: nil, name: nil, responsible_user_id: nil, tags_to_add: nil, tags_to_delete: nil, updated_at: nil, updated_by: nil, request_options: {}) ⇒ Amocrm::Models::CompanyUpdateByIDResponse::CompanyUpdateResponse, Amocrm::Models::CompanyUpdateByIDResponse::Problem

Update a company by id.

Parameters:

Returns:

See Also:



137
138
139
140
141
142
143
144
145
146
# File 'lib/amocrm/resources/companies.rb', line 137

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