{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://luncagent.com/internal/schemas/statsbin-customer-zero-v2.schema.json",
  "title": "Proposed StatsBin customer-zero v2; fixture tested, no live route",
  "$defs": {
    "timestamp": {
      "type": "string",
      "format": "date-time",
      "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{3}Z$"
    },
    "id": {
      "type": "string",
      "pattern": "^[A-Za-z0-9_-]{1,128}$"
    },
    "digest": {
      "type": "string",
      "pattern": "^[a-f0-9]{64}$"
    },
    "amount": {
      "type": "string",
      "pattern": "^(0|[1-9][0-9]{0,29})$"
    },
    "resource": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "schemaVersion",
        "network",
        "chainId",
        "source",
        "sourceUrl",
        "observedAt",
        "expiresAt",
        "height",
        "asset",
        "supplyUluna"
      ],
      "properties": {
        "schemaVersion": {
          "const": "2"
        },
        "network": {
          "const": "cosmos:columbus-5"
        },
        "chainId": {
          "const": "columbus-5"
        },
        "source": {
          "const": "statsbin-public"
        },
        "sourceUrl": {
          "const": "https://statsbin.com/"
        },
        "observedAt": {
          "$ref": "#/$defs/timestamp"
        },
        "expiresAt": {
          "$ref": "#/$defs/timestamp"
        },
        "height": {
          "type": "string",
          "pattern": "^[1-9][0-9]{0,19}$"
        },
        "asset": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "denom",
            "decimals"
          ],
          "properties": {
            "denom": {
              "const": "uluna"
            },
            "decimals": {
              "const": 6
            }
          }
        },
        "supplyUluna": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "total",
            "circulating"
          ],
          "properties": {
            "total": {
              "$ref": "#/$defs/amount"
            },
            "circulating": {
              "$ref": "#/$defs/amount"
            }
          }
        }
      }
    },
    "deliveryRequest": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "schemaVersion",
        "deliveryId",
        "quoteId",
        "resourceKey",
        "requestDigest"
      ],
      "properties": {
        "schemaVersion": {
          "const": "2"
        },
        "deliveryId": {
          "$ref": "#/$defs/id"
        },
        "quoteId": {
          "$ref": "#/$defs/id"
        },
        "resourceKey": {
          "const": "statsbin-public-network-metadata-v2"
        },
        "requestDigest": {
          "$ref": "#/$defs/digest"
        }
      }
    },
    "deliveryStatus": {
      "oneOf": [
        {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "schemaVersion",
            "deliveryId",
            "requestDigest",
            "status",
            "resource",
            "responseDigest",
            "appliedAt"
          ],
          "properties": {
            "schemaVersion": {
              "const": "2"
            },
            "deliveryId": {
              "$ref": "#/$defs/id"
            },
            "requestDigest": {
              "$ref": "#/$defs/digest"
            },
            "status": {
              "const": "APPLIED"
            },
            "resource": {
              "$ref": "#/$defs/resource"
            },
            "responseDigest": {
              "$ref": "#/$defs/digest"
            },
            "appliedAt": {
              "$ref": "#/$defs/timestamp"
            }
          }
        },
        {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "schemaVersion",
            "deliveryId",
            "requestDigest",
            "status",
            "reason",
            "checkedAt"
          ],
          "properties": {
            "schemaVersion": {
              "const": "2"
            },
            "deliveryId": {
              "$ref": "#/$defs/id"
            },
            "requestDigest": {
              "$ref": "#/$defs/digest"
            },
            "status": {
              "const": "NOT_APPLIED"
            },
            "reason": {
              "const": "RESOURCE_UNAVAILABLE"
            },
            "checkedAt": {
              "$ref": "#/$defs/timestamp"
            }
          }
        },
        {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "schemaVersion",
            "deliveryId",
            "status",
            "reason",
            "checkedAt"
          ],
          "properties": {
            "schemaVersion": {
              "const": "2"
            },
            "deliveryId": {
              "$ref": "#/$defs/id"
            },
            "status": {
              "const": "UNKNOWN"
            },
            "reason": {
              "enum": [
                "NOT_SEEN",
                "STATUS_UNAVAILABLE"
              ]
            },
            "checkedAt": {
              "$ref": "#/$defs/timestamp"
            }
          }
        }
      ]
    },
    "errorEnvelope": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "schemaVersion",
        "error"
      ],
      "properties": {
        "schemaVersion": {
          "const": "2"
        },
        "error": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "code",
            "message"
          ],
          "properties": {
            "code": {
              "enum": [
                "NOT_FOUND",
                "INVALID_REQUEST",
                "FORBIDDEN",
                "UNAUTHENTICATED",
                "RESOURCE_UNAVAILABLE",
                "IDEMPOTENCY_CONFLICT",
                "PAYLOAD_TOO_LARGE",
                "TRANSPORT_UNAVAILABLE"
              ]
            },
            "message": {
              "type": "string"
            }
          }
        }
      }
    }
  }
}
