/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod/v4-mini"; import { remap as remap$ } from "../../lib/primitives.js"; import { safeParse } from "../../lib/schemas.js"; import { Result as SafeParseResult } from "../../types/fp.js"; import * as types from "../../types/primitives.js"; import { CreditGrantCadence, CreditGrantCadence$inboundSchema, } from "./credit-grant-cadence.js"; import { CreditGrantExpiryDurationUnit, CreditGrantExpiryDurationUnit$inboundSchema, } from "./credit-grant-expiry-duration-unit.js"; import { CreditGrantExpiryType, CreditGrantExpiryType$inboundSchema, } from "./credit-grant-expiry-type.js"; import { CreditGrantPeriod, CreditGrantPeriod$inboundSchema, } from "./credit-grant-period.js"; import { CreditGrantScope, CreditGrantScope$inboundSchema, } from "./credit-grant-scope.js"; import { SDKValidationError } from "./sdk-validation-error.js"; import { Status, Status$inboundSchema } from "./status.js"; export type CreditGrantResponse = { addonId?: string | undefined; cadence?: CreditGrantCadence | undefined; /** * amount in the currency = number of credits * conversion_rate * * @remarks * ex if conversion_rate is 1, then 1 USD = 1 credit * ex if conversion_rate is 2, then 1 USD = 0.5 credits * ex if conversion_rate is 0.5, then 1 USD = 2 credits */ conversionRate?: string | undefined; createdAt?: Date | undefined; createdBy?: string | undefined; creditGrantAnchor?: Date | undefined; credits?: string | undefined; endDate?: Date | undefined; environmentId?: string | undefined; expirationDuration?: number | undefined; expirationDurationUnit?: CreditGrantExpiryDurationUnit | undefined; expirationType?: CreditGrantExpiryType | undefined; id?: string | undefined; metadata?: { [k: string]: string } | undefined; name?: string | undefined; period?: CreditGrantPeriod | undefined; periodCount?: number | undefined; planId?: string | undefined; priority?: number | undefined; scope?: CreditGrantScope | undefined; startDate?: Date | undefined; status?: Status | undefined; subscriptionId?: string | undefined; tenantId?: string | undefined; /** * topup_conversion_rate is the conversion rate for the topup to the currency * * @remarks * ex if topup_conversion_rate is 1, then 1 USD = 1 credit * ex if topup_conversion_rate is 2, then 1 USD = 0.5 credits * ex if topup_conversion_rate is 0.5, then 1 USD = 2 credits */ topupConversionRate?: string | undefined; updatedAt?: Date | undefined; updatedBy?: string | undefined; }; /** @internal */ export const CreditGrantResponse$inboundSchema: z.ZodMiniType< CreditGrantResponse, unknown > = z.pipe( z.object({ addon_id: types.optional(types.string()), cadence: types.optional(CreditGrantCadence$inboundSchema), conversion_rate: types.optional(types.string()), created_at: types.optional(types.date()), created_by: types.optional(types.string()), credit_grant_anchor: types.optional(types.date()), credits: types.optional(types.string()), end_date: types.optional(types.date()), environment_id: types.optional(types.string()), expiration_duration: types.optional(types.number()), expiration_duration_unit: types.optional( CreditGrantExpiryDurationUnit$inboundSchema, ), expiration_type: types.optional(CreditGrantExpiryType$inboundSchema), id: types.optional(types.string()), metadata: types.optional(z.record(z.string(), types.string())), name: types.optional(types.string()), period: types.optional(CreditGrantPeriod$inboundSchema), period_count: types.optional(types.number()), plan_id: types.optional(types.string()), priority: types.optional(types.number()), scope: types.optional(CreditGrantScope$inboundSchema), start_date: types.optional(types.date()), status: types.optional(Status$inboundSchema), subscription_id: types.optional(types.string()), tenant_id: types.optional(types.string()), topup_conversion_rate: types.optional(types.string()), updated_at: types.optional(types.date()), updated_by: types.optional(types.string()), }), z.transform((v) => { return remap$(v, { "addon_id": "addonId", "conversion_rate": "conversionRate", "created_at": "createdAt", "created_by": "createdBy", "credit_grant_anchor": "creditGrantAnchor", "end_date": "endDate", "environment_id": "environmentId", "expiration_duration": "expirationDuration", "expiration_duration_unit": "expirationDurationUnit", "expiration_type": "expirationType", "period_count": "periodCount", "plan_id": "planId", "start_date": "startDate", "subscription_id": "subscriptionId", "tenant_id": "tenantId", "topup_conversion_rate": "topupConversionRate", "updated_at": "updatedAt", "updated_by": "updatedBy", }); }), ); export function creditGrantResponseFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => CreditGrantResponse$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'CreditGrantResponse' from JSON`, ); }