/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod/v3"; import { remap as remap$ } from "../../lib/primitives.js"; import { safeParse } from "../../lib/schemas.js"; import { Result as SafeParseResult } from "../../types/fp.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { EnvironmentMode, EnvironmentMode$inboundSchema, EnvironmentMode$outboundSchema, } from "./environmentmode.js"; import { TransactionStatus, TransactionStatus$inboundSchema, TransactionStatus$outboundSchema, } from "./transactionstatus.js"; import { TransactionType, TransactionType$inboundSchema, TransactionType$outboundSchema, } from "./transactiontype.js"; export type TransactionEntity = { /** * Unique identifier for the object. */ id: string; /** * String representing the environment. */ mode: EnvironmentMode; /** * String representing the object's type. Objects of the same type share the same value. */ object: string; /** * The transaction amount in cents. 1000 = $10.00 */ amount: number; /** * The amount the customer paid in cents. 1000 = $10.00 */ amountPaid?: number | null | undefined; /** * The discount amount in cents. 1000 = $10.00 */ discountAmount?: number | null | undefined; /** * Three-letter ISO currency code, in uppercase. Must be a supported currency. */ currency: string; /** * The type of transaction. payment(one time payments) and invoice(subscription) */ type: TransactionType; /** * The ISO alpha-2 country code where tax is collected. */ taxCountry?: string | null | undefined; /** * The sale tax amount in cents. 1000 = $10.00 */ taxAmount?: number | null | undefined; /** * Status of the transaction. */ status: TransactionStatus; /** * The amount that has been refunded in cents. 1000 = $10.00 */ refundedAmount?: number | null | undefined; /** * The order associated with the transaction. */ order?: string | null | undefined; /** * The subscription associated with the transaction. */ subscription?: string | null | undefined; /** * The customer associated with the transaction. */ customer?: string | null | undefined; /** * The description of the transaction. */ description?: string | undefined; /** * Start period for the invoice as timestamp */ periodStart?: number | undefined; /** * End period for the invoice as timestamp */ periodEnd?: number | undefined; /** * Creation date of the order as timestamp */ createdAt: number; }; /** @internal */ export const TransactionEntity$inboundSchema: z.ZodType< TransactionEntity, z.ZodTypeDef, unknown > = z.object({ id: z.string(), mode: EnvironmentMode$inboundSchema, object: z.string(), amount: z.number(), amount_paid: z.nullable(z.number()).optional(), discount_amount: z.nullable(z.number()).optional(), currency: z.string(), type: TransactionType$inboundSchema, tax_country: z.nullable(z.string()).optional(), tax_amount: z.nullable(z.number()).optional(), status: TransactionStatus$inboundSchema, refunded_amount: z.nullable(z.number()).optional(), order: z.nullable(z.string()).optional(), subscription: z.nullable(z.string()).optional(), customer: z.nullable(z.string()).optional(), description: z.string().optional(), period_start: z.number().optional(), period_end: z.number().optional(), created_at: z.number(), }).transform((v) => { return remap$(v, { "amount_paid": "amountPaid", "discount_amount": "discountAmount", "tax_country": "taxCountry", "tax_amount": "taxAmount", "refunded_amount": "refundedAmount", "period_start": "periodStart", "period_end": "periodEnd", "created_at": "createdAt", }); }); /** @internal */ export type TransactionEntity$Outbound = { id: string; mode: string; object: string; amount: number; amount_paid?: number | null | undefined; discount_amount?: number | null | undefined; currency: string; type: string; tax_country?: string | null | undefined; tax_amount?: number | null | undefined; status: string; refunded_amount?: number | null | undefined; order?: string | null | undefined; subscription?: string | null | undefined; customer?: string | null | undefined; description?: string | undefined; period_start?: number | undefined; period_end?: number | undefined; created_at: number; }; /** @internal */ export const TransactionEntity$outboundSchema: z.ZodType< TransactionEntity$Outbound, z.ZodTypeDef, TransactionEntity > = z.object({ id: z.string(), mode: EnvironmentMode$outboundSchema, object: z.string(), amount: z.number(), amountPaid: z.nullable(z.number()).optional(), discountAmount: z.nullable(z.number()).optional(), currency: z.string(), type: TransactionType$outboundSchema, taxCountry: z.nullable(z.string()).optional(), taxAmount: z.nullable(z.number()).optional(), status: TransactionStatus$outboundSchema, refundedAmount: z.nullable(z.number()).optional(), order: z.nullable(z.string()).optional(), subscription: z.nullable(z.string()).optional(), customer: z.nullable(z.string()).optional(), description: z.string().optional(), periodStart: z.number().optional(), periodEnd: z.number().optional(), createdAt: z.number(), }).transform((v) => { return remap$(v, { amountPaid: "amount_paid", discountAmount: "discount_amount", taxCountry: "tax_country", taxAmount: "tax_amount", refundedAmount: "refunded_amount", periodStart: "period_start", periodEnd: "period_end", createdAt: "created_at", }); }); export function transactionEntityToJSON( transactionEntity: TransactionEntity, ): string { return JSON.stringify( TransactionEntity$outboundSchema.parse(transactionEntity), ); } export function transactionEntityFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => TransactionEntity$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'TransactionEntity' from JSON`, ); }