{
  "openapi": "3.0.1",
  "info": {
    "title": "WBS Element API",
    "version": "1.0"
  },
  "servers": [
    {
      "url": "https://api.mercadoe.com"
    }
  ],
  "paths": {
    "/v1/wbs-elements": {
      "post": {
        "tags": [
          "WBS Elements"
        ],
        "summary": "Create a WBS element",
        "description": "Create a new WBS element by providing the WBS element code, description and other details.",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateWbsElementCommand"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CreateWbsElementResponse"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        }
      },
      "get": {
        "tags": [
          "WBS Elements"
        ],
        "summary": "Get WBS Elements",
        "description": "Get a list of all WBS elements that are 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/GetAllWbsElementsResponse"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        }
      }
    },
    "/v1/wbs-elements/{wbsElementCode}": {
      "put": {
        "tags": [
          "WBS Elements"
        ],
        "summary": "Update a WBS element",
        "description": "Updates a WBS element specified by its wbsElementCode.",
        "parameters": [
          {
            "name": "wbsElementCode",
            "in": "path",
            "description": "The client WBS element code.",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "description": "",
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateWbsElementCommand"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UpdateWbsElementResponse"
                }
              }
            }
          },
          "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": [
          "WBS Elements"
        ],
        "summary": "Delete a WBS element",
        "description": "Deletes a WBS element by providing the wbsElementCode.",
        "parameters": [
          {
            "name": "wbsElementCode",
            "in": "path",
            "description": "The client WBS element code.",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DeleteWbsElementResponse"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        }
      }
    },
    "/v1/wbs-elements/{wbsElementCode}/business-organizations/delete": {
      "post": {
        "tags": [
          "WBS Elements Relationships"
        ],
        "summary": "Delete a relationship between a list of Business Organizations and a WBS element",
        "description": "Deletes a relationship between a WBS element and a list of Business Organizations specified by its wbsElementCode and the Business Organizations details.",
        "parameters": [
          {
            "name": "wbsElementCode",
            "in": "path",
            "description": "The client WBS element code.",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "description": "",
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DeleteWbsElementBorgsCommand"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DeleteWbsElementBorgsResponse"
                }
              }
            }
          },
          "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/wbs-elements/{wbsElementCode}/business-organizations": {
      "get": {
        "tags": [
          "WBS Elements Relationships"
        ],
        "summary": "Get all business organizations related to a WBS Element",
        "description": "Get a list of all business organizations for a specific WBS element with the given wbsElementCode.",
        "parameters": [
          {
            "name": "wbsElementCode",
            "in": "path",
            "description": "The client WBS element code.",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "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/GetAllWbsElementBorgsResponse"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "CreateWbsElementCommand": {
        "required": [
          "wbsElementCode"
        ],
        "type": "object",
        "properties": {
          "wbsElementCode": {
            "maxLength": 30,
            "minLength": 1,
            "type": "string",
            "description": "WBS element code."
          },
          "description": {
            "maxLength": 100,
            "type": "string",
            "description": "WBS element description.",
            "nullable": true
          },
          "isActive": {
            "type": "boolean",
            "description": "This flag indicates if the WBS element is active or not. The default is true.",
            "nullable": true
          },
          "businessOrganizations": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/NonNullableBorg"
            },
            "description": "The Business Organizations list comprises the Company Code and the Entity Type.",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "CreateWbsElementResponse": {
        "type": "object",
        "properties": {
          "correlationId": {
            "type": "string"
          }
        },
        "additionalProperties": false
      },
      "DeleteWbsElementBorgsCommand": {
        "required": [
          "businessOrganizations"
        ],
        "type": "object",
        "properties": {
          "businessOrganizations": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/NonNullableBorg"
            },
            "description": "The Business Organizations list comprises the Company Code and the Entity Type."
          }
        },
        "additionalProperties": false
      },
      "DeleteWbsElementBorgsResponse": {
        "type": "object",
        "properties": {
          "correlationId": {
            "type": "string"
          }
        },
        "additionalProperties": false
      },
      "DeleteWbsElementResponse": {
        "type": "object",
        "properties": {
          "correlationId": {
            "type": "string"
          }
        },
        "additionalProperties": false
      },
      "GetAllWbsElementBorgsResponse": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/GetAllWbsElementBorgsResponseData"
            }
          },
          "hits": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "next": {
            "type": "string",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "GetAllWbsElementBorgsResponseData": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "description": "Business organization code in the client's ERP.",
            "nullable": true
          },
          "entityType": {
            "type": "string",
            "description": "Type of organizational structure. Example: Company, branch, department.",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "GetAllWbsElementsResponse": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/GetAllWbsElementsResponseData"
            }
          },
          "hits": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "next": {
            "type": "string",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "GetAllWbsElementsResponseData": {
        "type": "object",
        "properties": {
          "wbsElementCode": {
            "type": "string",
            "description": "WBS element code."
          },
          "description": {
            "type": "string",
            "description": "WBS element description.",
            "nullable": true
          },
          "isActive": {
            "type": "boolean",
            "description": "This flag indicates if the WBS element is active or not."
          }
        },
        "additionalProperties": false
      },
      "NonNullableBorg": {
        "required": [
          "code",
          "entityType"
        ],
        "type": "object",
        "properties": {
          "code": {
            "minLength": 1,
            "type": "string",
            "description": "Business organization code in the client's ERP."
          },
          "entityType": {
            "minLength": 1,
            "type": "string",
            "description": "Type of organizational structure. Example: Company, branch, department."
          }
        },
        "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": {}
      },
      "UpdateWbsElementCommand": {
        "type": "object",
        "properties": {
          "description": {
            "maxLength": 100,
            "type": "string",
            "description": "WBS element description.",
            "nullable": true
          },
          "isActive": {
            "type": "boolean",
            "description": "This flag indicates if the WBS element is active or not.",
            "nullable": true
          },
          "businessOrganizations": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/NonNullableBorg"
            },
            "description": "The Business Organizations list comprises the Company Code and the Entity Type.",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "UpdateWbsElementResponse": {
        "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": []
    }
  ]
}