Class: Unit::Resource::RecurringPaymentResource

Inherits:
BaseResource
  • Object
show all
Defined in:
lib/unit/api_resources/recurring_payment_resource.rb

Class Method Summary collapse

Methods inherited from BaseResource

file_response_handler, response_handler

Class Method Details

.create_recurring_payment(request) ⇒ UnitResponse, UnitError

Create a new recurring payment by calling Unit’s API

Parameters:

  • request (CreateRecurringCreditAchPaymentRequest, CreateRecurringDebitAchPaymentRequest, CreateRecurringCreditBookPaymentRequest)

Returns:



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

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

.disable_recurring_payment(recurring_payment_id) ⇒ UnitResponse, UnitError

Disable a new recurring payment by calling Unit’s API

Parameters:

  • recurring_payment_id (String)

Returns:



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

def disable_recurring_payment(recurring_payment_id)
  response = HttpHelper.post("#{api_url}/recurring-payments/#{recurring_payment_id}/disable", headers: headers)
  response_handler(response)
end

.enable_recurring_payment(recurring_payment_id) ⇒ UnitResponse, UnitError

Enable a new recurring payment by calling Unit’s API

Parameters:

  • recurring_payment_id (String)

Returns:



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

def enable_recurring_payment(recurring_payment_id)
  response = HttpHelper.post("#{api_url}/recurring-payments/#{recurring_payment_id}/enable", headers: headers)
  response_handler(response)
end

.get_recurring_payment(recurring_payment_id) ⇒ UnitResponse, UnitError

Get a new recurring payment by calling Unit’s API

Parameters:

  • recurring_payment_id (String)

Returns:



48
49
50
51
# File 'lib/unit/api_resources/recurring_payment_resource.rb', line 48

def get_recurring_payment(recurring_payment_id)
  response = HttpHelper.get("#{api_url}/recurring-payments/#{recurring_payment_id}", headers: headers)
  response_handler(response)
end

.list_recurring_payment(params = {}) ⇒ UnitResponse, UnitError

List a new recurring payment by calling Unit’s API

Parameters:

  • request (ListRecurringPaymentParams)

Returns:



40
41
42
43
# File 'lib/unit/api_resources/recurring_payment_resource.rb', line 40

def list_recurring_payment(params = {})
  response = HttpHelper.get("#{api_url}/recurring-payments", params: params.to_hash, headers: headers)
  response_handler(response)
end