Class: Amocrm::Resources::Users

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

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Users

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

Parameters:



77
78
79
# File 'lib/amocrm/resources/users.rb', line 77

def initialize(client:)
  @client = client
end

Instance Method Details

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

Create users (batch).



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

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

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

Get user by id.

Parameters:

Returns:

See Also:



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

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

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

Get users list.

Parameters:

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

Returns:

See Also:



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

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