openapi: 3.0.3
info:
  title: Common API Endpoints & Objects
  description: The Common API for the Providence Technology Corp.
  version: '3.0'
  license:
    name: EULA
    url: 'https://www.provenancetechnology.io/eula'
  contact:
    name: Timothy Neill
    email: tim.neill@provenancetechnology.io
    url: 'https://provenancetechnology.io'
  x-json-schema-faker:
    locale: en
    min-items: 2
    max-items: 20
    resolve-json-path: true
tags:
  - name: Account
    description: The Account endpoints
  - name: Date
    description: The Date endpoint
  - name: Example
    description: The Example endpoints
  - name: Ping
    description: The Ping endpoint
servers:
  - url: 'https://admin.api.provenancetechnology.dev'
    description: Administration (Development)
  - url: 'https://assembly.api.provenancetechnology.dev'
    description: Assembly (Development)
  - url: 'https://coordinates.api.provenancetechnology.dev'
    description: Coordinates (Development)
  - url: 'https://manufacturer.api.provenancetechnology.dev'
    description: Manufacturer (Development)
  - url: 'https://user.api.provenancetechnology.dev'
    description: User (Development)
paths:
  /account/user:
    get:
      summary: Get a User
      operationId: get-account-user
      tags:
        - Account
      description: |
        Gets a User based on the authentication header. 
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/User'
              examples: {}
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '503':
          $ref: '#/components/responses/ServiceUnavailable'
    patch:
      summary: Update a User
      operationId: patch-account-user
      tags:
        - Account
      description: Updates a User based on the authentication header.
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                firstName:
                  type: string
                  description: The first name.
                  maxLength: 60
                lastName:
                  type: string
                  maxLength: 60
                  description: The last name.
                phone:
                  type: string
                  maxLength: 30
                  description: The phone number.
              required:
                - firstName
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/User'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '503':
          $ref: '#/components/responses/ServiceUnavailable'
  /date:
    get:
      summary: Gets the current timestamp from the API
      operationId: get-date
      tags:
        - Date
      parameters: []
      description: Gets the current timestamp from the API.
      responses:
        '200':
          description: OK
          content:
            text/plain:
              schema:
                type: string
              examples:
                TimeStamp:
                  value: '2022-09-27T16:09:00.074+00:00'
  /example/304:
    get:
      summary: Gets an example Not Modified response
      operationId: get-errors-304
      tags:
        - Example
      parameters: []
      description: Gets an example Not Modified response.
      responses:
        '304':
          $ref: '#/components/responses/NotModified'
  /example/400:
    get:
      summary: Gets an example Bad Request response
      operationId: get-errors-400
      tags:
        - Example
      parameters: []
      description: Gets an example Bad Request response.
      responses:
        '400':
          $ref: '#/components/responses/BadRequest'
  /example/401:
    get:
      summary: Gets an example Unauthorized response
      operationId: get-errors-401
      tags:
        - Example
      parameters: []
      description: Gets an example Unauthorized response.
      responses:
        '401':
          $ref: '#/components/responses/Unauthorized'
  /example/403:
    get:
      summary: Gets an example Forbidden response
      operationId: get-errors-403
      tags:
        - Example
      parameters: []
      description: Gets an example Forbidden response.
      responses:
        '403':
          $ref: '#/components/responses/Forbidden'
  /example/404:
    get:
      summary: Gets an example Not Found response
      operationId: get-errors-404
      tags:
        - Example
      parameters: []
      description: Gets an example Not Found response.
      responses:
        '404':
          $ref: '#/components/responses/NotFound'
  /example/503:
    get:
      summary: Gets an example Service Unavailable response
      operationId: get-errors-503
      tags:
        - Example
      parameters: []
      description: Gets an example Service Unavailable response.
      responses:
        '503':
          $ref: '#/components/responses/ServiceUnavailable'
  /log-out:
    delete:
      summary: Logs a User out
      operationId: delete-log-out
      tags:
        - Account
      description: Logs a User out.
      responses:
        '200':
          description: OK
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '503':
          $ref: '#/components/responses/ServiceUnavailable'
  /ping:
    get:
      summary: Pings the API
      operationId: get-ping
      parameters: []
      description: Pings the API.
      responses:
        '304':
          $ref: '#/components/responses/NotModified'
      tags:
        - Ping
components:
  schemas:
    Approval:
      type: object
      description: ''
      minProperties: 1
      maxProperties: 1
      x-internal: true
      title: ''
      properties:
        approval:
          type: string
          description: The Approval enum.
          enum:
            - PENDING
            - DECLINED
            - APPROVED
    Approval--PATCH:
      type: object
      description: ''
      x-examples: {}
      minProperties: 1
      maxProperties: 1
      x-internal: true
      title: ''
      properties:
        approval:
          type: string
          description: The Approval enum.
          enum:
            - DECLINED
            - APPROVED
      required:
        - approval
    Coordinates:
      type: object
      x-internal: true
      properties:
        latitude:
          type: number
          description: The latitude.
          format: double
          minimum: -90
          maximum: 90
          x-faker:
            datatype.number:
              min: -90
              max: 90
              precision: 0.000001
          example: 40.416775
        longitude:
          type: number
          description: The longitude.
          format: double
          minimum: -180
          maximum: 180
          x-faker:
            datatype.number:
              min: -180
              max: 180
              precision: 0.000001
          example: -3.70379
      required:
        - latitude
        - longitude
    Created:
      type: object
      x-internal: true
      properties:
        created:
          type: string
          format: date-time
          description: The created date.
          readOnly: true
    Email:
      type: object
      x-internal: true
      properties:
        email:
          type: string
          format: email
          description: The email.
          maxLength: 255
      required:
        - email
    Error:
      type: object
      description: ''
      x-examples:
        Unauthorized:
          timestamp: '2021-03-23T14:24:18.420+00:00'
          status: 401
          error: Unauthorized
          message: ''
          path: /v1/api/endpoint
      properties:
        timestamp:
          type: string
          minLength: 1
          format: date-time
          example: '2021-03-23T14:24:18.420+00:00'
          readOnly: true
        status:
          type: integer
          minimum: 100
          maximum: 511
          example: 401
          readOnly: true
        error:
          type: string
          minLength: 1
          example: Unauthorized
          readOnly: true
        message:
          type: string
          readOnly: true
        path:
          type: string
          minLength: 1
          example: /v1/api/endpoint
          readOnly: true
      required:
        - timestamp
        - status
        - error
        - message
        - path
      readOnly: true
      x-internal: true
    Id:
      type: object
      x-internal: true
      properties:
        id:
          type: string
          format: uuid
          description: The id.
    IdentifierId:
      type: object
      x-internal: true
      properties:
        identifierId:
          type: string
          format: uuid
          description: The Identifier id.
    Image:
      allOf:
        - $ref: '#/components/schemas/Id'
        - x-stoplight:
            id: 8on6yu19jjhb8
          properties:
            fileName:
              type: string
              x-stoplight:
                id: ryvzx5lrwlnbi
              description: The file name.
              readOnly: true
            height:
              type: integer
              x-stoplight:
                id: 8h34voujld4ee
              minimum: 1
              description: The height.
              readOnly: true
            url:
              type: string
              x-stoplight:
                id: 1gmoouf9hnb3c
              description: The url.
              format: uri
              readOnly: true
            width:
              type: integer
              x-stoplight:
                id: bwicmkduxnylv
              minimum: 1
              readOnly: true
      x-stoplight:
        id: 4c9d5e0be6706
      x-internal: true
      description: The image.
      type: object
    Inspection:
      type: object
      x-internal: false
      title: ''
      allOf:
        - $ref: '#/components/schemas/Nfc'
        - $ref: '#/components/schemas/Coordinates'
        - $ref: '#/components/schemas/Timestamp'
        - $ref: '#/components/schemas/Created'
      description: The Inspection model.
    Invitation:
      type: object
      description: ''
      minProperties: 1
      maxProperties: 1
      x-internal: true
      title: ''
      properties:
        invitation:
          type: string
          description: The Invitation enum.
          enum:
            - PENDING
            - DECLINED
            - ACCEPTED
      required:
        - invitation
    Invitation--PATCH:
      type: object
      description: ''
      x-examples: {}
      minProperties: 1
      maxProperties: 1
      x-internal: true
      title: ''
      properties:
        invitation:
          type: string
          description: The Invitation enum.
          enum:
            - DECLINED
            - ACCEPTED
      required:
        - invitation
    LotIdentifier:
      type: object
      x-internal: true
      properties:
        lotIdentifier:
          type: string
          minLength: 1
          maxLength: 255
          description: The lot identifier.
      description: ''
    Manufacturer:
      allOf:
        - $ref: '#/components/schemas/Created'
        - $ref: '#/components/schemas/Id'
        - $ref: '#/components/schemas/Name'
        - $ref: '#/components/schemas/ManufacturerStatus'
        - $ref: '#/components/schemas/Updated'
    Manufacturer--PATCH:
      allOf:
        - $ref: '#/components/schemas/Id'
        - $ref: '#/components/schemas/Name'
        - $ref: '#/components/schemas/Updated'
    Manufacturer--POST:
      allOf:
        - $ref: '#/components/schemas/Created'
        - $ref: '#/components/schemas/Id'
        - $ref: '#/components/schemas/Name'
      x-stoplight:
        id: 505f517781ee9
    ManufacturerId:
      type: object
      x-internal: true
      properties:
        manufacturerId:
          type: string
          format: uuid
          description: The Manufacturer id.
      required:
        - manufacturerId
    ManufacturerStatus:
      type: object
      x-internal: true
      properties:
        status:
          type: string
          description: The Status enum.
          enum:
            - DRAFT
            - LOCKED
      required:
        - status
    Meta:
      type: object
      minProperties: 0
      properties:
        meta:
          type: object
          description: The meta data.
      x-internal: true
    Name:
      type: object
      x-internal: true
      properties:
        name:
          type: string
          minLength: 1
          maxLength: 70
          description: The name.
      description: ''
    Nfc:
      allOf:
        - $ref: '#/components/schemas/Id'
        - $ref: '#/components/schemas/NfcLotId'
        - $ref: '#/components/schemas/NfcStatus'
        - $ref: '#/components/schemas/IdentifierId'
        - type: object
          properties:
            nfcData:
              allOf:
                - $ref: '#/components/schemas/NfcData'
            uid:
              type: string
              description: The chip uid.
              minLength: 17
              maxLength: 17
              pattern: '^([0-9A-F]{2}[:]){5}([0-9A-F]{2})$'
              example: '3D:F2:C9:A6:B3:4F'
          required:
            - uid
    NfcData:
      allOf:
        - $ref: '#/components/schemas/Id'
        - $ref: '#/components/schemas/NfcIso'
        - $ref: '#/components/schemas/NfcDataStatus'
        - type: object
          properties:
            data:
              type: string
              maxLength: 20
              description: The data.
          required:
            - data
    NfcDataStatus:
      type: object
      x-internal: true
      properties:
        status:
          type: string
          description: The Status enum.
          enum:
            - UNASSIGNED
            - PENDING
            - ASSIGNED
      required:
        - status
    NfcIso:
      type: object
      x-internal: true
      properties:
        iso:
          type: string
          description: The Nfc ISO.
          enum:
            - 'ISO/IEC 18000-63:2013'
    NfcLot:
      x-internal: true
      allOf:
        - $ref: '#/components/schemas/Id'
        - $ref: '#/components/schemas/SupplierId'
        - $ref: '#/components/schemas/NfcIso'
        - $ref: '#/components/schemas/NfcLotStatus'
        - $ref: '#/components/schemas/NumberOfUnits'
        - $ref: '#/components/schemas/LotIdentifier'
        - $ref: '#/components/schemas/Created'
        - $ref: '#/components/schemas/Updated'
    NfcLotId:
      type: object
      x-internal: true
      properties:
        nfcLotId:
          type: string
          format: uuid
          description: The NfcLot id.
      required:
        - nfcLotId
    NfcLotStatus:
      type: object
      x-internal: true
      properties:
        status:
          type: string
          description: The Status enum.
          enum:
            - PENDING
            - SCANNED
      required:
        - status
    NfcStatus:
      type: object
      x-internal: true
      properties:
        status:
          type: string
          description: The Status enum.
          enum:
            - UNASSIGNED
            - ASSIGNED
      required:
        - status
    NfcUid:
      type: object
      x-internal: true
      properties:
        uid:
          type: string
          description: The Nfc uid.
      required:
        - uid
    NumberOfUnits:
      type: object
      x-internal: true
      properties:
        numberOfUnits:
          type: integer
          description: The number of units.
          minimum: 1
      description: ''
    Pagination:
      type: object
      description: The Pagination properties.
      title: Pagination
      minProperties: 10
      x-examples: {}
      properties:
        pageable:
          type: object
          properties:
            sort:
              $ref: '#/components/schemas/Sort'
            offset:
              type: integer
              minimum: 0
              description: The offset.
              readOnly: true
            pageNumber:
              type: integer
              minimum: 0
              description: The page number (zero based).
              readOnly: true
            pageSize:
              type: integer
              minimum: 0
              description: The page size.
              readOnly: true
            paged:
              type: boolean
              description: The paged flag.
            unpaged:
              type: boolean
              description: The un-paged flag.
              readOnly: true
          readOnly: true
        last:
          type: boolean
          description: 'The last [page] flag.'
          readOnly: true
        totalPages:
          type: integer
          minimum: 0
          description: The total number of pages.
          readOnly: true
        totalElements:
          type: integer
          minimum: 0
          description: The total number of elements.
          readOnly: true
        size:
          type: integer
          minimum: 0
          description: 'The [page] size.'
          readOnly: true
        number:
          type: integer
          minimum: 0
          description: 'The [page] number.'
          readOnly: true
        sort:
          $ref: '#/components/schemas/Sort'
        first:
          type: boolean
          description: 'The first [page] flag.'
          readOnly: true
        numberOfElements:
          type: integer
          minimum: 0
          description: The number of elements.
          readOnly: true
        empty:
          type: boolean
          description: The empty flag.
          readOnly: true
      readOnly: true
      x-internal: true
    Permission:
      type: object
      description: ''
      minProperties: 1
      maxProperties: 1
      x-internal: true
      title: ''
      properties:
        permission:
          type: string
          description: The Permission enum.
          enum:
            - ADMIN
            - READ
            - WRITE
      required:
        - permission
    PhoneNumber:
      type: object
      properties:
        phoneNumber:
          type: object
          description: The phone number.
          maxProperties: 2
          additionalProperties: false
          properties:
            countryCode:
              type: integer
              description: The country code.
              minimum: 1
              maximum: 99999
            subscriberNumber:
              type: integer
              maximum: 99999999999999
              minimum: 1000
              description: The subscriber number.
    Product:
      allOf:
        - $ref: '#/components/schemas/Id'
        - $ref: '#/components/schemas/Name'
        - $ref: '#/components/schemas/Meta'
    Production:
      allOf:
        - $ref: '#/components/schemas/Id'
        - $ref: '#/components/schemas/ProductionStatus'
        - $ref: '#/components/schemas/Name'
        - $ref: '#/components/schemas/NumberOfUnits'
        - $ref: '#/components/schemas/Meta'
        - x-stoplight:
            id: ppcc2igvvuyah
          properties:
            year:
              type: integer
              x-stoplight:
                id: r6cqo0qa208ar
              minimum: 1900
              maximum: 2050
              description: The year.
      type: object
    ProductionImage:
      allOf:
        - $ref: '#/components/schemas/Id'
        - x-stoplight:
            id: 3496y7l7jtybj
          properties:
            image:
              $ref: '#/components/schemas/Image'
            order:
              type: integer
              x-stoplight:
                id: 17hnr5hhpvzt2
              minimum: 0
              description: The order (zero based).
        - $ref: '#/components/schemas/ProductionImageStatus'
      x-stoplight:
        id: 753d2e2817674
      type: object
    ProductionImageStatus:
      type: object
      x-internal: true
      properties:
        status:
          description: The status.
          enum:
            - DRAFT
            - LOCKED
    ProductionStatus:
      type: object
      properties:
        status:
          type: string
          description: The status.
      title: ''
      x-internal: true
    RfidIso:
      type: object
      x-internal: true
      properties:
        iso:
          type: string
          description: The Rfid ISO.
          enum:
            - 'ISO/IEC 18000-63:2013'
    Sort:
      type: object
      description: The Sort model.
      title: ''
      x-examples: {}
      minProperties: 3
      maxProperties: 3
      properties:
        sorted:
          type: boolean
          description: The sorted flag.
          readOnly: true
        unsorted:
          type: boolean
          description: The un-sorted flag.
          readOnly: true
        empty:
          type: boolean
          description: The empty flag.
          readOnly: true
      readOnly: true
      x-internal: true
    SupplierId:
      type: object
      x-internal: true
      properties:
        supplierId:
          type: string
          format: uuid
          description: The Supplier id.
      required:
        - manufacturerId
    Timestamp:
      type: object
      x-internal: true
      properties:
        timestamp:
          type: string
          format: date-time
          description: The current timestamp.
          writeOnly: true
      required:
        - timestamp
    UnitComposite:
      description: The UnitComposite model.
      title: ''
      x-examples: {}
      x-internal: false
      type: object
      properties:
        id:
          $ref: '#/components/schemas/Id'
        manufacturer:
          $ref: '#/components/schemas/Manufacturer'
        product:
          $ref: '#/components/schemas/Product'
        production:
          $ref: '#/components/schemas/Production'
    Updated:
      type: object
      x-internal: true
      properties:
        updated:
          type: string
          format: date-time
          description: The updated date.
          readOnly: true
    User:
      description: The User model.
      x-internal: false
      allOf:
        - type: object
          properties:
            firstName:
              type: string
              maxLength: 60
              description: The first name.
            lastName:
              type: string
              maxLength: 60
              description: The last name.
            email:
              type: string
              format: email
              maxLength: 255
              description: The email address.
              readOnly: true
          required:
            - email
        - $ref: '#/components/schemas/PhoneNumber'
    User--POST:
      description: The User model.
      x-examples: {}
      x-internal: true
      type: object
      properties:
        user:
          description: The user.
          allOf:
            - $ref: '#/components/schemas/Email'
      required:
        - user
    UserAuthentication:
      allOf:
        - $ref: '#/components/schemas/Id'
        - $ref: '#/components/schemas/User'
        - $ref: '#/components/schemas/Permission'
    UserAuthentication--PATCH:
      allOf:
        - $ref: '#/components/schemas/Permission'
      x-internal: true
    UserAuthentication--POST:
      allOf:
        - $ref: '#/components/schemas/User--POST'
        - $ref: '#/components/schemas/Permission'
      x-internal: true
    UserUnitComposite:
      description: The UserUnitComposite model.
      title: ''
      x-examples: {}
      x-internal: false
      type: object
      properties:
        id:
          $ref: '#/components/schemas/Id'
        manufacturer:
          $ref: '#/components/schemas/Manufacturer'
        product:
          $ref: '#/components/schemas/Product'
        production:
          $ref: '#/components/schemas/Production'
  securitySchemes: {}
  parameters:
    approval--query:
      name: approval
      in: query
      schema:
        type: string
        enum:
          - APPROVED
          - DECLINED
          - PENDING
      description: The Approval enum.
    invitation----query:
      name: invitation
      in: query
      schema:
        type: string
        enum:
          - ACCEPTED
          - DECLINED
          - PENDING
      description: The Invitation enum.
    manufacturerId--path:
      name: manufacturerId
      in: path
      required: true
      schema:
        type: string
        format: uuid
      description: The Manufacturer id.
    nfcLotId--path:
      name: nfcLotId
      in: path
      required: true
      schema:
        type: string
        format: uuid
      description: The NfcLot id.
    page--query:
      name: page
      in: query
      required: false
      schema:
        type: integer
        default: 0
        minimum: 0
      description: The Page number (zero based).
    permission--query:
      name: permission
      in: query
      required: false
      schema:
        type: string
        enum:
          - ADMIN
          - READ
          - WRITE
      description: The Permission.
    productId--path:
      name: productId
      in: path
      required: true
      schema:
        type: string
        format: uuid
      description: The Product id.
    productionId--path:
      name: productionId
      in: path
      required: true
      schema:
        type: string
        format: uuid
      description: The Production id.
    productionImageId--path:
      name: productionImageId
      in: path
      required: true
      schema:
        type: string
        format: uuid
      description: The ProductionImage id.
    size--query:
      name: size
      in: query
      required: false
      schema:
        type: integer
        default: 20
        minimum: 1
      description: The Page size.
    sort--query:
      name: sort
      in: query
      required: false
      schema:
        type: string
        example: 'name:asc'
      description: 'The Sort property (propertyName:[asc||desc]).'
    userId--query:
      name: userId
      in: query
      schema:
        type: string
        format: uuid
      description: The User id.
    userAuthenticationId--path:
      name: userAuthenticationId
      in: path
      required: true
      schema:
        type: string
        format: uuid
      description: The UserAuthentication id.
    userUnitId--path:
      name: userUnitId
      in: path
      required: true
      schema:
        type: string
        format: uuid
      description: The UserUnit id.
  responses:
    BadRequest:
      description: |-
        A request is invalid.

        This could be caused by: 
        - One or more parameters is invalid
        - The targeted or related object is in an invalid state
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          examples:
            Bad Request:
              value:
                timestamp: '2021-03-23T14:24:29.500+00:00'
                status: 400
                error: Bad Request
                message: The Object is not valid.
                path: /v1/api/endpoint/
    Forbidden:
      description: The User is forbidden to execute the endpoint.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          examples:
            Forbidden:
              value:
                timestamp: '2021-03-23T14:24:29.500+00:00'
                status: 403
                error: Forbidden
                message: ''
                path: /v1/api/endpoint/
    Locked:
      description: The resource is locked.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          examples:
            Forbidden:
              value:
                timestamp: '2021-03-23T14:24:29.500+00:00'
                status: 423
                error: Locked
                message: ''
                path: /v1/api/endpoint/
    NotFound:
      description: The Object was not found.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          examples:
            Not Found:
              value:
                timestamp: '2021-03-23T14:24:29.500+00:00'
                status: 404
                error: Not Found
                message: The Object was not found.
                path: /v1/api/endpoint/
    NotModified:
      description: The Object was not modified.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          examples:
            Not Modified:
              value:
                timestamp: '2021-03-23T14:24:29.500+00:00'
                status: 304
                error: Not Modified
                message: The Object was not modified.
                path: /v1/api/endpoint/
    ServiceUnavailable:
      description: The Service is temporarily down for maintenance.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          examples:
            ServiceUnavailable:
              value:
                timestamp: '2021-03-23T14:24:29.500+00:00'
                status: 503
                error: Service Unavailable
                message: The service is temporarily unavailable.
                path: /v1/api/endpoint/
    Unauthorized:
      description: The User is unauthorized to execute the endpoint.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          examples:
            Unauthorized:
              value:
                timestamp: '2021-03-23T14:24:29.500+00:00'
                status: 401
                error: Unauthorized
                message: ''
                path: /v1/api/endpoint/
security: []
x-internal: true
