{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://agenthandelstandard.se/schemas/agent-lane-outcomes.schema.json",
  "title": "SACP agent lane outcomes",
  "description": "Error bodies a shop returns when it advertises agent.lane. Added in SACP 1.2.0-draft.",
  "oneOf": [
    {
      "$ref": "#/$defs/PhaseMismatch"
    },
    {
      "$ref": "#/$defs/PhaseUndeclared"
    },
    {
      "$ref": "#/$defs/PhaseConflict"
    },
    {
      "$ref": "#/$defs/RateLimited"
    },
    {
      "$ref": "#/$defs/AutonomousNotOffered"
    }
  ],
  "$defs": {
    "PhaseMismatch": {
      "description": "HTTP 400. The path does not match the declared agent_phase.",
      "type": "object",
      "required": [
        "code",
        "declared",
        "required"
      ],
      "additionalProperties": false,
      "properties": {
        "code": {
          "const": "phase_mismatch"
        },
        "declared": {
          "enum": [
            "shopping",
            "checkout"
          ]
        },
        "required": {
          "enum": [
            "shopping",
            "checkout"
          ]
        },
        "path": {
          "type": "string"
        }
      }
    },
    "PhaseUndeclared": {
      "description": "HTTP 400. The shop advertises agent.lane and the request has no agent_phase.",
      "type": "object",
      "required": [
        "code"
      ],
      "additionalProperties": false,
      "properties": {
        "code": {
          "const": "phase_undeclared"
        },
        "path": {
          "type": "string"
        }
      }
    },
    "PhaseConflict": {
      "description": "HTTP 400. The header and the body declare different values.",
      "type": "object",
      "required": [
        "code"
      ],
      "additionalProperties": false,
      "properties": {
        "code": {
          "const": "phase_conflict"
        },
        "header": {
          "type": "string"
        },
        "body": {
          "type": "string"
        }
      }
    },
    "RateLimited": {
      "description": "HTTP 429. The phase rate limit was exceeded.",
      "type": "object",
      "required": [
        "code",
        "agent_phase",
        "retry_after_seconds"
      ],
      "additionalProperties": false,
      "properties": {
        "code": {
          "const": "rate_limited"
        },
        "agent_phase": {
          "enum": [
            "shopping",
            "checkout"
          ]
        },
        "retry_after_seconds": {
          "type": "integer",
          "minimum": 1
        }
      }
    },
    "AutonomousNotOffered": {
      "description": "HTTP 403. checkout_mode is autonomous and the shop does not advertise checkout.autonomous.",
      "type": "object",
      "required": [
        "code"
      ],
      "additionalProperties": false,
      "properties": {
        "code": {
          "const": "autonomous_not_offered"
        },
        "checkout_mode": {
          "const": "autonomous"
        }
      }
    }
  }
}
