{
  "openapi": "3.0.4",
  "info": {
    "title": "Payment Conditions API",
    "version": "1.0"
  },
  "servers": [
    {
      "url": "https://api.mercadoe.com"
    }
  ],
  "paths": {
    "/v1/payment-conditions": {
      "post": {
        "tags": [
          "Payment Conditions"
        ],
        "summary": "Create a payment condition",
        "description": "Creates a new Payment condition by providing its description, number of installments, and other details.",
        "requestBody": {
          "description": "",
          "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": [
          "Payment Conditions"
        ],
        "summary": "Get all payment conditions",
        "description": "Get a list of all payment conditions available to the connected user.",
        "parameters": [
          {
            "name": "pageNumber",
            "in": "query",
            "description": "",
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "pageSize",
            "in": "query",
            "description": "",
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "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/payment-conditions/{paymentConditionId}": {
      "put": {
        "tags": [
          "Payment Conditions"
        ],
        "summary": "Update a payment condition",
        "description": "Updates a payment condition specified by its paymentConditionId.",
        "parameters": [
          {
            "name": "paymentConditionId",
            "in": "path",
            "description": "",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "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"
                }
              }
            }
          }
        }
      },
      "get": {
        "tags": [
          "Payment Conditions"
        ],
        "summary": "Get a payment condition",
        "description": "Get information about a specific payment condition with the given paymentConditionId.",
        "parameters": [
          {
            "name": "paymentConditionId",
            "in": "path",
            "description": "",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GetPaymentConditionByIdResponse"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": [
          "Payment Conditions"
        ],
        "summary": "Delete a payment condition",
        "description": "Deletes a payment condition specified by its paymentConditionId.",
        "parameters": [
          {
            "name": "paymentConditionId",
            "in": "path",
            "description": "",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "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/payment-conditions/{paymentConditionId}/business-organizations": {
      "get": {
        "tags": [
          "Payment Conditions"
        ],
        "summary": "Get all business organizations related to a payment condition",
        "description": "Get a list of all business organizations for a specific payment condition with the given paymentConditionId.",
        "parameters": [
          {
            "name": "paymentConditionId",
            "in": "path",
            "description": "",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "pageNumber",
            "in": "query",
            "description": "",
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "pageSize",
            "in": "query",
            "description": "",
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GetBusinessOrganizationByPaymentConditionIdResponse"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        }
      }
    },
    "/v1/payment-conditions/{paymentConditionId}/relationship/delete": {
      "post": {
        "tags": [
          "Payment Conditions"
        ],
        "summary": "Delete a relationship between a list of business organizations and a payment condition",
        "description": "Deletes the relationship between a list of business organizations and a payment condition specified by its paymentConditionId and the list of business organizations.",
        "parameters": [
          {
            "name": "paymentConditionId",
            "in": "path",
            "description": "",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "description": "",
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DeleteRelationshipCommand"
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "Accepted",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DeleteRelationshipResponse"
                }
              }
            }
          },
          "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"
        ],
        "type": "object",
        "properties": {
          "code": {
            "minLength": 1,
            "type": "string",
            "description": "Business organization id in the client's ERP"
          },
          "entityType": {
            "type": "string",
            "description": "It is the type of organizational structure. Example: Company, branch, department.",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "BusinessOrganizationModel": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "description": "Business organization id in the client's ERP",
            "nullable": true
          },
          "entityType": {
            "type": "string",
            "description": "Type of organizational structure. Example: Company, branch, department.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Business organization WF"
      },
      "CreateCommand": {
        "type": "object",
        "properties": {
          "clientPaymentConditionId": {
            "type": "string",
            "description": "Payment condition Id in the client's ERP",
            "nullable": true
          },
          "installments": {
            "type": "string",
            "description": "Installments description",
            "nullable": true
          },
          "isDisabled": {
            "type": "boolean",
            "description": "It indicates if this payment condition option is not available.",
            "nullable": true
          },
          "isForeignTradeDisabled": {
            "type": "boolean",
            "description": "Is it possible to block foreign trade?",
            "nullable": true
          },
          "paymentTerm": {
            "type": "integer",
            "description": "Payment term description",
            "format": "int32",
            "nullable": true
          },
          "areFreeInstallments": {
            "type": "boolean",
            "description": "If the free installment plan is true, the client will enter an installment plan.",
            "nullable": true
          },
          "maximumInstallments": {
            "type": "integer",
            "description": "Maximum number of installments",
            "format": "int32",
            "nullable": true
          },
          "note": {
            "type": "string",
            "description": "Note about the payment condition",
            "nullable": true
          },
          "invoicePaymentTerm": {
            "type": "integer",
            "description": "Days until installment due",
            "format": "int32",
            "nullable": true
          },
          "descriptions": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "enUS": {
                  "type": "string"
                },
                "esES": {
                  "type": "string"
                },
                "esMX": {
                  "type": "string"
                },
                "ptBR": {
                  "type": "string"
                },
                "ptPT": {
                  "type": "string"
                }
              },
              "additionalProperties": false
            },
            "description": "Descriptions in different languages."
          },
          "businessOrganizations": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/BusinessOrganization"
            },
            "description": "The Business Organizations list comprises the Company Code and the Entity Type."
          }
        },
        "additionalProperties": false,
        "description": "It is a command to create a payment condition."
      },
      "CreateResponse": {
        "type": "object",
        "properties": {
          "correlationId": {
            "type": "string",
            "description": ""
          }
        },
        "additionalProperties": false,
        "description": "It is a response for creating a payment condition."
      },
      "DeleteRelationshipCommand": {
        "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,
        "description": "It is a command to delete a relationship between a payment condition and a business organization."
      },
      "DeleteRelationshipResponse": {
        "type": "object",
        "properties": {
          "correlationId": {
            "type": "string",
            "description": ""
          }
        },
        "additionalProperties": false,
        "description": "It is a response to deleting the relationship."
      },
      "DeleteResponse": {
        "type": "object",
        "properties": {
          "correlationId": {
            "type": "string",
            "description": ""
          }
        },
        "additionalProperties": false,
        "description": "It is a response to the delete payment condition command."
      },
      "GetAllResponse": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PaymentConditionIdentifier"
            },
            "description": ""
          },
          "hits": {
            "type": "integer",
            "description": "",
            "format": "int32"
          }
        },
        "additionalProperties": false,
        "description": "It is a response to getting all payment conditions."
      },
      "GetBusinessOrganizationByPaymentConditionIdResponse": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/BusinessOrganizationModel"
            },
            "description": ""
          },
          "hits": {
            "type": "integer",
            "description": "",
            "format": "int32"
          }
        },
        "additionalProperties": false,
        "description": "It is a response to getting all business organizations by payment condition."
      },
      "GetPaymentConditionByIdResponse": {
        "type": "object",
        "properties": {
          "paymentConditionId": {
            "type": "integer",
            "description": "ME Payment condition Id",
            "format": "int32"
          },
          "clientPaymentConditionId": {
            "type": "string",
            "description": "Payment condition Id in the client's ERP",
            "nullable": true
          },
          "installments": {
            "type": "string",
            "description": "Description of installments",
            "nullable": true
          },
          "isDisabled": {
            "type": "boolean",
            "description": "It indicates if this payment condition option is not available.",
            "nullable": true
          },
          "isForeignTradeDisabled": {
            "type": "boolean",
            "description": "Is it possible to block foreign trade?",
            "nullable": true
          },
          "paymentTerm": {
            "type": "integer",
            "description": "The number of days within which payment is due",
            "format": "int32",
            "nullable": true
          },
          "areFreeInstallments": {
            "type": "boolean",
            "description": "If the free installment plan is true, the client will enter an installment plan.",
            "nullable": true
          },
          "maximumInstallments": {
            "type": "integer",
            "description": "Number of installments",
            "format": "int32",
            "nullable": true
          },
          "note": {
            "type": "string",
            "description": "Note about the payment condition",
            "nullable": true
          },
          "invoicePaymentTerm": {
            "type": "integer",
            "description": "Days until installment due",
            "format": "int32",
            "nullable": true
          },
          "descriptions": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "enUS": {
                  "type": "string"
                },
                "esES": {
                  "type": "string"
                },
                "esMX": {
                  "type": "string"
                },
                "ptBR": {
                  "type": "string"
                },
                "ptPT": {
                  "type": "string"
                }
              },
              "additionalProperties": false
            },
            "description": "Descriptions in different languages."
          },
          "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,
        "description": "It is a response to getting a payment condition by Id."
      },
      "PaymentConditionIdentifier": {
        "type": "object",
        "properties": {
          "paymentConditionId": {
            "type": "integer",
            "description": "ME Payment condition Id",
            "format": "int32"
          },
          "description": {
            "type": "string",
            "description": "Payment condition description"
          },
          "clientPaymentConditionId": {
            "type": "string",
            "description": "Payment condition Id in the client's ERP"
          },
          "isDisabled": {
            "type": "boolean",
            "description": "It indicates if this payment condition option is not available."
          }
        },
        "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": {}
      },
      "UpdateCommand": {
        "type": "object",
        "properties": {
          "clientPaymentConditionId": {
            "type": "string",
            "description": "Payment condition Id in the client's ERP",
            "nullable": true
          },
          "installments": {
            "type": "string",
            "description": "Installments description",
            "nullable": true
          },
          "isDisabled": {
            "type": "boolean",
            "description": "It indicates if this payment condition option is not available.",
            "nullable": true
          },
          "isForeignTradeDisabled": {
            "type": "boolean",
            "description": "Is it possible to block foreign trade?",
            "nullable": true
          },
          "paymentTerm": {
            "type": "integer",
            "description": "Payment term description",
            "format": "int32",
            "nullable": true
          },
          "areFreeInstallments": {
            "type": "boolean",
            "description": "If the free installment plan is true, the client will enter an installment plan.",
            "nullable": true
          },
          "maximumInstallments": {
            "type": "integer",
            "description": "Maximum number of installments",
            "format": "int32",
            "nullable": true
          },
          "note": {
            "type": "string",
            "description": "Note about the payment condition",
            "nullable": true
          },
          "invoicePaymentTerm": {
            "type": "integer",
            "description": "Days until installment due",
            "format": "int32",
            "nullable": true
          },
          "descriptions": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "enUS": {
                  "type": "string"
                },
                "esES": {
                  "type": "string"
                },
                "esMX": {
                  "type": "string"
                },
                "ptBR": {
                  "type": "string"
                },
                "ptPT": {
                  "type": "string"
                }
              },
              "additionalProperties": false
            },
            "description": "Descriptions in different languages."
          },
          "businessOrganizations": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/BusinessOrganization"
            },
            "description": "The Business Organizations list comprises the Company Code and the Entity Type."
          }
        },
        "additionalProperties": false,
        "description": "It is a command to update a payment condition."
      },
      "UpdateResponse": {
        "type": "object",
        "properties": {
          "correlationId": {
            "type": "string",
            "description": ""
          }
        },
        "additionalProperties": false,
        "description": "It is a response to the updating of a payment condition."
      }
    },
    "securitySchemes": {
      "bearer": {
        "type": "http",
        "description": "Please enter your JWT (Without the 'Bearer' word in the beginning).",
        "scheme": "bearer",
        "bearerFormat": "JWT"
      }
    }
  },
  "security": [
    {
      "bearer": []
    }
  ],
  "tags": [
    {
      "name": "Payment Conditions"
    }
  ]
}