Class: Unit::Resource::AccountResource

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

Class Method Summary collapse

Methods inherited from BaseResource

file_response_handler, response_handler

Class Method Details

.activate_control_agreement(account_id) ⇒ UnitResponse, UnitError

Activate a control agreement by calling Unit’s API

Parameters:

  • account_id (String)

Returns:



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

def activate_control_agreement()
  response = HttpHelper.post("#{api_url}/accounts/#{}/activate-daca", headers: headers)
  response_handler(response)
end

.add_owners(request) ⇒ UnitResponse, UnitError

Add account owners by calling Unit’s API

Parameters:

  • request (AccountOwnersRequest)

Returns:



132
133
134
135
136
# File 'lib/unit/api_resources/account_resource.rb', line 132

def add_owners(request)
  payload = request.to_json_api
  response = HttpHelper.post("#{api_url}/accounts/#{request.}/relationships/customers", body: payload, headers: headers)
  response_handler(response)
end

.close_account(request) ⇒ UnitResponse, UnitError

Close an account by calling Unit’s API

Parameters:

  • request (CloseDepositAccountRequest)

    request

Returns:



49
50
51
52
53
# File 'lib/unit/api_resources/account_resource.rb', line 49

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

.create_account(request) ⇒ UnitResponse, UnitError

Create a new account by calling Unit’s API

Parameters:

  • request (CreateDepositAccountRequest)

    request

Returns:



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

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

.deactivate_control_agreement(account_id) ⇒ UnitResponse, UnitError

Deactivate a control agreement by calling Unit’s API

Parameters:

  • account_id (String)

Returns:



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

def deactivate_control_agreement()
  response = HttpHelper.post("#{api_url}/accounts/#{}/deactivate-daca", headers: headers)
  response_handler(response)
end

.enter_control_agreement(account_id) ⇒ UnitResponse, UnitError

Enter a control agreement by calling Unit’s API

Parameters:

  • account_id (String)

Returns:



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

def enter_control_agreement()
  response = HttpHelper.post("#{api_url}/accounts/#{}/enter-daca", headers: headers)
  response_handler(response)
end

.freeze_account(request) ⇒ UnitResponse, UnitError

Freeze an account by calling Unit’s API

Parameters:

  • request (FreezeAccountRequest)

Returns:



67
68
69
70
71
# File 'lib/unit/api_resources/account_resource.rb', line 67

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

.get_account(account_id) ⇒ UnitResponse, UnitError

Get account by calling Unit’s API

Parameters:

  • account_id (String)

Returns:



84
85
86
87
# File 'lib/unit/api_resources/account_resource.rb', line 84

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

.get_account_balance_history(params) ⇒ UnitResponse, UnitError

Get account balance history by calling Unit’s API

Parameters:

  • params (BalanceHistoryRequest)

Returns:



124
125
126
127
# File 'lib/unit/api_resources/account_resource.rb', line 124

def (params)
  response = HttpHelper.get("#{api_url}/account-end-of-day", params: params.to_hash, headers: headers)
  response_handler(response)
end

.get_deposit_products(account_id) ⇒ UnitResponse, UnitError

Get deposit products by calling Unit’s API

Parameters:

  • account_id (String)

Returns:



116
117
118
119
# File 'lib/unit/api_resources/account_resource.rb', line 116

def get_deposit_products()
  response = HttpHelper.get("#{api_url}/accounts/#{}/deposit-products", headers: headers)
  response_handler(response)
end

.limits(account_id) ⇒ UnitResponse, UnitError

Limit account by calling Unit’s API

Parameters:

  • account_id (String)

Returns:



108
109
110
111
# File 'lib/unit/api_resources/account_resource.rb', line 108

def limits()
  response = HttpHelper.get("#{api_url}/accounts/#{}/limits", headers: headers)
  response_handler(response)
end

.list_accounts(params = nil) ⇒ UnitResponse, UnitError

List accounts by calling Unit’s API

Parameters:

  • params (ListAccountParams) (defaults to: nil)
    • optional

Returns:



92
93
94
95
# File 'lib/unit/api_resources/account_resource.rb', line 92

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

.remove_owners(request) ⇒ UnitResponse, UnitError

Remove account owners by calling Unit’s API

Parameters:

  • request (AccountOwnersRequest)

Returns:



141
142
143
144
145
# File 'lib/unit/api_resources/account_resource.rb', line 141

def remove_owners(request)
  payload = request.to_json_api
  response = HttpHelper.delete("#{api_url}/accounts/#{request.}/relationships/customers", body: payload, headers: headers)
  response_handler(response)
end

.reopen_account(account_id) ⇒ UnitResponse, UnitError

Reopen an account by calling Unit’s API

Parameters:

  • account_id (String)
  • reason (String)

Returns:



59
60
61
62
# File 'lib/unit/api_resources/account_resource.rb', line 59

def ()
  response = HttpHelper.post("#{api_url}/accounts/#{}/reopen", headers: headers)
  response_handler(response)
end

.unfreeze_account(account_id) ⇒ UnitResponse, UnitError

Unfreeze an account by calling Unit’s API

Parameters:

  • account_id (String)

Returns:



76
77
78
79
# File 'lib/unit/api_resources/account_resource.rb', line 76

def ()
  response = HttpHelper.post("#{api_url}/accounts/#{}/unfreeze", headers: headers)
  response_handler(response)
end

.update_account(request) ⇒ Object

Update account by calling Unit’s API

Parameters:

  • request (PatchDepositAccountRequest)


99
100
101
102
103
# File 'lib/unit/api_resources/account_resource.rb', line 99

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