Class: Unit::Resource::TransactionResource

Inherits:
BaseResource show all
Defined in:
lib/unit/api_resources/transaction_resource.rb

Class Method Summary collapse

Methods inherited from BaseResource

file_response_handler, response_handler

Class Method Details

.get_transaction(params) ⇒ UnitResponse, UnitError

Get a transaction by id by calling Unit’s API

Parameters:

  • params (GetTransactionParams)

Returns:



16
17
18
19
# File 'lib/unit/api_resources/transaction_resource.rb', line 16

def get_transaction(params)
  response = HttpHelper.get("#{api_url}/accounts/#{params.}/transactions/#{params.transaction_id}", params: params.to_hash, headers: headers)
  response_handler(response)
end

.list_transactions(params = nil) ⇒ UnitResponse, UnitError

Get transactions by calling Unit’s API

Parameters:

  • params (ListTransactionParams) (defaults to: nil)

Returns:



24
25
26
27
# File 'lib/unit/api_resources/transaction_resource.rb', line 24

def list_transactions(params = nil)
  response = HttpHelper.get("#{api_url}/transactions", params: params.to_hash, headers: headers)
  response_handler(response)
end

.update_tags(request) ⇒ UnitResponse, UnitError

Update a transaction by calling Unit’s API

Parameters:

  • request (PatchTagsRequest)

Returns:



32
33
34
35
36
# File 'lib/unit/api_resources/transaction_resource.rb', line 32

def update_tags(request)
  payload = request.to_json_api
  response = HttpHelper.patch("#{api_url}/accounts/#{request.}/transactions/#{request.transaction_id}", body: payload, headers: headers)
  response_handler(response)
end

.update_transaction(request) ⇒ UnitResponse, UnitError

Update a transaction by calling Unit’s API

Parameters:

  • request (PatchBookTransactionRequest, PatchChargeTransactionRequest)

Returns:



41
42
43
44
45
# File 'lib/unit/api_resources/transaction_resource.rb', line 41

def update_transaction(request)
  payload = request.to_json_api
  response = HttpHelper.patch("#{api_url}/transactions/#{request.transaction_id}", body: payload, headers: headers)
  response_handler(response)
end