/**
 * AdvancedBilling
 *
 * This file was automatically generated for Maxio by APIMATIC v3.0 ( https://www.apimatic.io ).
 */

import {
  bigint,
  boolean,
  expandoObject,
  nullable,
  number,
  optional,
  Schema,
  string,
} from '../schema.js';
import {
  ExpirationIntervalUnit,
  expirationIntervalUnitSchema,
} from './expirationIntervalUnit.js';
import { IntervalUnit, intervalUnitSchema } from './intervalUnit.js';
import { TrialType, trialTypeSchema } from './trialType.js';

export interface CreateProductPricePoint {
  /** The product price point name */
  name: string;
  /** The product price point API handle */
  handle?: string;
  /** The product price point price, in integer cents */
  priceInCents: bigint;
  /** The numerical interval. i.e. an interval of ‘30’ coupled with an interval_unit of day would mean this product price point would renew every 30 days */
  interval: number;
  /** A string representing the interval unit for this product price point, either month or day */
  intervalUnit: IntervalUnit;
  /** The product price point trial price, in integer cents */
  trialPriceInCents?: bigint;
  /** The numerical trial interval. i.e. an interval of ‘30’ coupled with a trial_interval_unit of day would mean this product price point trial would last 30 days. */
  trialInterval?: number;
  /** A string representing the trial interval unit for this product price point, either month or day */
  trialIntervalUnit?: IntervalUnit;
  /** Indicates how a trial is handled when the trail period ends and there is no credit card on file. For `no_obligation`, the subscription transitions to a Trial Ended state. Maxio will not send any emails or statements. For `payment_expected`, the subscription transitions to a Past Due state. Maxio will send normal dunning emails and statements according to your other settings. */
  trialType?: TrialType | null;
  /** The product price point initial charge, in integer cents */
  initialChargeInCents?: bigint;
  initialChargeAfterTrial?: boolean;
  /** The numerical expiration interval. i.e. an expiration_interval of ‘30’ coupled with an expiration_interval_unit of day would mean this product price point would expire after 30 days. */
  expirationInterval?: number;
  /** A string representing the expiration interval unit for this product price point, either month, day or never */
  expirationIntervalUnit?: ExpirationIntervalUnit | null;
  /** Whether or not to use the site's exchange rate or define your own pricing when your site has multiple currencies defined. */
  useSiteExchangeRate?: boolean;
  [key: string]: unknown;
}

export const createProductPricePointSchema: Schema<CreateProductPricePoint> = expandoObject(
  {
    name: ['name', string()],
    handle: ['handle', optional(string())],
    priceInCents: ['price_in_cents', bigint()],
    interval: ['interval', number()],
    intervalUnit: ['interval_unit', intervalUnitSchema],
    trialPriceInCents: ['trial_price_in_cents', optional(bigint())],
    trialInterval: ['trial_interval', optional(number())],
    trialIntervalUnit: ['trial_interval_unit', optional(intervalUnitSchema)],
    trialType: ['trial_type', optional(nullable(trialTypeSchema))],
    initialChargeInCents: ['initial_charge_in_cents', optional(bigint())],
    initialChargeAfterTrial: [
      'initial_charge_after_trial',
      optional(boolean()),
    ],
    expirationInterval: ['expiration_interval', optional(number())],
    expirationIntervalUnit: [
      'expiration_interval_unit',
      optional(nullable(expirationIntervalUnitSchema)),
    ],
    useSiteExchangeRate: ['use_site_exchange_rate', optional(boolean())],
  }
);
