ЕСОЗ - публічна документація

Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Current »

Purpose

This WS is designed to change equipment availability status

Specification

Apiary

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 token

  • Check 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

  1. Validate $.availability_status is one of the following (dictionary: DEVICE_AVAILABILITY_STATUSES)

    1. in case of error - return 422 ("value is not allowed in enum")

  2. Validate $.availability_status is not equal to the current value of availability_status

    1. in case of error - return 409 ("equipment already has {availability_status} availability_status")

Service logic

  1. Update equipment record with the following:

    1. availability_status = $.availability_status

    2. updated_at = current datetime

    3. updated_by = user_id from token

  • No labels