{
  "openapi": "3.0.1",
  "info": {
    "title": "Currencies API",
    "version": "1.0"
  },
  "servers": [
    {
      "url": "https://api.mercadoe.com"
    }
  ],
  "paths": {
    "/v1/currencies": {
      "post": {
        "tags": [
          "Currencies"
        ],
        "summary": "Create a Currency",
        "description": "Creates a new Currency by providing the CurrencyCode, Description, ConversionAvailability, CurrencyAvailability, 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": [
          "Currencies"
        ],
        "summary": "Get Currencies",
        "description": "Get a list of all currencies 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": 20
            }
          }
        ],
        "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/currencies/{currencyCode}": {
      "get": {
        "tags": [
          "Currencies"
        ],
        "summary": "Get Currency by CurrencyCode",
        "description": "Get information about a specific currency with the given CurrencyCode.",
        "parameters": [
          {
            "name": "currencyCode",
            "in": "path",
            "description": "Currency in alphabetic code (for more information, please refer to: https://www.iso.org/iso-4217-currency-codes.html).",
            "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": [
          "Currencies"
        ],
        "summary": "Update a Currency based on the CurrencyCode",
        "description": "Updates a currency specified by its CurrencyCode.",
        "parameters": [
          {
            "name": "currencyCode",
            "in": "path",
            "description": "Currency in alphabetic code (for more information, please refer to: https://www.iso.org/iso-4217-currency-codes.html).",
            "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": [
          "Currencies"
        ],
        "summary": "Delete a currency based on the CurrencyCode",
        "description": "Deletes a currency specified by its CurrencyCode.",
        "parameters": [
          {
            "name": "currencyCode",
            "in": "path",
            "description": "Currency in alphabetic code (for more information, please refer to: https://www.iso.org/iso-4217-currency-codes.html).",
            "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/currencies/{currencyCode}/relationships/delete": {
      "post": {
        "tags": [
          "Currencies"
        ],
        "summary": "Delete a relationship between a list of Business Organizations and a Currency",
        "description": "Deletes a currency and business organization relationship specified by its CurrencyCode and list of business organizations.",
        "parameters": [
          {
            "name": "currencyCode",
            "in": "path",
            "description": "Currency in alphabetic code (for more information, please refer to: https://www.iso.org/iso-4217-currency-codes.html).",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DeleteBusinessOrganizationRelationshipCommand"
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "Accepted",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DeleteBusinessOrganizationRelationshipResponse"
                }
              }
            }
          },
          "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": {
            "maxLength": 50,
            "type": "string",
            "description": "Type of organizational structure. Example: Company, branch, department.",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "BusinessOrganizationModel": {
        "type": "object",
        "properties": {
          "businessOrganizationId": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "clientBusinessOrganizationId": {
            "type": "string",
            "nullable": true
          },
          "description": {
            "type": "string",
            "nullable": true
          },
          "virtualEntityField": {
            "type": "string",
            "nullable": true
          },
          "virtualEntityDescription": {
            "type": "string",
            "nullable": true
          },
          "entityType": {
            "type": "string",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "ConversionAvailability": {
        "enum": [
          "DomesticConversion",
          "InternationalConversion",
          "BothConversions"
        ],
        "type": "string"
      },
      "CreateCommand": {
        "required": [
          "conversionAvailability",
          "currencyAvailability",
          "currencyCode",
          "descriptions"
        ],
        "type": "object",
        "properties": {
          "currencyAvailability": {
            "$ref": "#/components/schemas/CurrencyAvailability"
          },
          "conversionAvailability": {
            "$ref": "#/components/schemas/ConversionAvailability"
          },
          "descriptions": {
            "minItems": 1,
            "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": "List with the Business Organizations comprising the Company Code and the Entity Type.",
            "nullable": true
          },
          "currencyCode": {
            "maxLength": 3,
            "minLength": 1,
            "type": "string",
            "description": "Currency in alphabetic code (for more information, please refer to: https://www.iso.org/iso-4217-currency-codes.html)."
          }
        },
        "additionalProperties": false
      },
      "CreateResponse": {
        "type": "object",
        "properties": {
          "correlationId": {
            "type": "string"
          }
        },
        "additionalProperties": false
      },
      "CurrencyAvailability": {
        "enum": [
          "DomesticAvailability",
          "InternationalAvailability",
          "BothAvailabilities"
        ],
        "type": "string"
      },
      "CurrencyIdentifierModel": {
        "type": "object",
        "properties": {
          "currencyCode": {
            "type": "string",
            "nullable": true
          },
          "description": {
            "type": "string",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "DeleteBusinessOrganizationRelationshipCommand": {
        "required": [
          "businessOrganizations"
        ],
        "type": "object",
        "properties": {
          "businessOrganizations": {
            "minItems": 1,
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/BusinessOrganization"
            },
            "description": "List with the Business Organizations comprising the Company Code and the Entity Type."
          }
        },
        "additionalProperties": false
      },
      "DeleteBusinessOrganizationRelationshipResponse": {
        "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/CurrencyIdentifierModel"
            }
          },
          "hits": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "GetByIdResponse": {
        "type": "object",
        "properties": {
          "currencyCode": {
            "type": "string",
            "description": "Currency in alphabetic code (for more information, please refer to: https://www.iso.org/iso-4217-currency-codes.html).",
            "nullable": true
          },
          "description": {
            "type": "string",
            "description": "Name of currency. For example: Real, Dollar, Euro.",
            "nullable": true
          },
          "currencyAvailability": {
            "$ref": "#/components/schemas/CurrencyAvailability"
          },
          "conversionAvailability": {
            "$ref": "#/components/schemas/ConversionAvailability"
          },
          "usEnglishDescription": {
            "type": "string",
            "description": "Currency description in English.",
            "nullable": true
          },
          "spanishDescription": {
            "type": "string",
            "description": "Currency description in Spanish.",
            "nullable": true
          },
          "mxSpanishDescription": {
            "type": "string",
            "description": "Currency description in Spanish (from Mexico).",
            "nullable": true
          },
          "ptPortugueseDescription": {
            "type": "string",
            "description": "Currency description in Portuguese.",
            "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": "List with the Business Organizations comprising the Company Code and the Entity Type.",
            "nullable": true
          }
        },
        "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": {
          "currencyAvailability": {
            "$ref": "#/components/schemas/CurrencyAvailability"
          },
          "conversionAvailability": {
            "$ref": "#/components/schemas/ConversionAvailability"
          },
          "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": "List with the Business Organizations comprising the Company Code and the Entity Type.",
            "nullable": true
          }
        },
        "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": []
    }
  ]
}