Class: Unit::Resource::AuthorizationRequestResource

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

Class Method Summary collapse

Methods inherited from BaseResource

file_response_handler, response_handler

Class Method Details

.approve(request) ⇒ UnitResponse, UnitError

Approve an authorization request by calling Unit’s API

Parameters:

  • request (ApproveRequest)

Returns:



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

def approve(request)
  payload = request.to_json_api
  response = HttpHelper.post("#{api_url}/authorization-requests/#{request.authorization_request_id}/approve", body: payload, headers: headers)
  response_handler(response)
end

.decline(request) ⇒ UnitResponse, UnitError

Decline an authorization request by calling Unit’s API

Parameters:

  • request (DeclineRequest)

Returns:



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

def decline(request)
  payload = request.to_json_api
  response = HttpHelper.post("#{api_url}/authorization-requests/#{request.authorization_request_id}/decline", body: payload, headers: headers)
  response_handler(response)
end

.get_authorization_request(request_id) ⇒ UnitResponse, UnitError

Get authorization request by calling Unit’s API

Parameters:

  • request_id (String)

Returns:



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

def get_authorization_request(request_id)
  response = HttpHelper.get("#{api_url}/authorization-requests/#{request_id}", headers: headers)
  response_handler(response)
end

.list(params = nil) ⇒ UnitResponse, UnitError

List authorization requests by calling Unit’s API

Parameters:

  • params (ListAuthorizationParams) (defaults to: nil)

Returns:



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

def list(params = nil)
  response = HttpHelper.get("#{api_url}/authorization-requests", params: params.to_hash, headers: headers)
  response_handler(response)
end