openapi: '3.0.1'

info:
  title: TASK-DATA-SERVICE
  description: |
      This API specification serves as reference within SiGREEN project for how to design and specify HTTPs-based APIs.
  contact:
    name: SiGREEN API Support
    email: sigreensupport.industry@siemens.com
  version: 1.14.0
servers:
- url: https://app.sigreen.siemens.com/api
  description: SiGREEN Production Server
- url: https://app-uat.sigreen-playground.siemens.cloud/api
  description: SiGREEN User Acceptance Test (UAT) Server
security:
  - bearerAuth: []

tags:
  - name: Product Tasks
    description: "![remote](../images/api-package-remote-red.svg) Product Tasks APIs"
  - name: Component Tasks
    description: "![remote](../images/api-package-remote-red.svg) Component Tasks APIs"

paths:
    /tasks/inboundPcfRequests:
      get:
        tags:
          - Product Tasks
        description: GET the incoming pcf requests received for company in SiGREEN.
        operationId: "getInboundPcfRequests"

        parameters:
          - in: query
            name: searchText
            schema:
              type: string
            required: false
            description:  Free text search for incoming pcf requests that will look in the attribute of Task ID, Product name, Company Name(Requester company name) of a company in SiGREEN
          - in: query
            name: productName
            schema:
              type: string
            required: false
            description: Product name of the company in SiGREEN
          - in: query
            name: taskId
            example: T0001
            schema:
              type: string
            required: false
            description: Task Id for identifying the incoming pcf request of the company in SiGREEN
          - in: query
            name: id
            example : C98BE31E-3698-412D-91E3-8270102CC7D5
            schema:
              type: string
            required: false
            description: UUID of the Task for identifying the incoming pcf request of the company in SiGREEN
          - in: query
            name: companyName
            schema:
              type: string
            required: false
            description: Name of the customer company  
          - in: query
            name: pcfId
            schema:
              type: string
            required: false
            description:  Id for identifying the pcf data shared in my company  
          - in: query
            name: productFamily
            schema:
              type: string
            required: false
            description:  Product family name of the product my company    
          - in: query
            name: status
            schema:
              type: string
              enum: [ "NEW","PCF_SHARED","WITHDRAWN","COMPLETED","REJECTED_PCF","DENIED","CANCELLED"]
            required: false
            description:  Inbound pcf request task status.Multiple fields could be used separated by commas (e.g. "NEW","PCF_SHARED").
          - in: query
            name: from
            schema:
              type: string
              format: date-time
            example: "2022-11-20T08:30:00.000Z"
            description: 
                 The start date of the date range when the task was created or updated in SiGREEN.DateTime (ISO 8601; UTC Timezone)
          - in: query
            name: to
            schema:
              type: string
              format: date-time
            example: "2022-11-20T08:30:00.000Z"
            description: 
                 The end date of the date range when the task was created or updated in SiGREEN.DateTime (ISO 8601; UTC Timezone)
          - in: query
            name: sort
            schema:
              type: string
            required: false
            example: "-taskId"
            description:  The order of returned elements.sort supporting fields(taskId,productName,companyName) for inbound pcf requests.Descending order could be requested by appending '-' ,ascending '+' at the prefix of parameter.(e.g. '+taskId)'
          - in: query
            name: page
            schema:
              type: integer
              default: 0
            description: This is an integer representing the page-number to fetch. 0 would be the first page.(e.g 'page=0')
          - in: query
            name: size
            schema:
              type: integer
              maximum: 10
              default: 10
            description: This is used for the requested maximum page size. (e.g 'size=10')
        summary: GET the incoming pcf requests  of my company. it is recommended to make use of the "status" query parameter as follows /tasks/inboundPcfRequests?status=NEW,PCF_SHARED,COMPLETED.
        responses:
          '200':
            description: Get incoming pcf requests for company in SiGREEN
            content:
              application/json:
                schema: 
                  allOf:
                    - properties: 
                        items : 
                          type: array
                          items:
                            $ref: '#/components/schemas/ProductTasksResponse'
                    - $ref: "#/components/schemas/PaginatedResult"
          '400':
            description: Bad request.
            content:
              application/problem+json:
                example:
                  {
                    "type": "https://developer.siemens.com/sigreen/validation-error.html",
                    "title": "Bad request",
                    "status": 400,
                    "traceId": "d7e420c2-5a49-4a34-8ead-9c52a8f91577",
                    "instance": "/api/tasks/inboundPcfRequests",
                    "errors": [
                      {
                        "detail": "Name must not be null or empty.",
                        "code": "SIG-BUS-0001"
                      }
                    ]
                  }
                schema:
                  $ref: "#/components/schemas/Problem"
          '401':
            description: Unauthorized.
            content:
              application/problem+json:
                example:
                  {
                    "type": "https://developer.siemens.com/sigreen/validation-error.html",
                    "title": "UNAUTHORIZED",
                    "status": 401,
                    "traceId": "d7e420c2-5a49-4a34-8ead-9c52a8f91577",
                    "instance": "/api/tasks/inboundPcfRequests",
                    "errors": [
                      {
                        "detail": "Invalidate Authentcation",
                        "code": "SIG-BUS-0001"
                      }
                    ]
                  }
                schema:
                  $ref: "#/components/schemas/Problem"
          '403':
            description: Forbidden.
            content:
              application/problem+json:
                example:
                  {
                    "type": "https://developer.siemens.com/sigreen/validation-error.html",
                    "title": "FORBIDDEN",
                    "status": 403,
                    "traceId": "d7e420c2-5a49-4a34-8ead-9c52a8f91577",
                    "instance": "/api/tasks/inboundPcfRequests",
                    "errors": [
                      {
                        "detail": "Invalidate Autherization",
                        "code": "SIG-BUS-0001"
                      }
                    ]
                  }
                schema:
                  $ref: "#/components/schemas/Problem"
          '5XX':
            description: Unexpected error.
            content:
              application/problem+json:
                example:
                  {
                    "type": "https://developer.siemens.com/sigreen/validation-error.html",
                    "title": "INTERNAL_SERVER_ERROR",
                    "status": 500,
                    "traceId": "d7e420c2-5a49-4a34-8ead-9c52a8f91577",
                    "instance": "/api/tasks/inboundPcfRequests",
                    "errors": [
                      {
                        "detail": "Internal service error",
                        "code": "SIG-BUS-0001"
                      }
                    ]
                  }
                schema:
                  $ref: "#/components/schemas/Problem"
    /tasks/{id}/linkProduct/{productId}:
      put: 
        tags:
          - Product Tasks
        description: Link an existing Product to the given Task. Only one product can be linked to a task at a time. If will fail, if a product is already linked to the task.
        operationId: "linkProductToTask"
        parameters:
          - in: path
            name: id
            required: true
            example : C98BE31E-3698-412D-91E3-8270102CC7D5
            schema:
              type: string
            description: UUID of the Task to identify the product task of the company in SiGREEN
          - in: path
            name: productId
            required: true
            example : C98BE31E-3698-412D-91E3-8270102CC7D5
            schema:
              type: string
            description:  UUID of the Product to identify the product of the company in SiGREEN.
        summary: Link product to the task.
        responses:
          '204':
            description: No content, Product successfully linked to the task
          '400':
            description: Bad request.
            content:
              application/problem+json:
                example:
                  {
                    "type": "https://developer.siemens.com/sigreen/validation-error.html",
                    "title": "Bad request",
                    "status": 400,
                    "traceId": "d7e420c2-5a49-4a34-8ead-9c52a8f91577",
                    "instance": "/api/tasks/{id}/linkProduct/{productId}",
                    "errors": [
                      {
                        "detail": "Name must not be null or empty.",
                        "code": "SIG-BUS-0001"
                      }
                    ]
                  }
                schema:
                  $ref: "#/components/schemas/Problem"
          '401':
            description: Unauthorized.
            content:
              application/problem+json:
                example:
                  {
                    "type": "https://developer.siemens.com/sigreen/validation-error.html",
                    "title": "UNAUTHORIZED",
                    "status": 401,
                    "traceId": "d7e420c2-5a49-4a34-8ead-9c52a8f91577",
                    "instance": "/api/tasks/{id}/linkProduct/{productId}",
                    "errors": [
                      {
                        "detail": "Invalidate Authentcation",
                        "code": "SIG-BUS-0001"
                      }
                    ]
                  }
                schema:
                  $ref: "#/components/schemas/Problem"
          '403':
            description: Forbidden.
            content:
              application/problem+json:
                example:
                  {
                    "type": "https://developer.siemens.com/sigreen/validation-error.html",
                    "title": "FORBIDDEN",
                    "status": 403,
                    "traceId": "d7e420c2-5a49-4a34-8ead-9c52a8f91577",
                    "instance": "/api/tasks/{id}/linkProduct/{productId}",
                    "errors": [
                      {
                        "detail": "Invalidate Autherization",
                        "code": "SIG-BUS-0001"
                      }
                    ]
                  }
                schema:
                  $ref: "#/components/schemas/Problem"
          '5XX':
            description: Unexpected error.
            content:
              application/problem+json:
                example:
                  {
                    "type": "https://developer.siemens.com/sigreen/validation-error.html",
                    "title": "INTERNAL_SERVER_ERROR",
                    "status": 500,
                    "traceId": "d7e420c2-5a49-4a34-8ead-9c52a8f91577",
                    "instance": "/api/tasks/{id}/linkProduct/{productId}",
                    "errors": [
                      {
                        "detail": "Internal service error",
                        "code": "SIG-BUS-0001"
                      }
                    ]
                  }
                schema:
                  $ref: "#/components/schemas/Problem"    
      delete: 
        tags:
          - Product Tasks
        description: Delete link between product and task. Only possible before the task status is changed to 'PCF Shared'.
        operationId: "deleteLinkedProductFromTask"
        parameters:
          - in: path
            name: id
            required: true
            example : C98BE31E-3698-412D-91E3-8270102CC7D5
            schema:
              type: string
            description: UUID of the Task to identify the product task of the company in SiGREEN
          - in: path
            name: productId
            required: true
            example : C98BE31E-3698-412D-91E3-8270102CC7D5
            schema:
              type: string
            description:  UUID of the Product to identify the product of the company in SiGREEN.
        summary: Delete link between product and task.
        responses:
          '204':
            description: No content, Product successfully unlinked from the task
          '400':
            description: Bad request.
            content:
              application/problem+json:
                example:
                  {
                    "type": "https://developer.siemens.com/sigreen/validation-error.html",
                    "title": "Bad request",
                    "status": 400,
                    "traceId": "d7e420c2-5a49-4a34-8ead-9c52a8f91577",
                    "instance": "/api/tasks/{id}/linkProduct/{productId}",
                    "errors": [
                      {
                        "detail": "Name must not be null or empty.",
                        "code": "SIG-BUS-0001"
                      }
                    ]
                  }
                schema:
                  $ref: "#/components/schemas/Problem"
          '401':
            description: Unauthorized.
            content:
              application/problem+json:
                example:
                  {
                    "type": "https://developer.siemens.com/sigreen/validation-error.html",
                    "title": "UNAUTHORIZED",
                    "status": 401,
                    "traceId": "d7e420c2-5a49-4a34-8ead-9c52a8f91577",
                    "instance": "/api/tasks/{id}/linkProduct/{productId}",
                    "errors": [
                      {
                        "detail": "Invalidate Authentcation",
                        "code": "SIG-BUS-0001"
                      }
                    ]
                  }
                schema:
                  $ref: "#/components/schemas/Problem"
          '403':
            description: Forbidden.
            content:
              application/problem+json:
                example:
                  {
                    "type": "https://developer.siemens.com/sigreen/validation-error.html",
                    "title": "FORBIDDEN",
                    "status": 403,
                    "traceId": "d7e420c2-5a49-4a34-8ead-9c52a8f91577",
                    "instance": "/api/tasks/{id}/linkProduct/{productId}",
                    "errors": [
                      {
                        "detail": "Invalidate Autherization",
                        "code": "SIG-BUS-0001"
                      }
                    ]
                  }
                schema:
                  $ref: "#/components/schemas/Problem"
          '5XX':
            description: Unexpected error.
            content:
              application/problem+json:
                example:
                  {
                    "type": "https://developer.siemens.com/sigreen/validation-error.html",
                    "title": "INTERNAL_SERVER_ERROR",
                    "status": 500,
                    "traceId": "d7e420c2-5a49-4a34-8ead-9c52a8f91577",
                    "instance": "/api/tasks/{id}/linkProduct/{productId}",
                    "errors": [
                      {
                        "detail": "Internal service error",
                        "code": "SIG-BUS-0001"
                      }
                    ]
                  }
                schema:
                  $ref: "#/components/schemas/Problem"    
    /tasks/{id}/sharePcf/{pcfId}:
      put:
        tags: 
          - Product Tasks
        description: Share the pcf data for the given task with a linked product. The pcf data must match the product. 
        operationId: "sharePcfData"
        parameters:
          - in: path
            name: id
            required: true
            example : C98BE31E-3698-412D-91E3-8270102CC7D5
            schema:
              type: string
            description: UUID of the Task to identify the product task of the company in SiGREEN
          - in: path
            name: pcfId
            required: true
            example : C98BE31E-3698-412D-91E3-8270102CC7D5
            schema:
              type: string
            description:  UUID of the of PCF to identify the pcf data of the company in SiGREEN.
        summary: Share the pcf data with the given task.
        responses:
          '204':
            description: No content.
          '400':
            description: Bad request.
            content:
              application/problem+json:
                example:
                  {
                    "type": "https://developer.siemens.com/sigreen/validation-error.html",
                    "title": "Bad request",
                    "status": 400,
                    "traceId": "d7e420c2-5a49-4a34-8ead-9c52a8f91577",
                    "instance": "/api/tasks/{id}/sharePcf/{pcfId}",
                    "errors": [
                      {
                        "detail": "Name must not be null or empty.",
                        "code": "SIG-BUS-0001"
                      }
                    ]
                  }
                schema:
                  $ref: "#/components/schemas/Problem"
          '401':
            description: Unauthorized.
            content:
              application/problem+json:
                example:
                  {
                    "type": "https://developer.siemens.com/sigreen/validation-error.html",
                    "title": "UNAUTHORIZED",
                    "status": 401,
                    "traceId": "d7e420c2-5a49-4a34-8ead-9c52a8f91577",
                    "instance": "/api/tasks/{id}/sharePcf/{pcfId}",
                    "errors": [
                      {
                        "detail": "Invalidate Authentcation",
                        "code": "SIG-BUS-0001"
                      }
                    ]
                  }
                schema:
                  $ref: "#/components/schemas/Problem"
          '403':
            description: Forbidden.
            content:
              application/problem+json:
                example:
                  {
                    "type": "https://developer.siemens.com/sigreen/validation-error.html",
                    "title": "FORBIDDEN",
                    "status": 403,
                    "traceId": "d7e420c2-5a49-4a34-8ead-9c52a8f91577",
                    "instance": "/api/tasks/{id}/sharePcf/{pcfId}",
                    "errors": [
                      {
                        "detail": "Invalidate Autherization",
                        "code": "SIG-BUS-0001"
                      }
                    ]
                  }
                schema:
                  $ref: "#/components/schemas/Problem"
          '5XX':
            description: Unexpected error.
            content:
              application/problem+json:
                example:
                  {
                    "type": "https://developer.siemens.com/sigreen/validation-error.html",
                    "title": "INTERNAL_SERVER_ERROR",
                    "status": 500,
                    "traceId": "d7e420c2-5a49-4a34-8ead-9c52a8f91577",
                    "instance": "/api/tasks/{id}/sharePcf/{pcfId}",
                    "errors": [
                      {
                        "detail": "Internal service error",
                        "code": "SIG-BUS-0001"
                      }
                    ]
                  }
                schema:
                  $ref: "#/components/schemas/Problem"              

    /tasks/outboundPcfRequests:
      get:
        tags:
          - Component Tasks
        description: GET the outbound pcf requests sent for company in SiGREEN.    
        operationId: "getOutboundPcfRequests"
        parameters:
          - in: query
            name: searchText
            schema:
              type: string
            required: false
            description:  Free text search for outbound pcf requests that will look in the attribute of Task ID,component name,supplierName of a company in SiGREEN.
          - in: query
            name: componentName
            schema:
              type: string
            required: false
            description: Component name of the company in SiGREEN
          - in: query
            name: taskId
            example: T0001
            schema:
              type: string
            required: false
            description: Task Id for identifying the outbound pcf request of the company in SiGREEN
          - in: query
            name: id
            example : C98BE31E-3698-412D-91E3-8270102CC7D5
            schema:
              type: string
            required: false
            description: UUID of the Task for identifying the outbound pcf request of the company in SiGREEN
          - in: query
            name: supplierId
            schema:
              type: string
            required: false
            description: SupplierId of the supplier company
          - in: query
            name: supplierName
            schema:
              type: string
            required: false
            description: Name of the supplier company
          - in: query
            name: pcfId
            schema:
              type: string
            required: false
            description: Id for identifying the pcf data received in my company
          - in: query
            name: materialCategory
            schema:
              type: string
            required: false
            description:  MaterialCategory of the component my company
          - in: query
            name: status
            schema:
              type: string
              enum: [ "NEW","PCF_RECEIVED","UNDER_REVIEW","WITHDRAWN","COMPLETED","REJECTED_PCF","DENIED","CANCELLED"]
            required: false
            description:  Outbound pcf request status. Multiple fields could be used separated by commas (e.g. "PCF_RECEIVED","UNDER_REVIEW"). 
          - in: query
            name: from
            schema:
              type: string
              format: date-time
            example: "2022-11-20T08:30:00.000Z"
            description: 
                  The start date of the date range when the task was created or updated in SiGREEN.DateTime (ISO 8601; UTC Timezone)
          - in: query
            name: to
            schema:
              type: string
              format: date-time
            example: "2022-11-20T08:30:00.000Z"
            description: 
                  The end date of the date range when the task was created or update in SiGREEN.DateTime (ISO 8601; UTC Timezone)
          - in: query
            name: sort
            schema:
              type: string
            required: false
            example: "+taskId"
            description: The order of returned elements.sort supporting fileds(taskId,componentName,supplierName,supplierId,requestTimeStamp) in outbound pcf requests.Descending order could be requested by appending '-' ,ascending '+' at the prefix of parameter.(e.g. '+taskId)'
          - in: query
            name: page
            schema:
              type: integer
              default: 0
            description: This is an integer representing the page-number to fetch. 0 would be the first page.(e.g 'page=0')
          - in: query
            name: size
            schema:
              type: integer
              maximum: 10
              default: 10
            description: This is used for the requested maximum page size.(e.g. 'size=10')
        summary: GET the outbound pcf requests of my company. it is recommended to make use of the "status" query parameter as follows /tasks/outboundPcfRequests?status=NEW,PCF_RECEIVED,COMPLETED.
        responses:
          '200':
            description: Get outbound pcf requests for company in SiGREEN
            content:
              application/json:
                schema: 
                  allOf:
                    - properties: 
                        items : 
                          type: array
                          items:
                            $ref: '#/components/schemas/ComponentTasksResponse'
                    - $ref: "#/components/schemas/PaginatedResult"
          '204':
            description: No Content.The request is successfully fulfilled, but no additional content is provided in the response.
          '400':
            description: Bad request.
            content:
              application/problem+json:
                example:
                  {
                    "type": "https://developer.siemens.com/sigreen/validation-error.html",
                    "title": "Bad request",
                    "status": 400,
                    "traceId": "d7e420c2-5a49-4a34-8ead-9c52a8f91577",
                    "instance": "/api/tasks/outboundPcfRequests",
                    "errors": [
                      {
                        "detail": "Name must not be null or empty.",
                        "code": "SIG-BUS-0001"
                      }
                    ]
                  }
                schema:
                  $ref: "#/components/schemas/Problem"
          '401':
            description: Unauthorized.
            content:
              application/problem+json:
                example:
                  {
                    "type": "https://developer.siemens.com/sigreen/validation-error.html",
                    "title": "UNAUTHORIZED",
                    "status": 401,
                    "traceId": "d7e420c2-5a49-4a34-8ead-9c52a8f91577",
                    "instance": "/api/tasks/outboundPcfRequests",
                    "errors": [
                      {
                        "detail": "Invalidate Authentcation",
                        "code": "SIG-BUS-0001"
                      }
                    ]
                  }
                schema:
                  $ref: "#/components/schemas/Problem"
          '403':
            description: Forbidden.
            content:
              application/problem+json:
                example:
                  {
                    "type": "https://developer.siemens.com/sigreen/validation-error.html",
                    "title": "FORBIDDEN",
                    "status": 403,
                    "traceId": "d7e420c2-5a49-4a34-8ead-9c52a8f91577",
                    "instance": "/api/tasks/outboundPcfRequests",
                    "errors": [
                      {
                        "detail": "Invalidate Autherization",
                        "code": "SIG-BUS-0001"
                      }
                    ]
                  }
                schema:
                  $ref: "#/components/schemas/Problem"
          '5XX':
            description: Unexpected error.
            content:
              application/problem+json:
                example:
                  {
                    "type": "https://developer.siemens.com/sigreen/validation-error.html",
                    "title": "INTERNAL_SERVER_ERROR",
                    "status": 500,
                    "traceId": "d7e420c2-5a49-4a34-8ead-9c52a8f91577",
                    "instance": "/api/tasks/outboundPcfRequests",
                    "errors": [
                      {
                        "detail": "Internal service error",
                        "code": "SIG-BUS-0001"
                      }
                    ]
                  }
                schema:
                  $ref: "#/components/schemas/Problem"
    /tasks/{id}/pcf/accept:
      patch:
        tags:
          - Component Tasks
        description: accept proof recived to the task in SiGREEN.
        operationId: "acceptProof"
        parameters:
          - in: path
            name: id
            schema:
              type: string
            required: true
            description: UUID of the Task to identify the product task of the company in SiGREEN
        summary: accept proof recived to the task in SiGREEN.
        responses:
          "202":
           description: accept proof is performed.
          '400':
            description: Bad request.
            content:
              application/problem+json:
                example:
                  {
                    "type": "https://developer.siemens.com/sigreen/validation-error.html",
                    "title": "Bad request",
                    "status": 400,
                    "traceId": "d7e420c2-5a49-4a34-8ead-9c52a8f91577",
                    "instance": "/api/tasks/{id}/pcf/accept",
                    "errors": [
                      {
                        "detail": "Name must not be null or empty.",
                        "code": "SIG-BUS-0001"
                      }
                    ]
                  }
                schema:
                  $ref: "#/components/schemas/Problem"
          '401':
            description: Unauthorized.
            content:
              application/problem+json:
                example:
                  {
                    "type": "https://developer.siemens.com/sigreen/validation-error.html",
                    "title": "UNAUTHORIZED",
                    "status": 401,
                    "traceId": "d7e420c2-5a49-4a34-8ead-9c52a8f91577",
                    "instance": "/api/tasks/{id}/pcf/accept",
                    "errors": [
                      {
                        "detail": "Invalidate Authentcation",
                        "code": "SIG-BUS-0001"
                      }
                    ]
                  }
                schema:
                  $ref: "#/components/schemas/Problem"
          '403':
            description: Forbidden.
            content:
              application/problem+json:
                example:
                  {
                    "type": "https://developer.siemens.com/sigreen/validation-error.html",
                    "title": "FORBIDDEN",
                    "status": 403,
                    "traceId": "d7e420c2-5a49-4a34-8ead-9c52a8f91577",
                    "instance": "/api/tasks/{id}/pcf/accept",
                    "errors": [
                      {
                        "detail": "Invalidate Autherization",
                        "code": "SIG-BUS-0001"
                      }
                    ]
                  }
                schema:
                  $ref: "#/components/schemas/Problem"
          '5XX':
            description: Unexpected error.
            content:
              application/problem+json:
                example:
                  {
                    "type": "https://developer.siemens.com/sigreen/validation-error.html",
                    "title": "INTERNAL_SERVER_ERROR",
                    "status": 500,
                    "traceId": "d7e420c2-5a49-4a34-8ead-9c52a8f91577",
                    "instance": "/api/tasks/{id}/pcf/accept",
                    "errors": [
                      {
                        "detail": "Internal service error",
                        "code": "SIG-BUS-0001"
                      }
                    ]
                  }
                schema:
                  $ref: "#/components/schemas/Problem"            
    /tasks/{id}/pcf/reject:
      patch:
        tags:
          - Component Tasks
        description: reject proof recived to the task in SiGREEN.
        operationId: "rejectProof"
        parameters:
          - in: path
            name: id
            schema:
              type: string
            required: true
            description: UUID of the Task to identify the product task of the company in SiGREEN
        requestBody:
          description: "Reason for rejecting the proof"
          required: true
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Reason'      
        summary: reject proof recived to the task in SiGREEN.
        responses:
          "202":
           description: reject proof is performed.
          '400':
            description: Bad request.
            content:
              application/problem+json:
                example:
                  {
                    "type": "https://developer.siemens.com/sigreen/validation-error.html",
                    "title": "Bad request",
                    "status": 400,
                    "traceId": "d7e420c2-5a49-4a34-8ead-9c52a8f91577",
                    "instance": "/api/tasks/{id}/pcf/reject",
                    "errors": [
                      {
                        "detail": "Name must not be null or empty.",
                        "code": "SIG-BUS-0001"
                      }
                    ]
                  }
                schema:
                  $ref: "#/components/schemas/Problem"
          '401':
            description: Unauthorized.
            content:
              application/problem+json:
                example:
                  {
                    "type": "https://developer.siemens.com/sigreen/validation-error.html",
                    "title": "UNAUTHORIZED",
                    "status": 401,
                    "traceId": "d7e420c2-5a49-4a34-8ead-9c52a8f91577",
                    "instance": "/api/tasks/{id}/pcf/reject",
                    "errors": [
                      {
                        "detail": "Invalidate Authentcation",
                        "code": "SIG-BUS-0001"
                      }
                    ]
                  }
                schema:
                  $ref: "#/components/schemas/Problem"
          '403':
            description: Forbidden.
            content:
              application/problem+json:
                example:
                  {
                    "type": "https://developer.siemens.com/sigreen/validation-error.html",
                    "title": "FORBIDDEN",
                    "status": 403,
                    "traceId": "d7e420c2-5a49-4a34-8ead-9c52a8f91577",
                    "instance": "/api/tasks/{id}/pcf/reject",
                    "errors": [
                      {
                        "detail": "Invalidate Autherization",
                        "code": "SIG-BUS-0001"
                      }
                    ]
                  }
                schema:
                  $ref: "#/components/schemas/Problem"
          '5XX':
            description: Unexpected error.
            content:
              application/problem+json:
                example:
                  {
                    "type": "https://developer.siemens.com/sigreen/validation-error.html",
                    "title": "INTERNAL_SERVER_ERROR",
                    "status": 500,
                    "traceId": "d7e420c2-5a49-4a34-8ead-9c52a8f91577",
                    "instance": "/api/tasks/{id}/pcf/reject",
                    "errors": [
                      {
                        "detail": "Internal service error",
                        "code": "SIG-BUS-0001"
                      }
                    ]
                  }
                schema:
                  $ref: "#/components/schemas/Problem"            

components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
  schemas:
    Problem:
      type: object
      properties:
        type:
          type: string
          example: https://developer.siemens.com/sigreen/validation-error.html
          description: "A URI reference that identifies the problem type. This should be a human-redable documentation for the problem type (e.g. list of SiGREEN Validation errors). When this member is not present, its value is assumed to be 'about:blank'."
        title:
          type: string
          example: Bad request
          description: "trueDeveloper friendly, human-readable description or summary that SHOULD NOT change from occurrence to occurrence of the problem. In case of using a custom HTTP status codes in the status field of the error object, the title MUST provide a concise description of the HTTP error code (for example: status: '599', title: 'Network Connection Timeout')."
        status:
          type: integer
          example: 400
          description: "Numeric HTTP status code for the specific error."
        traceId:
          type: string
          example: "UUID"
          description: "A unique string identifier (UUID), representing a flow through the system."  
        instance:  
          type: string
          example: "/api/tasks/inboundPcfRequests"
          description: "A URI reference that points to the specific resource where the problem was identified (for example: points to the api resource /api/tasks/inboundPcfRequests)."  
        errors:
          type: array
          description: "Extended error array to include descriptions about errors like validation errors."
          items:
            $ref: '#/components/schemas/Errors'
    Errors:
      type: object
      properties:
        detail:
          type: string
          example: "Invalid Date Format. Please send valid date format (for eg: yyyy-MM-dd'T'HH:mm:ss'Z')"
          description: "Developer friendly, human-readable, detailed description specific to the occurrence of the problem."
        code:
          type: string
          example: "SIG_VLD-092"
          description: "trueString with a generated pointer to the wrong value; Collections integrated as an integer, starts with 0."
        pointer:
          type: string
          example: "/data/0/from" 
          description: "An application-specific error code, expressed as a string value, mostly is this used for validation errors. The format and type of code representation MUST be harmonized across all services within SiGREEN. The code focuses on programs and doesn’t have to be human-readable."
          
    PaginatedResult:
      type: object
      properties:
        hasNext:
          type: boolean
          example: true
          description: "true if next page exists (page < totalPages)"
        hasPrev:
          type: boolean
          example: false
          description: "true if a previous page exists (page > 0)"
        page:
          type: number
          example: 0
          description: "The current page-number (starts with 0)"
        pageNumber:
          type: number
          example: 1
          description: "The current page-number (starts with 1)"
        size:
          type: number
          example: 10
          description: "The size of elements in the response"
        totalPages:
          type: number
          example: 120
          description: "The total available pages"
  
        
    Identifier:
      type: object
      properties:
        type:
          type: string
          maxLength: 100
          example: MLFB
          description: 
                MLFB.
        value:
          type: string
          maxLength: 100
          example: ABC-UVW-1234
          description: 
                ABC-UVW-1234.
                
    ProductTasksResponse:
      type: object
      properties:
        id:
          type: string
          example: UUID
          description: 
                task UUID to identify the task of the company in SiGREEN.
        taskId:
          type: string
          example: T001
          description: 
                tak id.
        pcfRequestedData:
          $ref: "#/components/schemas/PcfRequestedData"
        pcfData:
          $ref: "#/components/schemas/ProductPcfData"  
        productName:
          type: string
          example: productName
          description: 
                productName.
        companyName:
          type: string
          example: companyName
          description: 
                Requester company.
        type:
          type: string
          enum: ["Received","Sent"]
          example: Received
          description: 
                Received or Sent from company.
        taskType:
          type: string
          enum: ["PCF_REQUEST","EXTERNAL_PCF_REQUEST"]
          example: PCF_REQUEST
          description: 
                task types from company.
        status:
          type: string
          enum: [ "NEW","PCF_SHARED","WITHDRAWN","COMPLETED","REJECTED_PCF","DENIED","CANCELLED"]
          example: NEW
          description: 
                task status.
        requestTimeStamp:
          type: string
          format: date-time
          example: "2022-11-20T08:30:00.000Z"
          description: 
            Pcf Request created DateTime.DateTime (ISO 8601; UTC Timezone)
        lastUpdatedTimeStamp:
          type: string
          format: date-time
          example: "2022-11-20T08:30:00.000Z"
          description: 
            Last update DateTime.DateTime (ISO 8601; UTC Timezone)
        productFamily:
           type: string
           example: productFamily
           description: productFamily of the product
          
        
    PcfRequestedData:
      type: object
      properties:
        location:
          type: string
          maxLength: 100
          example: location
          description: 
               Expecting pcf data for the declared location.
        declaredUnit:
          type: string
          example: kg
          description: 
              Expecting pcf data for the declared unit.
        standards:
          type: string
          enum: [ "PACT V2.0.0","PACT V1.0.1","TFS V2","Catena-X V2","Catena-X V1","ISO 14067","EPD Style"]
          example: TFS V2
          description: 
              Expecting pcf data for the declared pcf format or standards.
        message:
          type: string
          maxLength: 300
          example: "PCF request message"
          description: 
             Requesting pcf data with message, which gives more information regarding the product pcf data to be shared.
        identifiers:
          type: array
          items:
            $ref: '#/components/schemas/Identifier'   
          example: [{"type":"ean","value":"4667"}]
          description: 
             Additional product identifiers gives more information regarding the product pcf data to be shared.  
        supplierProductId:
          type: string
          example: Id
          description: 
             Requesting supplier ProductId as product identifier gives more information regarding the product pcf data to be shared.
    ProductPcfData:
      type: object
      properties:
        pcfId:   
           type: string
           example: pcfId
           description: pcfId of PCF data.
    PcfData:
      type: object
      properties:
        pcfId:   
           type: string
           example: pcfId
           description: pcfId of PCF data.
        pcfState:
          type: string
          example: "Certified,Self published"
          description: State of the pcf to say if it self certified or certified by a 3rd party certifier
        standards:
          type: array
          items:
            enum: [ "PACT V2.0.0","PACT V1.0.1","TFS V2","Catena-X V2","Catena-X V1","ISO 14067","EPD Style"]
          example: ["TFS V2","PACT V2.0.0"]
          description: 
              Pcf format or standards of the pcf data shared.  
                
    ComponentTasksResponse:
      type: object
      properties:
        id:
          type: string
          example: UUID
          description: 
                task UUID to identify the task of the company in SiGREEN.
        taskId:
          type: string
          example: T001
          description: 
                task id.
        pcfRequestedData:
          $ref: "#/components/schemas/PcfRequestedData"
        pcfData:
          $ref: "#/components/schemas/PcfData"          
        componentName:
          type: string
          example: componentName
          description: 
                componentName.
        supplierName:
          type: string
          example: supplier Name
          description: 
                supplier company name.
        type:
          type: string
          enum: ["Received","Sent"]
          example: Received
          description: 
                Received or Sent from company.
        taskType:
          type: string
          enum: ["PCF_REQUEST","PCF_DATA_SHARE"]
          example: PCF_REQUEST
          description: 
                Task types from company.
        status:
          type: string
          enum: [ "NEW","PCF_RECEIVED","UNDER_REVIEW","WITHDRAWN","COMPLETED","REJECTED_PCF","DENIED","CANCELLED"]
          example: NEW
          description: 
                task status.
        requestTimeStamp:
          type: string
          format: date-time
          example: "2022-11-20T08:30:00.000Z"
          description: 
            Pcf Request created DateTime.DateTime (ISO 8601; UTC Timezone)
        lastUpdatedTimeStamp:
          type: string
          format: date-time
          example: "2022-11-20T08:30:00.000Z"
          description: 
            Last update DateTime.DateTime (ISO 8601; UTC Timezone)
        materialCategory:
           type: string
           example: materialCategory
           description: materialCategory of the component
        supplierId:   
           type: string
           example:  supplier id
           description:  supplier id.   

    Reason:
      type: object
      properties:
        reason:
          type: string
          example: reason.
          description: 
            deny reason.
