{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://objectsgrid.com/.well-known/objects-catalog/ReturnAction/v1/schema.json",
  "title": "ReturnAction",
  "description": "Objects Grid ReturnAction Object. A return of some of an Order's lines: who returns them, why, how, the refund and the parcel back. A private record of a customer: it has no JSON-LD document. Modeled in compliance with https://schema.org/ReturnAction; returnedItem, refundAmount and returnDelivery are ObjectsGrid's own fields.",
  "x-objectsgrid-jsonLd": false,
  "type": "object",
  "properties": {
    "at_context": {
      "description": "Schema context",
      "anyOf": [
        {
          "type": "string",
          "enum": [
            "https://schema.org"
          ]
        },
        {
          "type": "null"
        }
      ]
    },
    "at_type": {
      "description": "The object type",
      "anyOf": [
        {
          "type": "string",
          "enum": [
            "ReturnAction"
          ]
        },
        {
          "type": "null"
        }
      ]
    },
    "at_id": {
      "description": "This ReturnAction's ObjectsGrid URL, https://apis.objectsgrid.com/<path>/<id>: its JSON-LD @id, which References point to. Set by the service.",
      "type": [
        "string",
        "null"
      ],
      "format": "uri",
      "readOnly": true
    },
    "id": {
      "description": "The unique identifier for ReturnAction. Assigned by the server.",
      "type": [
        "string",
        "null"
      ],
      "minLength": 0,
      "maxLength": 50,
      "readOnly": true
    },
    "identifier": {
      "description": "The unique identifier for ReturnAction. Assigned by the server.",
      "type": [
        "string",
        "null"
      ],
      "minLength": 0,
      "maxLength": 50,
      "readOnly": true
    },
    "url": {
      "description": "This ReturnAction URL. Assigned by the server.",
      "type": [
        "string",
        "null"
      ],
      "format": "uri",
      "minLength": 1,
      "readOnly": true
    },
    "object": {
      "description": "The Order the lines are returned from",
      "x-objectsgrid-rangeIncludes": [
        "Order"
      ],
      "$ref": "https://objectsgrid.com/.well-known/objects-catalog/Reference/v1/schema.json"
    },
    "agent": {
      "x-objectsgrid-erasure": "keep",
      "x-objectsgrid-version": "pinned",
      "description": "The customer returning them: the URL of a Person or Organization, stored as <url>?version=<objectVersion>, the version that was newest when the return was written, as an Order's customer.",
      "x-objectsgrid-rangeIncludes": [
        "Person",
        "Organization"
      ],
      "$ref": "https://objectsgrid.com/.well-known/objects-catalog/Reference/v1/schema.json"
    },
    "recipient": {
      "x-objectsgrid-erasure": "keep",
      "description": "Who takes the return: the shop or a store",
      "x-objectsgrid-rangeIncludes": [
        "Organization",
        "Place",
        "Person"
      ],
      "anyOf": [
        {
          "$ref": "https://objectsgrid.com/.well-known/objects-catalog/Reference/v1/schema.json"
        },
        {
          "type": "null"
        }
      ]
    },
    "actionStatus": {
      "description": "Where the return stands: Potential (requested), Active (in progress), Completed (refunded or exchanged), Failed (refused)",
      "anyOf": [
        {
          "$ref": "https://objectsgrid.com/.well-known/objects-catalog/ActionStatusType/v1/schema.json"
        },
        {
          "type": "null"
        }
      ]
    },
    "startTime": {
      "description": "When the return was asked for",
      "type": [
        "string",
        "null"
      ],
      "format": "date-time"
    },
    "endTime": {
      "description": "When the return was done",
      "type": [
        "string",
        "null"
      ],
      "format": "date-time"
    },
    "returnedItem": {
      "description": "The Order's lines returned, by their orderItemNumber. ObjectsGrid's own field.",
      "type": "array",
      "minItems": 1,
      "maxItems": 100,
      "items": {
        "type": "object",
        "properties": {
          "orderItemNumber": {
            "description": "The orderItemNumber of the Order's line",
            "type": "string",
            "minLength": 1,
            "maxLength": 50
          },
          "quantity": {
            "description": "How many of the line are returned; all when not given",
            "type": [
              "number",
              "null"
            ],
            "minimum": 0
          },
          "returnReason": {
            "description": "Why, as the customer or the shop puts it: not for personal details",
            "type": [
              "string",
              "null"
            ],
            "maxLength": 1000
          }
        },
        "required": [
          "orderItemNumber"
        ],
        "unevaluatedProperties": false
      }
    },
    "returnMethod": {
      "description": "How the items come back: by mail, in store, at a kiosk",
      "anyOf": [
        {
          "$ref": "https://objectsgrid.com/.well-known/objects-catalog/ReturnMethodEnumeration/v1/schema.json"
        },
        {
          "type": "null"
        }
      ]
    },
    "refundType": {
      "description": "Full refund, exchange or store credit",
      "anyOf": [
        {
          "$ref": "https://objectsgrid.com/.well-known/objects-catalog/RefundTypeEnumeration/v1/schema.json"
        },
        {
          "type": "null"
        }
      ]
    },
    "refundAmount": {
      "description": "What was refunded. ObjectsGrid's own field.",
      "anyOf": [
        {
          "$ref": "https://objectsgrid.com/.well-known/objects-catalog/MonetaryAmount/v1/schema.json"
        },
        {
          "type": "null"
        }
      ]
    },
    "returnFees": {
      "description": "Who pays for the return",
      "anyOf": [
        {
          "$ref": "https://objectsgrid.com/.well-known/objects-catalog/ReturnFeesEnumeration/v1/schema.json"
        },
        {
          "type": "null"
        }
      ]
    },
    "returnDelivery": {
      "x-objectsgrid-personal": "agent",
      "description": "The parcels back, with their tracking and the customer's address. Personal: encrypted with the key of the agent's pinned Person version, as an Order's orderDelivery is, and never in events or search. ObjectsGrid's own field.",
      "type": [
        "array",
        "null"
      ],
      "maxItems": 20,
      "items": {
        "$ref": "https://objectsgrid.com/.well-known/objects-catalog/ParcelDelivery/v1/schema.json"
      }
    },
    "result": {
      "description": "What came of it: a credit note (an Invoice), or the replacement Order of an exchange",
      "x-objectsgrid-rangeIncludes": [
        "Invoice",
        "Order"
      ],
      "anyOf": [
        {
          "$ref": "https://objectsgrid.com/.well-known/objects-catalog/Reference/v1/schema.json"
        },
        {
          "type": "null"
        }
      ]
    },
    "tags": {
      "description": "Tags an ABAC policy can decide on. A name may repeat; the same name and value appear once. Every stored object has them: created empty when not sent, kept by a replacement (PUT) that does not mention them, unchanged by a patch that does not mention them, cleared by null or [].",
      "type": "array",
      "default": [],
      "uniqueItems": true,
      "maxItems": 50,
      "items": {
        "$ref": "https://objectsgrid.com/.well-known/objects-catalog/Tag/v1/schema.json"
      }
    },
    "meta": {
      "description": "System-managed metadata for the object (version, audit fields). Assigned by the server.",
      "$ref": "https://objectsgrid.com/.well-known/objects-catalog/ObjectMeta/v1/schema.json",
      "readOnly": true
    }
  },
  "required": [
    "object",
    "agent",
    "returnedItem"
  ],
  "unevaluatedProperties": false
}
