ndidplatform / api

NDID API
GNU Affero General Public License v3.0
27 stars 18 forks source link

[feature/rp message] Add constrain to parameters and Add callback after blockchain #83

Closed crossknight closed 3 years ago

crossknight commented 3 years ago

According to Wed. 23th Jun. 2021 meeting, I submitted two commits in this pull request as following:

  1. Add constrain to initial_salt, message, and purpose parameters.
    • initial_salt string parameter from request and message API size must be larger or equals to 24 characters. (config.saltStrLength, configurable variable like config.saltLength)
  1. Add callback calls after sent data to TM.

You can find message swagger format APIs here:

  1. POST /rp/message
  1. GET /utility/message
  1. POST /rp/message/:referenceID (since I reached the maximum number to create APIs for a free account, I will attached it as codes)
    openapi: 3.0.0
    servers:
    - url: 'https://virtserver.swaggerhub.com/ndid/rp_callback/0.1'
    info:
    version: "4.0"
    title: RP Message Callback API
    description: API that RP MUST IMPLEMENT to be called by the platform
    paths:
    '/rp/message/{reference_id}':
    post:
      summary: Update from NDID
      description: 'Update from NDID to RP, there''s been an update to the status. Note that {reference_id} is NOT automatically append to the registered callback url. This is just an example that you can register callback with reference_id as parameter'
      operationId: request_update
      parameters:
        - name: reference_id
          in: path
          description: Reference ID
          required: true
          schema:
            type: string
      responses:
        '204':
          description: Status Update Acknowledged
      requestBody:
        content:
          application/json:
            schema:
              oneOf:
                - $ref: '#/components/schemas/CallbackCreateMessageResult'
        description: Callback about message
        required: true
    components:
    schemas:
    CallbackCreateMessageResult:
      type: object
      required:
        - node_id
        - type
        - reference_id
        - message_id
        - success
      properties:
        node_id:
          type: string
        type:
          type: string
          enum:
            - create_message_result
        reference_id:
          type: string
        message_id:
          type: string
        creation_block_height:
          type: string
          description: '<CHAIN_ID>:<BLOCK_HEIGHT>'
        success:
          type: boolean
        error:
          $ref: '#/components/schemas/Error'
    Error:
      type: object
      required:
        - code
        - message
      properties:
        code:
          type: integer
        message:
          type: string