Class: Amocrm::Resources::Sources

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

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Sources

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

Parameters:



160
161
162
# File 'lib/amocrm/resources/sources.rb', line 160

def initialize(client:)
  @client = client
end

Instance Method Details

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

Create sources (batch).



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

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

#delete(body:, request_options: {}) ⇒ Amocrm::Models::SourceDeleteResponse::EmptyResponse, Amocrm::Models::SourceDeleteResponse::Problem

Delete sources (batch).



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

def delete(params)
  parsed, options = Amocrm::SourceDeleteParams.dump_request(params)
  @client.request(
    method: :delete,
    path: "api/v4/sources",
    body: parsed[:body],
    model: Amocrm::Models::SourceDeleteResponse,
    options: options
  )
end

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

Delete source by id.



101
102
103
104
105
106
107
108
# File 'lib/amocrm/resources/sources.rb', line 101

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

#get_by_id(id, request_options: {}) ⇒ Amocrm::Models::SourceGetByIDResponse::Source, Amocrm::Models::SourceGetByIDResponse::Problem

Get source by id.

Parameters:

Returns:

See Also:



120
121
122
123
124
125
126
127
# File 'lib/amocrm/resources/sources.rb', line 120

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

#list(filter: nil, request_options: {}) ⇒ Amocrm::Models::SourceListResponse::SourceListResponse, Amocrm::Models::SourceListResponse::Problem

Get sources list.



58
59
60
61
62
63
64
65
66
67
68
# File 'lib/amocrm/resources/sources.rb', line 58

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

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

Update sources (batch).



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

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

#update_by_id(id, default: nil, external_id: nil, name: nil, origin_code: nil, pipeline_id: nil, request_id: nil, services: nil, request_options: {}) ⇒ Amocrm::Models::SourceUpdateByIDResponse::SourceUpdateResponse, Amocrm::Models::SourceUpdateByIDResponse::Problem

Update source by id.

Parameters:

  • id (Integer)
  • default (Boolean)
  • external_id (String)
  • name (String)
  • origin_code (String, nil)
  • pipeline_id (Integer, nil)
  • request_id (String)
  • services (Array<Object>, Array<String>)
  • request_options (Amocrm::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



146
147
148
149
150
151
152
153
154
155
# File 'lib/amocrm/resources/sources.rb', line 146

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