Purpose
This WS is designed to change equipment availability status
Specification
Authorization
Verify the validity of access token
Return (401, 'Invalid access token') in case of validation fails
Verify that token is not expired
in case of error - return (401, 'Invalid access token')
Check user scopes in order to perform this action (scope = 'equipment:write')
Return (403, 'Your scope does not allow to access this resource. Missing allowances: equipment:write') in case of invalid scope(s)
If BLOCK_UNVERIFIED_PARTY_USERS is true, then check party's data match following condition: verification_status != NOT_VERIFIED or (verification_status = NOT_VERIFIED and updated_at > current_date - UNVERIFIED_PARTY_PERIOD_DAYS_ALLOWED):
in case not match - return 403 ("Access denied. Party is not verified")
If BLOCK_DECEASED_PARTY_USERS is true, check that party is not deceased (party_verification record does not equal to: dracs_death_verification_status = VERIFIED and dracs_death_verification_reason = MANUAL_CONFIRMED):
in case of error - return 403 ("Access denied. Party is deceased")
Validate equipment
Check that equipment with such ID exists in the system (is_active = true)
in case of error - return 404
Validate legal entity
Check that requested equipment belongs to the same legal entity as user
Extract
client_id
from tokenCheck that
equipments.legal_entity_id
==client_id
in case of error - return 403 (“Forbidden“)
Validate status
It is allowed to change availability status only for active equipment
Get equipment by id
Check equipment status (
status
== active)in case of error - return 409 ('Invalid status. Equipment must be active')
Validate request
Validate request by schema and return 422 error code with the list of validation errors in case of fails
Availability_status
Validate $.availability_status is one of the following (dictionary:
equipment_availability_statuses
)in case of error - return 422 ("value is not allowed in enum")
Validate $.availability_status is not equal to the current value of availability_status
in case of error - return 409 ("equipment already has {availability_status} availability_status")
Service logic
Update equipment record with the following:
availability_status = $.availability_status
updated_at = current datetime
updated_by = user_id from token