Class: Amocrm::Resources::EntityLinks

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

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ EntityLinks

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

Parameters:



161
162
163
# File 'lib/amocrm/resources/entity_links.rb', line 161

def initialize(client:)
  @client = client
end

Instance Method Details

Link entities (bulk).



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

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

Link entities for a specific entity.

Parameters:

Returns:

See Also:



66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/amocrm/resources/entity_links.rb', line 66

def link_by_entity(entity_id, params)
  parsed, options = Amocrm::EntityLinkLinkByEntityParams.dump_request(params)
  entity_type =
    parsed.delete(:entity_type) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  @client.request(
    method: :post,
    path: ["api/v4/%1$s/%2$s/link", entity_type, entity_id],
    body: parsed[:body],
    model: Amocrm::Models::EntityLinkLinkByEntityResponse,
    options: options
  )
end

#list(entity_type, filter: nil, request_options: {}) ⇒ Amocrm::Models::EntityLinkListResponse::EntityLinksResponse, Amocrm::Models::EntityLinkListResponse::Problem

Get list of linked entities (bulk).



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

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

#list_by_entity(entity_id, entity_type:, request_options: {}) ⇒ Amocrm::Models::EntityLinkListByEntityResponse::EntityLinksResponse, Amocrm::Models::EntityLinkListByEntityResponse::Problem

Get links for a specific entity.



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

def list_by_entity(entity_id, params)
  parsed, options = Amocrm::EntityLinkListByEntityParams.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/%2$s/links", entity_type, entity_id],
    model: Amocrm::Models::EntityLinkListByEntityResponse,
    options: options
  )
end

Unlink entities (bulk).



117
118
119
120
121
122
123
124
125
126
# File 'lib/amocrm/resources/entity_links.rb', line 117

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

Unlink entities for a specific entity.



143
144
145
146
147
148
149
150
151
152
153
154
155
156
# File 'lib/amocrm/resources/entity_links.rb', line 143

def unlink_by_entity(entity_id, params)
  parsed, options = Amocrm::EntityLinkUnlinkByEntityParams.dump_request(params)
  entity_type =
    parsed.delete(:entity_type) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  @client.request(
    method: :post,
    path: ["api/v4/%1$s/%2$s/unlink", entity_type, entity_id],
    body: parsed[:body],
    model: Amocrm::Models::EntityLinkUnlinkByEntityResponse,
    options: options
  )
end