Class: Amocrm::Resources::Roles

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

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Roles

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

Parameters:



120
121
122
# File 'lib/amocrm/resources/roles.rb', line 120

def initialize(client:)
  @client = client
end

Instance Method Details

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

Create roles (batch).



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

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

#delete_by_id(id, request_options: {}) ⇒ Amocrm::Models::RoleDeleteByIDResponse::EmptyResponse, Amocrm::Models::RoleDeleteByIDResponse::Problem

Delete role by id.



61
62
63
64
65
66
67
68
# File 'lib/amocrm/resources/roles.rb', line 61

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

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

Get role by id.

Parameters:

Returns:

See Also:



81
82
83
84
85
86
87
88
89
90
91
# File 'lib/amocrm/resources/roles.rb', line 81

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

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

Get roles 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/roles.rb', line 39

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

#update_by_id(id, name: nil, request_id: nil, rights: nil, request_options: {}) ⇒ Amocrm::Models::RoleUpdateByIDResponse::Role, Amocrm::Models::RoleUpdateByIDResponse::Problem

Update role by id.

Parameters:

Returns:

See Also:



106
107
108
109
110
111
112
113
114
115
# File 'lib/amocrm/resources/roles.rb', line 106

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