Class: Unit::Resource::PaymentResource

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

Class Method Summary collapse

Methods inherited from BaseResource

file_response_handler, response_handler

Class Method Details

.create_batch_release(request) ⇒ UnitResponse, UnitError

Create a new batch release by calling Unit’s API

Parameters:

  • request (BatchReleaseRequestBuilder)

Returns:



60
61
62
63
64
# File 'lib/unit/api_resources/payment_resource.rb', line 60

def create_batch_release(request)
  payload = request.to_hash.to_json
  response = HttpHelper.post("#{api_url}/batch-releases", body: payload, headers: headers)
  response_handler(response)
end

.create_bulk_payment(request) ⇒ UnitResponse, UnitError

Create a new bulk payment by calling Unit’s API

Parameters:

  • request (BulkPaymentRequest)

Returns:



25
26
27
28
# File 'lib/unit/api_resources/payment_resource.rb', line 25

def create_bulk_payment(request)
  response = HttpHelper.post("#{api_url}/payments/bulk", body: request, headers: headers)
  response_handler(response)
end

.create_payment(request) ⇒ UnitResponse, UnitError

Create a new payment by calling Unit’s API

Parameters:

  • request (CreateAchPaymentInlineRequest, CreatePaymentLinkedRequest, CreateBookPaymentRequest, CreateWithPlaidTokenRequest, CreateWirePaymentRequest)

Returns:



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

def create_payment(request)
  payload = request.to_json_api
  response = HttpHelper.post("#{api_url}/payments", body: payload, headers: headers)
  response_handler(response)
end

.get_payment(request) ⇒ UnitResponse, UnitError

Get a payment by calling Unit’s API

Parameters:

  • request (GetRequest)

Returns:



42
43
44
45
46
# File 'lib/unit/api_resources/payment_resource.rb', line 42

def get_payment(request)
  payload = request.to_hash
  response = HttpHelper.get("#{api_url}/payments/#{request.payment_id}", params: payload, headers: headers)
  response_handler(response)
end

.list_payments(request) ⇒ UnitResponse, UnitError

List payments by calling Unit’s API

Parameters:

  • request (ListPaymentParams)

Returns:



51
52
53
54
55
# File 'lib/unit/api_resources/payment_resource.rb', line 51

def list_payments(request)
  payload = request.to_hash
  response = HttpHelper.get("#{api_url}/payments", params: payload, headers: headers)
  response_handler(response)
end

.update_payment(request) ⇒ UnitResponse, UnitError

Update a payment by calling Unit’s API

Parameters:

  • request (PatchBookPaymentRequest, PatchAchPaymentRequest)

Returns:



33
34
35
36
37
# File 'lib/unit/api_resources/payment_resource.rb', line 33

def update_payment(request)
  payload = request.to_json_api
  response = HttpHelper.patch("#{api_url}/payments/#{request.payment_id}", body: payload, headers: headers)
  response_handler(response)
end