{
  "openapi": "3.0.1",
  "info": {
    "title": "Service-Sheet API",
    "version": "1.0"
  },
  "servers": [
    {
      "url": "https://api.mercadoe.com"
    }
  ],
  "paths": {
    "/v1/service-sheets/{serviceSheetId}": {
      "get": {
        "tags": [
          "ServiceSheet"
        ],
        "summary": "Get a service sheet by Id",
        "description": "Get information about a specific service sheet with the given Id.",
        "parameters": [
          {
            "name": "serviceSheetId",
            "in": "path",
            "description": "the serviceSheet id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GetByIdResponse"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        }
      }
    },
    "/v1/service-sheets/status": {
      "put": {
        "tags": [
          "ServiceSheet"
        ],
        "summary": "Update a Service Sheet status based on the serviceSheetId",
        "description": "Change a specific Service Sheet status",
        "parameters": [
          {
            "name": "X-ME-CORRELATION-ID",
            "in": "header",
            "description": "Internal client code to be identified in the webhook. It can be, for example, a product code in your ERP, an order number, etc.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "description": "",
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateStatusCommand"
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "Accepted",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UpdateStatusResponse"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        }
      }
    },
    "/v1/service-sheets": {
      "delete": {
        "tags": [
          "ServiceSheet"
        ],
        "summary": "Cancel a service sheet",
        "description": "Cancels a service sheet specified by its serviceSheetHeaderId.",
        "parameters": [
          {
            "name": "X-ME-CORRELATION-ID",
            "in": "header",
            "description": "Internal client code to be identified in the webhook. It can be, for example, a product code in your ERP, an order number, etc.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "description": "",
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DeleteCommand"
              }
            },
            "text/json": {
              "schema": {
                "$ref": "#/components/schemas/DeleteCommand"
              }
            },
            "application/*+json": {
              "schema": {
                "$ref": "#/components/schemas/DeleteCommand"
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "Accepted",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DeleteResponse"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        }
      }
    },
    "/v1/service-sheets-document/{serviceSheetHeaderId}": {
      "get": {
        "tags": [
          "ServiceSheetDocument"
        ],
        "summary": "Get a service sheet",
        "description": "Get information about a specific service sheet with the given Id.",
        "parameters": [
          {
            "name": "serviceSheetHeaderId",
            "in": "path",
            "description": "the ServiceSheet header id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GetByHeaderIdResponse"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        }
      }
    },
    "/v1/service-sheets-document/status": {
      "put": {
        "tags": [
          "ServiceSheetDocument"
        ],
        "summary": "Update a Service Sheet status",
        "description": "Updates a Service Sheet status specified by its serviceSheetHeaderId",
        "parameters": [
          {
            "name": "X-ME-CORRELATION-ID",
            "in": "header",
            "description": "Internal client code to be identified in the webhook. It can be, for example, a product code in your ERP, an order number, etc.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "description": "",
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateStatusCommand2"
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "Accepted",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UpdateStatusResponse2"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        }
      }
    },
    "/v1/service-sheets-document": {
      "post": {
        "tags": [
          "ServiceSheetDocument"
        ],
        "summary": "Create a service sheet",
        "description": "Creates a new service sheet by providing the Description, Status, and other details.",
        "parameters": [
          {
            "name": "X-ME-CORRELATION-ID",
            "in": "header",
            "description": "Internal client code to be identified in the webhook. It can be, for example, a product code in your ERP, an order number, etc.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateCommand"
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "Accepted",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CreateResponse"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": [
          "ServiceSheetDocument"
        ],
        "summary": "Cancel a service sheet",
        "description": "Cancels a service sheet specified by its serviceSheetHeaderId.",
        "parameters": [
          {
            "name": "X-ME-CORRELATION-ID",
            "in": "header",
            "description": "Internal client code to be identified in the webhook. It can be, for example, a product code in your ERP, an order number, etc.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "description": "",
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DeleteCommand2"
              }
            },
            "text/json": {
              "schema": {
                "$ref": "#/components/schemas/DeleteCommand2"
              }
            },
            "application/*+json": {
              "schema": {
                "$ref": "#/components/schemas/DeleteCommand2"
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "Accepted",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DeleteResponse2"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "AddServiceSheet": {
        "type": "object",
        "properties": {
          "clientOrderId": {
            "type": "string",
            "nullable": true
          },
          "itemId": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "clientServiceSheetId": {
            "type": "string"
          },
          "description": {
            "type": "string",
            "nullable": true
          },
          "initialDate": {
            "type": "string",
            "format": "date-time"
          },
          "issueDate": {
            "type": "string",
            "format": "date-time"
          },
          "endDate": {
            "type": "string",
            "format": "date-time"
          },
          "status": {
            "type": "integer",
            "format": "int32"
          },
          "createdBy": {
            "type": "string",
            "nullable": true
          },
          "approvalDate": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "approvalNote": {
            "type": "string",
            "nullable": true
          },
          "clientContractId": {
            "type": "string",
            "nullable": true
          },
          "clientContractItemID": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "category": {
            "type": "string",
            "nullable": true
          },
          "quantity": {
            "type": "number",
            "format": "double"
          },
          "measurementUnit": {
            "type": "string"
          },
          "value": {
            "type": "number",
            "format": "double"
          },
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SubItemModel"
            },
            "nullable": true
          },
          "orderId": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "CreateCommand": {
        "type": "object",
        "properties": {
          "clientOrderId": {
            "type": "string"
          },
          "createdBy": {
            "type": "string"
          },
          "serviceSheets": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/AddServiceSheet"
            }
          },
          "orderId": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "currencyCode": {
            "type": "string",
            "nullable": true
          },
          "clientSupplierCode": {
            "type": "string",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "CreateResponse": {
        "type": "object",
        "properties": {
          "correlationId": {
            "type": "string"
          }
        },
        "additionalProperties": false
      },
      "DeleteCommand": {
        "type": "object",
        "properties": {
          "serviceSheetId": {
            "type": "integer",
            "description": "ME Service sheet Id",
            "format": "int32",
            "nullable": true
          },
          "clientServiceSheetId": {
            "type": "string",
            "description": "Service sheet id in the client's ERP",
            "nullable": true
          },
          "note": {
            "type": "string",
            "description": "Notes",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "DeleteCommand2": {
        "type": "object",
        "properties": {
          "serviceSheetHeaderId": {
            "type": "integer",
            "description": "ME Service sheet header Id",
            "format": "int64",
            "nullable": true
          },
          "clientServiceSheetId": {
            "type": "string",
            "description": "Service sheet id in the client's ERP",
            "nullable": true
          },
          "note": {
            "type": "string",
            "description": "Notes",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "DeleteResponse": {
        "type": "object",
        "properties": {
          "correlationId": {
            "type": "string"
          }
        },
        "additionalProperties": false
      },
      "DeleteResponse2": {
        "type": "object",
        "properties": {
          "correlationId": {
            "type": "string"
          }
        },
        "additionalProperties": false
      },
      "GetByHeaderIdResponse": {
        "type": "object",
        "properties": {
          "serviceSheets": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ServiceSheet"
            },
            "description": "List of service sheets"
          }
        },
        "additionalProperties": false
      },
      "GetByIdResponse": {
        "type": "object",
        "properties": {
          "clientOrderId": {
            "type": "string",
            "description": "Order Client Id"
          },
          "orderId": {
            "type": "integer",
            "description": "Order Id",
            "format": "int32"
          },
          "clientFRSId": {
            "type": "string",
            "description": "Service sheet code"
          },
          "itemId": {
            "type": "integer",
            "description": "Item Id",
            "format": "int32"
          },
          "serviceSheetId": {
            "type": "integer",
            "description": "The Id of the ME",
            "format": "int32"
          },
          "complement": {
            "type": "string",
            "description": "Complement"
          },
          "measurementUnit": {
            "type": "string",
            "description": "MeasurementUnit"
          },
          "quantity": {
            "type": "number",
            "description": "Quantity",
            "format": "float",
            "nullable": true
          },
          "description": {
            "type": "string",
            "description": "Description"
          },
          "value": {
            "type": "number",
            "description": "The order value",
            "format": "float",
            "nullable": true
          },
          "initialDate": {
            "type": "string",
            "description": "Service sheet Initial Date",
            "format": "date-time"
          },
          "issueDate": {
            "type": "string",
            "description": "Service sheet Issue Date",
            "format": "date-time"
          },
          "endDate": {
            "type": "string",
            "description": "Service sheet End Date",
            "format": "date-time"
          },
          "isCanceled": {
            "type": "boolean",
            "description": "Indicates if the service sheet was canceled",
            "nullable": true
          },
          "status": {
            "type": "integer",
            "description": "Service sheet status",
            "format": "int32"
          },
          "approvalDate": {
            "type": "string",
            "description": "Service sheet approval date",
            "format": "date-time",
            "nullable": true
          },
          "approvalNote": {
            "type": "string",
            "description": "Notes on the approval"
          },
          "createdBy": {
            "type": "string",
            "description": "User who created the service sheet"
          },
          "clientContractId": {
            "type": "string",
            "description": "The ID of the ERP Contract"
          },
          "category": {
            "type": "string",
            "description": "Service sheet category"
          }
        },
        "additionalProperties": false
      },
      "ProblemDetails": {
        "type": "object",
        "properties": {
          "type": {
            "type": "string",
            "nullable": true
          },
          "title": {
            "type": "string",
            "nullable": true
          },
          "status": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "detail": {
            "type": "string",
            "nullable": true
          },
          "instance": {
            "type": "string",
            "nullable": true
          }
        },
        "additionalProperties": {}
      },
      "ServiceSheet": {
        "type": "object",
        "properties": {
          "tenantId": {
            "type": "integer",
            "format": "int32"
          },
          "serviceSheetId": {
            "type": "integer",
            "format": "int32"
          },
          "orderId": {
            "type": "integer",
            "format": "int32"
          },
          "clientOrderId": {
            "type": "string"
          },
          "itemId": {
            "type": "integer",
            "format": "int32"
          },
          "clientFRSId": {
            "type": "string"
          },
          "description": {
            "type": "string"
          },
          "complement": {
            "type": "string"
          },
          "quantity": {
            "type": "number",
            "format": "float",
            "nullable": true
          },
          "measurementUnit": {
            "type": "string"
          },
          "value": {
            "type": "number",
            "format": "float",
            "nullable": true
          },
          "issueDate": {
            "type": "string",
            "format": "date-time"
          },
          "initialDate": {
            "type": "string",
            "format": "date-time"
          },
          "endDate": {
            "type": "string",
            "format": "date-time"
          },
          "status": {
            "type": "integer",
            "format": "int32"
          },
          "isCanceled": {
            "type": "boolean",
            "nullable": true
          },
          "approvalDate": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "approvalNote": {
            "type": "string"
          },
          "category": {
            "type": "string"
          },
          "clientContractId": {
            "type": "string"
          },
          "createdBy": {
            "type": "string"
          },
          "subItems": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SubItemModel"
            },
            "nullable": true
          },
          "serviceSheetHeaderId": {
            "type": "integer",
            "format": "int64",
            "nullable": true
          },
          "statusHeader": {
            "type": "integer",
            "format": "int32"
          }
        },
        "additionalProperties": false
      },
      "SubItemModel": {
        "type": "object",
        "properties": {
          "subItem": {
            "type": "integer",
            "format": "int32"
          },
          "description": {
            "type": "string"
          },
          "quantity": {
            "type": "number",
            "format": "double"
          },
          "measurementUnit": {
            "type": "string"
          },
          "value": {
            "type": "number",
            "format": "double"
          },
          "decimalNumbering": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "UpdateStatusCommand": {
        "type": "object",
        "properties": {
          "serviceSheetId": {
            "type": "integer",
            "description": "ME Service sheet Id",
            "format": "int32",
            "nullable": true
          },
          "clientServiceSheetId": {
            "type": "string",
            "description": "Service sheet id in the client's ERP",
            "nullable": true
          },
          "clientOrderId": {
            "type": "string",
            "description": "Order Id in the client's ERP",
            "nullable": true
          },
          "item": {
            "type": "integer",
            "description": "Service sheet items",
            "format": "int32",
            "nullable": true
          },
          "status": {
            "type": "integer",
            "description": "Service sheet status",
            "format": "int32"
          },
          "note": {
            "type": "string",
            "description": "Notes",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Contract status"
      },
      "UpdateStatusCommand2": {
        "type": "object",
        "properties": {
          "serviceSheetHeaderId": {
            "type": "integer",
            "description": "ME Service sheet header Id",
            "format": "int64",
            "nullable": true
          },
          "clientServiceSheetId": {
            "type": "string",
            "description": "Service sheet id in the client's ERP",
            "nullable": true
          },
          "status": {
            "type": "integer",
            "description": "Service sheet status\r\n\r\nPossible status:\r\n- 1 = Approved\r\n- 2 = Refused/Inconsistency\r\n- 3 = Canceled",
            "format": "int32"
          },
          "note": {
            "type": "string",
            "description": "Notes",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Contract status"
      },
      "UpdateStatusResponse": {
        "type": "object",
        "properties": {
          "correlationId": {
            "type": "string"
          }
        },
        "additionalProperties": false
      },
      "UpdateStatusResponse2": {
        "type": "object",
        "properties": {
          "correlationId": {
            "type": "string"
          }
        },
        "additionalProperties": false
      }
    },
    "securitySchemes": {
      "Bearer": {
        "type": "apiKey",
        "description": "Please enter the word 'Bearer' followed by a space and then your JWT.",
        "name": "Authorization",
        "in": "header"
      }
    }
  },
  "security": [
    {
      "Bearer": []
    }
  ]
}