{
  "openapi": "3.0.4",
  "info": {
    "title": "Permanent Assets API",
    "version": "1.0"
  },
  "servers": [
    {
      "url": "https://api.mercadoe.com"
    }
  ],
  "paths": {
    "/v1/permanent-assets": {
      "post": {
        "tags": [
          "Permanent Assets"
        ],
        "summary": "Create a Permanent Asset",
        "description": "Creates a new Permanent Asset by providing the ClientPermanentAssetId, Description, Status, and other details.",
        "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"
                }
              }
            }
          }
        }
      },
      "get": {
        "tags": [
          "Permanent Assets"
        ],
        "summary": "Get Permanent Assets",
        "description": "Get a list of all permanent assets available to the connected user.",
        "parameters": [
          {
            "name": "pageNumber",
            "in": "query",
            "description": "The page number in query pagination. Default is 1.",
            "schema": {
              "type": "integer",
              "format": "int32",
              "default": 1
            }
          },
          {
            "name": "pageSize",
            "in": "query",
            "description": "The page size in query pagination. Default is 10.",
            "schema": {
              "type": "integer",
              "format": "int32",
              "default": 10
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GetAllResponse"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        }
      }
    },
    "/v1/permanent-assets/{clientPermanentAssetId}": {
      "get": {
        "tags": [
          "Permanent Assets"
        ],
        "summary": "Get a Permanent Asset",
        "description": "Get information about a specific permanent asset with the given ClientPermanentAssetId.",
        "parameters": [
          {
            "name": "clientPermanentAssetId",
            "in": "path",
            "description": "Permanent Asset's ID",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GetByIdResponse"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        }
      },
      "patch": {
        "tags": [
          "Permanent Assets"
        ],
        "summary": "Update a Permanent Asset",
        "description": "Updates a Permanent Asset specified by its ClientPermanentAssetId.",
        "parameters": [
          {
            "name": "clientPermanentAssetId",
            "in": "path",
            "description": "Permanent Asset's ID",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "description": "",
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateCommand"
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "Accepted",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UpdateResponse"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": [
          "Permanent Assets"
        ],
        "summary": "Delete a Permanent Asset",
        "description": "Deletes (deactivates) a Permanent Asset specified by its ClientPermanentAssetId.",
        "parameters": [
          {
            "name": "clientPermanentAssetId",
            "in": "path",
            "description": "Permanent Asset's ID",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "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/permanent-assets/{clientPermanentAssetId}/relationships/delete": {
      "post": {
        "tags": [
          "Permanent Assets"
        ],
        "summary": "Delete a relationship between a list of Business Organizations and a Permanent Asset",
        "description": "Deletes the relationship between a list of business organizations and a permanent asset specified by its ClientPermanentAssetsId and the list of business organizations..",
        "parameters": [
          {
            "name": "clientPermanentAssetId",
            "in": "path",
            "description": "Permanent Asset's ID",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DeleteBorgRelationshipCommand"
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "Accepted",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DeleteBorgRelationshipResponse"
                }
              }
            }
          },
          "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": {
      "BusinessOrganization": {
        "required": [
          "code",
          "entityType"
        ],
        "type": "object",
        "properties": {
          "code": {
            "minLength": 1,
            "type": "string",
            "description": "Company code in the client's ERP"
          },
          "entityType": {
            "minLength": 1,
            "type": "string",
            "description": "Type of organizational structure. Example: Company, branch, department."
          }
        },
        "additionalProperties": false
      },
      "BusinessOrganizationModel": {
        "type": "object",
        "properties": {
          "businessOrganizationId": {
            "type": "integer",
            "description": "ME business organization id",
            "format": "int32",
            "nullable": true
          },
          "code": {
            "type": "string",
            "description": "Business organization id in the client's ERP",
            "nullable": true
          },
          "description": {
            "type": "string",
            "description": "Company description",
            "nullable": true
          },
          "virtualEntityField": {
            "type": "string",
            "description": "Delivery center/location code",
            "nullable": true
          },
          "virtualEntityDescription": {
            "type": "string",
            "description": "Delivery center/location description",
            "nullable": true
          },
          "entityType": {
            "type": "string",
            "description": "Type of organizational structure. Example: Company, branch, department.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Business organization WF"
      },
      "CreateCommand": {
        "required": [
          "clientPermanentAssetId",
          "isDeactivated"
        ],
        "type": "object",
        "properties": {
          "clientPermanentAssetId": {
            "minLength": 1,
            "type": "string",
            "description": "Permanent Asset's ID"
          },
          "description": {
            "type": "string",
            "description": "Description of the permanent asset",
            "nullable": true
          },
          "isDeactivated": {
            "type": "boolean",
            "description": "Flag to identify if the Permanent Asset is blocked"
          },
          "businessOrganizations": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/BusinessOrganization"
            },
            "description": "The Business Organizations list comprises the Company Code and the Entity Type.",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "CreateResponse": {
        "type": "object",
        "properties": {
          "correlationId": {
            "type": "string"
          }
        },
        "additionalProperties": false
      },
      "DeleteBorgRelationshipCommand": {
        "type": "object",
        "properties": {
          "businessOrganizations": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/BusinessOrganization"
            },
            "description": "The Business Organizations list comprises the Company Code and the Entity Type."
          }
        },
        "additionalProperties": false
      },
      "DeleteBorgRelationshipResponse": {
        "type": "object",
        "properties": {
          "correlationId": {
            "type": "string"
          }
        },
        "additionalProperties": false
      },
      "DeleteResponse": {
        "type": "object",
        "properties": {
          "correlationId": {
            "type": "string"
          }
        },
        "additionalProperties": false
      },
      "GetAllResponse": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PermanentAsset"
            }
          },
          "hits": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "GetByIdResponse": {
        "required": [
          "clientPermanentAssetId",
          "isDeactivated"
        ],
        "type": "object",
        "properties": {
          "clientPermanentAssetId": {
            "minLength": 1,
            "type": "string",
            "description": "Permanent Asset's ID"
          },
          "description": {
            "type": "string",
            "description": "Description of the permanent asset",
            "nullable": true
          },
          "isDeactivated": {
            "type": "boolean",
            "description": "Flag to identify if the Permanent Asset is blocked"
          },
          "businessOrganizations": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/BusinessOrganizationModel"
            },
            "description": "The Business Organizations list comprises the Company Code and the Entity Type.",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "PermanentAsset": {
        "type": "object",
        "properties": {
          "clientPermanentAssetId": {
            "type": "string",
            "description": "Permanent asset code in the client's ERP"
          },
          "description": {
            "type": "string",
            "description": "Description of the permanent asset",
            "nullable": true
          },
          "isDeactivated": {
            "type": "boolean",
            "description": "Flag to identify if the Permanent Asset is blocked"
          }
        },
        "additionalProperties": false,
        "description": "Permanent Asset"
      },
      "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": {}
      },
      "UpdateCommand": {
        "type": "object",
        "properties": {
          "description": {
            "type": "string",
            "description": "Permanent Asset's description",
            "nullable": true
          },
          "isDeactivated": {
            "type": "boolean",
            "description": "Flag to identify if the Permanent Asset is blocked"
          },
          "businessOrganizations": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/BusinessOrganization"
            },
            "description": "The Business Organizations list comprises the Company Code and the Entity Type.",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "UpdateResponse": {
        "type": "object",
        "properties": {
          "correlationId": {
            "type": "string"
          }
        },
        "additionalProperties": false
      }
    },
    "securitySchemes": {
      "bearer": {
        "type": "http",
        "description": "Please enter your JWT (Without the 'Bearer' word in the beginning).",
        "scheme": "bearer",
        "bearerFormat": "JWT"
      }
    }
  },
  "security": [
    {
      "bearer": []
    }
  ],
  "tags": [
    {
      "name": "Permanent Assets"
    }
  ]
}