Class: Amocrm::Resources::CustomerTransactions

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

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ CustomerTransactions

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

Parameters:



111
112
113
# File 'lib/amocrm/resources/customer_transactions.rb', line 111

def initialize(client:)
  @client = client
end

Instance Method Details

#create(customer_id, body:, accrue_bonus: nil, request_options: {}) ⇒ Amocrm::Models::CustomerTransactionCreateResponse::CustomerTransactionCreateResponse, Amocrm::Models::CustomerTransactionCreateResponse::Problem

Create transactions for a customer.

Parameters:

Returns:

See Also:



21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/amocrm/resources/customer_transactions.rb', line 21

def create(customer_id, params)
  parsed, options = Amocrm::CustomerTransactionCreateParams.dump_request(params)
  query = Amocrm::Internal::Util.encode_query_params(parsed.except(:body))
  @client.request(
    method: :post,
    path: ["api/v4/customers/%1$s/transactions", customer_id],
    query: query,
    body: parsed[:body],
    model: Amocrm::Models::CustomerTransactionCreateResponse,
    options: options
  )
end

#delete_by_id(transaction_id, customer_id:, request_options: {}) ⇒ Object, Amocrm::Models::CustomerTransactionDeleteByIDResponse::Problem

Delete a transaction for a customer.

Parameters:

  • transaction_id (Integer)
  • customer_id (Integer)
  • request_options (Amocrm::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/amocrm/resources/customer_transactions.rb', line 69

def delete_by_id(transaction_id, params)
  parsed, options = Amocrm::CustomerTransactionDeleteByIDParams.dump_request(params)
  customer_id =
    parsed.delete(:customer_id) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  @client.request(
    method: :delete,
    path: ["api/v4/customers/%1$s/transactions/%2$s", customer_id, transaction_id],
    model: Amocrm::Models::CustomerTransactionDeleteByIDResponse,
    options: options
  )
end

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

Get list of transactions.

Parameters:

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

Returns:

See Also:



46
47
48
49
50
51
52
53
54
55
56
# File 'lib/amocrm/resources/customer_transactions.rb', line 46

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

#list_by_customer(customer_id, filter: nil, limit: nil, page: nil, request_options: {}) ⇒ Amocrm::Models::CustomerTransactionListByCustomerResponse::CustomerTransactionListResponse, Amocrm::Models::CustomerTransactionListByCustomerResponse::Problem

Get list of transactions for a customer.

Parameters:

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

Returns:

See Also:



96
97
98
99
100
101
102
103
104
105
106
# File 'lib/amocrm/resources/customer_transactions.rb', line 96

def list_by_customer(customer_id, params = {})
  parsed, options = Amocrm::CustomerTransactionListByCustomerParams.dump_request(params)
  query = Amocrm::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: ["api/v4/customers/%1$s/transactions", customer_id],
    query: query,
    model: Amocrm::Models::CustomerTransactionListByCustomerResponse,
    options: options
  )
end