Class: Unit::Resource::ApiTokenResource
- Inherits:
-
BaseResource
- Object
- BaseResource
- Unit::Resource::ApiTokenResource
- Defined in:
- lib/unit/api_resources/api_token_resource.rb
Class Method Summary collapse
-
.create_customer_token(request) ⇒ UnitResponse, UnitError
Create customer token by calling Unit’s API.
-
.create_org_api_token(request) ⇒ UnitResponse, UnitError
Create a new Org API api_token by calling Unit’s API.
-
.create_token_verification(request) ⇒ UnitResponse, UnitError
Create customer token verification by calling Unit’s API.
-
.list_org_tokens(user_id) ⇒ UnitResponse, UnitError
Get Org API tokens by calling Unit’s API.
-
.revoke_org_token(user_id, token_id) ⇒ UnitResponse, UnitError
Revoke Org API api_token by calling Unit’s API.
Methods inherited from BaseResource
file_response_handler, response_handler
Class Method Details
.create_customer_token(request) ⇒ UnitResponse, UnitError
Create customer token by calling Unit’s API
42 43 44 45 46 |
# File 'lib/unit/api_resources/api_token_resource.rb', line 42 def create_customer_token(request) payload = request.to_json_api response = HttpHelper.post("#{api_url}/customers/#{request.customer_id}/token", headers: headers, body: payload) response_handler(response) end |
.create_org_api_token(request) ⇒ UnitResponse, UnitError
Create a new Org API api_token by calling Unit’s API
16 17 18 19 20 |
# File 'lib/unit/api_resources/api_token_resource.rb', line 16 def create_org_api_token(request) payload = request.to_json_api response = HttpHelper.post("#{api_url}/users/#{request.user_id}/api-tokens", body: payload, headers: headers) response_handler(response) end |
.create_token_verification(request) ⇒ UnitResponse, UnitError
Create customer token verification by calling Unit’s API
51 52 53 54 55 |
# File 'lib/unit/api_resources/api_token_resource.rb', line 51 def create_token_verification(request) payload = request.to_json_api response = HttpHelper.post("#{api_url}/customers/#{request.customer_id}/token/verification", body: payload, headers: headers) response_handler(response) end |
.list_org_tokens(user_id) ⇒ UnitResponse, UnitError
Get Org API tokens by calling Unit’s API
25 26 27 28 |
# File 'lib/unit/api_resources/api_token_resource.rb', line 25 def list_org_tokens(user_id) response = HttpHelper.get("#{api_url}/users/#{user_id}/api-tokens", headers: headers) response_handler(response) end |
.revoke_org_token(user_id, token_id) ⇒ UnitResponse, UnitError
Revoke Org API api_token by calling Unit’s API
34 35 36 37 |
# File 'lib/unit/api_resources/api_token_resource.rb', line 34 def revoke_org_token(user_id, token_id) response = HttpHelper.delete("#{api_url}/users/#{user_id}/api-tokens/#{token_id}", headers: headers) response_handler(response) end |