{
  "openapi": "3.0.1",
  "info": {
    "title": "Decision Table API",
    "version": "1.0"
  },
  "servers": [
    {
      "url": "https://api.mercadoe.com"
    }
  ],
  "paths": {
    "/v1/decision-table": {
      "post": {
        "tags": [
          "Decision Table"
        ],
        "summary": "Create a decision table",
        "description": "Create a new decision table by providing the TableName and TableRows fields. \r\nThe purpose of this endpoint is to complete the ME approval tables.",
        "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": [
          "Decision Table"
        ],
        "summary": "Delete a decision table",
        "description": "Delete a decision table with the given CorrelationId.",
        "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/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"
                }
              }
            }
          }
        }
      },
      "put": {
        "tags": [
          "Decision Table"
        ],
        "summary": "Update a decision table",
        "description": "Update a decision table with the given CorrelationId.",
        "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/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"
                }
              }
            }
          }
        }
      }
    },
    "/v1/decision-table/delete": {
      "post": {
        "tags": [
          "Decision Table"
        ],
        "summary": "Delete a decision table",
        "description": "Delete a decision table with the given CorrelationId.",
        "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/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/decision-table/{tableName}": {
      "get": {
        "tags": [
          "Decision Table"
        ],
        "summary": "Get the table rows from a decision table",
        "description": "Get all rows of a decision table with the given tableName.",
        "parameters": [
          {
            "name": "tableName",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "pageSize",
            "in": "query",
            "schema": {
              "type": "integer",
              "format": "int32",
              "default": 10
            }
          },
          {
            "name": "pageNumber",
            "in": "query",
            "schema": {
              "type": "integer",
              "format": "int32",
              "default": 1
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GetDecisionTableResponse"
                }
              }
            }
          },
          "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": {
      "CreateCommand": {
        "required": [
          "tableName",
          "tableRows"
        ],
        "type": "object",
        "properties": {
          "tableName": {
            "maxLength": 30,
            "minLength": 1,
            "type": "string",
            "description": "Name of the ME approval table that will be filled."
          },
          "tableRows": {
            "minItems": 1,
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TableRow"
            },
            "description": "List with the `ColumnName` and `Value` fields that form the approval table rows."
          }
        },
        "additionalProperties": false
      },
      "CreateResponse": {
        "type": "object",
        "properties": {
          "correlationId": {
            "type": "string"
          }
        },
        "additionalProperties": false
      },
      "DeleteCommand": {
        "required": [
          "tableName",
          "tableRows"
        ],
        "type": "object",
        "properties": {
          "tableName": {
            "maxLength": 20,
            "minLength": 1,
            "type": "string",
            "description": "Name of the ME approval table that will be filled."
          },
          "tableRows": {
            "minItems": 1,
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TableRow"
            },
            "description": "List with the `ColumnName` and `Value` fields that form the approval table rows."
          }
        },
        "additionalProperties": false
      },
      "DeleteResponse": {
        "type": "object",
        "properties": {
          "correlationId": {
            "type": "string"
          }
        },
        "additionalProperties": false
      },
      "GetDecisionTableResponse": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/GetDecisionTableResponseData"
            }
          },
          "hits": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "next": {
            "type": "string",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "GetDecisionTableResponseData": {
        "type": "object",
        "properties": {
          "rows": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Row"
            },
            "description": "Approval rule rows in the decision table"
          }
        },
        "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": {}
      },
      "Row": {
        "required": [
          "columnName"
        ],
        "type": "object",
        "properties": {
          "columnName": {
            "minLength": 1,
            "type": "string",
            "description": "Column name within the approval table."
          },
          "value": {
            "type": "string",
            "description": "Value that will be filled in the specified approval table's column."
          }
        },
        "additionalProperties": false
      },
      "TableRow": {
        "required": [
          "columnName"
        ],
        "type": "object",
        "properties": {
          "columnName": {
            "minLength": 1,
            "type": "string"
          },
          "value": {
            "type": "string"
          }
        },
        "additionalProperties": false
      },
      "UpdateCommand": {
        "required": [
          "tableName",
          "tableRows"
        ],
        "type": "object",
        "properties": {
          "tableName": {
            "maxLength": 30,
            "minLength": 1,
            "type": "string",
            "description": "Name of the ME approval table that will be filled."
          },
          "tableRows": {
            "minItems": 1,
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TableRow"
            },
            "description": "List with the `ColumnName` and `Value` fields that form the approval table rows."
          }
        },
        "additionalProperties": false
      },
      "UpdateResponse": {
        "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": []
    }
  ]
}