{
  "openapi": "3.0.1",
  "info": {
    "title": "Order Justifications",
    "version": "9.1.20.0",
    "description": "Create and administer a collection of justifications for order management.",
    "x-introduced": "9.1.12.0"
  },
  "servers": [
    {
      "url": "https://{hostname}:{port}/rest/admin/v2",
      "variables": {
        "port": {
          "default": "443",
          "enum": [
            "443",
            "8000"
          ]
        },
        "hostname": {
          "default": "localhost",
          "enum": [
            "localhost",
            "test.hostname"
          ]
        }
      }
    }
  ],
  "paths": {
    "/order-justifications": {
      "get": {
        "tags": [
          "Order Justifications"
        ],
        "description": "Get a collection of order justifications.",
        "operationId": "getOrderJustifications",
        "parameters": [
          {
            "name": "storeId",
            "in": "query",
            "required": true,
            "description": "The store ID.",
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "usage",
            "in": "query",
            "required": true,
            "description": "The integer representation of the usage. 1 - appeasement, 2 - returns, 3 - both appeasement and returns",
            "schema": {
              "type": "integer",
              "format": "int32",
              "enum": [
                1,
                2,
                3
              ]
            }
          },
          {
            "name": "languageId",
            "in": "query",
            "description": "The language of the description. For a list of integer language identifiers, please refer to the Help Center.",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "includeDeleted",
            "in": "query",
            "required": false,
            "description": "The boolean value to indicate whether or not to include the deleted justifications.",
            "schema": {
              "type": "boolean"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "A collection of order justifications.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OrderJustificationCollection"
                },
                "example": {
                  "count": 5,
                  "items": [
                    {
                      "sequence": 100,
                      "code": "ITEM_WRONG",
                      "deleted": false,
                      "usage": 3,
                      "languageId": -1,
                      "description": "The customer ordered the wrong product or size",
                      "id": 11002,
                      "storeId": 12501
                    },
                    {
                      "sequence": 200,
                      "code": "ITEM_DAMAGE",
                      "deleted": false,
                      "usage": 3,
                      "languageId": -1,
                      "description": "The product was damaged or defective",
                      "id": 11003,
                      "storeId": 12501
                    },
                    {
                      "sequence": 300,
                      "code": "ITEM_LATE",
                      "deleted": false,
                      "usage": 3,
                      "languageId": -1,
                      "description": "The product arrived too late",
                      "id": 11004,
                      "storeId": 12501
                    },
                    {
                      "sequence": 400,
                      "code": "ITEM_NOT_NEEDED",
                      "deleted": false,
                      "usage": 3,
                      "languageId": -1,
                      "description": "The customer no longer needed the product",
                      "id": 11005,
                      "storeId": 12501
                    },
                    {
                      "sequence": 1000,
                      "code": "OTHER",
                      "deleted": false,
                      "usage": 3,
                      "languageId": -1,
                      "description": "Other",
                      "id": 11001,
                      "storeId": 12501
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "description": "There was a client error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponseContainer"
                }
              }
            }
          },
          "500": {
            "description": "There was a server error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponseContainer"
                }
              }
            }
          }
        }
      }
    },
    "/order-justifications/{id}": {
      "get": {
        "tags": [
          "Order Justifications"
        ],
        "description": "Get an order justification.",
        "operationId": "getOrderJustificationById",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "The order justification ID.",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "languageId",
            "in": "query",
            "description": "The language of the description. For a list of integer language identifiers, please refer to the Help Center.",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Order Justification.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OrderJustification"
                },
                "example": {
                  "sequence": 100,
                  "code": "ITEM_WRONG",
                  "deleted": false,
                  "usage": 3,
                  "languageId": -1,
                  "description": "The customer ordered the wrong product or size",
                  "id": 11002,
                  "storeId": 12501
                }
              }
            }
          },
          "400": {
            "description": "There was a client error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponseContainer"
                }
              }
            }
          },
          "404": {
            "description": "The resource was not found.",
            "content": {}
          },
          "500": {
            "description": "There was a server error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponseContainer"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Error": {
        "type": "object",
        "properties": {
          "errorCode": {
            "type": "string",
            "description": "The error message code."
          },
          "errorMessage": {
            "type": "string",
            "description": "The error message."
          },
          "errorKey": {
            "type": "string",
            "description": "The error message key."
          },
          "errorParameters": {
            "type": "array",
            "description": "The arguments used to construct the error message.",
            "items": {
              "type": "object",
              "properties": {}
            }
          },
          "errorLevel": {
            "type": "string",
            "description": "The error level."
          },
          "errorHref": {
            "type": "string",
            "description": "The error hypertext reference."
          }
        },
        "description": "The error message item model."
      },
      "ErrorResponseContainer": {
        "type": "object",
        "properties": {
          "requestId": {
            "type": "string",
            "description": "The request identifier."
          },
          "errors": {
            "type": "array",
            "description": "The errors.",
            "items": {
              "$ref": "#/components/schemas/Error"
            }
          }
        },
        "description": "The error message model."
      },
      "OrderJustification": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "Order justification id"
          },
          "storeId": {
            "type": "integer",
            "format": "int32",
            "description": "Store id"
          },
          "code": {
            "type": "string",
            "maxLength": 30,
            "description": "Order justification code"
          },
          "usage": {
            "type": "integer",
            "format": "int32",
            "description": "The integer representation of the usage. 1 - appeasement, 2 - returns, 3 - both appeasement and returns"
          },
          "sequence": {
            "type": "number",
            "description": "A number to indicate the relative display order"
          },
          "languageId": {
            "type": "integer",
            "format": "int32",
            "description": "The language of the description."
          },
          "description": {
            "type": "string",
            "description": "The language specific description."
          },
          "deleted": {
            "type": "boolean",
            "description": "A flag to indicate if the justification is marked for delete."
          }
        }
      },
      "OrderJustificationCollection": {
        "type": "object",
        "properties": {
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/OrderJustification"
            }
          },
          "count": {
            "type": "integer"
          }
        },
        "required": [
          "items",
          "count"
        ]
      }
    },
    "securitySchemes": {
      "basicAuth": {
        "type": "http",
        "scheme": "basic"
      }
    }
  },
  "security": [
    {
      "basicAuth": []
    }
  ],
  "tags": [
    {
      "name": "Order Justifications",
      "description": "Provide RESTful services to manage order justifications."
    }
  ],
  "externalDocs": {
    "description": "Some REST services take languageId as a request parameter. For a list of the integers that map to the supported default languages, please refer to this Help Center page.",
    "url": "https://help.hcltechsw.com/commerce/9.1.0/database/database/language.html"
  }
}
