name: user-invitation
description: Basic invitation mechanizm for user/resources
classes:
  invitations:
    - name: email
      type: string
      filter_index: true
    - name: key
      type: string
      filter_index: true
    - name: resourceID
      type: string
      filter_index: true
    - name: resourceType
      type: string
      filter_index: true
    - name: status
      type: string
      filter_index: true
    - name: details
      type: object
endpoints:
  invite:
    private: true
    description: Create invitation for a given e-mail
    inputs:
      required:
        - email
        - resourceID
        - resourceType
      properties:
        email:
          type: string
          description: User e-mail
          example: joe@mail.com
        resourceID:
          type: integer
          description: ID of the resource related to invitation
          example: 12345
        resourceType:
          type: string
          description: Type of the resource
          example: company
        details:
          type: object
          description: Invitation details inform of the object
          example: |
            {
              "company_id": "12345"
            }
    outputs:
      success:
        exit_code: 200
        description: Success
        example: null
      fail:
        key: '1232141254215512521'
        exit_code: 400
        description: Failed
        example: {}
  get:
    private: true
    description: Get invitation by invtiation key
    inputs:
      properties:
        key:
          type: string
          description: Key of the invitation
          example: 1232141254215512600
    outputs:
      success:
        exit_code: 200
      fail:
        exit_code: 400
  update:
    private: true
    description: Update invitation
    inputs:
      properties:
        key:
          type: string
          description: Invitation key
          example: 1232141254215512600
        status:
          type: string
          description: Status of the invitation
          example: pending
    outputs:
      success:
        exit_code: 200
      fail:
        exit_code: 400
  list:
    private: true
    description: List invitation for given resource ID and type
    inputs:
      properties:
        resourceID:
          type: integer
          description: ID of the resource related to invitation
          example: 12345
        resourceType:
          type: string
          description: Type of the resource
          example: company
    outputs:
      fail:
        exit_code: 400
      success:
        exit_code: 200
        examples:
          description: Success
          example: |
            [
              {
                "email": "joe@mail.com",
                "key": "1232141254215512521",
                "details": {
                  "company_id": "12345"
                }
              }
            ]
