{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/grainfinance-co/json-schema/grainfinance-co-organization-conversion-schema.json",
  "title": "OrganizationConversion",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/grainfinance-co-conversions-api-openapi.yml#/components/schemas/OrganizationConversion",
  "properties": {
    "id": {
      "$ref": "#/$defs/UUID",
      "description": "The id of the conversion within the Grain platform."
    },
    "organizationId": {
      "$ref": "#/$defs/UUID",
      "description": "The id of the organization that perform the conversion within the Grain platform."
    },
    "fromCurrency": {
      "type": "string",
      "description": "The currency in which the transaction should be paid at by your customer."
    },
    "toCurrency": {
      "type": "string",
      "description": "The currency in which the inventory item is listed at on your platform."
    },
    "toCurrencyAmount": {
      "type": "number",
      "format": "double",
      "description": "The amount to transfer in the toCurrency"
    },
    "fromCurrencyAmount": {
      "type": "number",
      "format": "double",
      "description": "The amount to transfer in the fromCurrency"
    },
    "quote": {
      "type": "number",
      "format": "double",
      "description": "The rate locked by this conversion."
    },
    "acceptedAtTs": {
      "type": "number",
      "format": "double",
      "description": "The unix timestamp in which the conversion offer was accepted (if it was)."
    },
    "issuedAt": {
      "$ref": "#/$defs/GrainDateFormat",
      "description": "The date in which the conversion was issued, denoted in `YYYY-MM-DD` format."
    },
    "completedAt": {
      "description": "The date in which the conversion was completed, denoted in `YYYY-MM-DD` format.",
      "oneOf": [
        {
          "$ref": "#/$defs/GrainDateFormat"
        },
        {
          "type": "null"
        }
      ]
    }
  },
  "required": [
    "id",
    "organizationId",
    "fromCurrency",
    "toCurrency",
    "toCurrencyAmount",
    "fromCurrencyAmount",
    "quote",
    "acceptedAtTs",
    "issuedAt",
    "completedAt"
  ],
  "type": "object",
  "additionalProperties": false,
  "$defs": {
    "GrainDateFormat": {
      "type": "string",
      "format": "YYYY-MM-DD",
      "description": "The date format accepted by Grain's API. We accept dash separated ISO-8601 date-only strings.",
      "pattern": "\\d{4}-\\d{2}-\\d{2}"
    },
    "UUID": {
      "type": "string",
      "format": "uuid",
      "pattern": "[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-4[0-9A-Fa-f]{3}-[89ABab][0-9A-Fa-f]{3}-[0-9A-Fa-f]{12}"
    }
  }
}