/**
 * Account and Transaction API SpecificationLib
 *
 * This file was automatically generated by APIMATIC v3.0 ( https://www.apimatic.io ).
 */

import { array, lazy, object, optional, Schema, string } from '../schema';
import { StatementAmount, statementAmountSchema } from './statementAmount';
import { StatementBenefit, statementBenefitSchema } from './statementBenefit';
import {
  StatementDateTime,
  statementDateTimeSchema,
} from './statementDateTime';
import { StatementFee, statementFeeSchema } from './statementFee';
import {
  StatementInterest,
  statementInterestSchema,
} from './statementInterest';
import { StatementRate, statementRateSchema } from './statementRate';
import {
  StatementTypeEnum,
  statementTypeEnumSchema,
} from './statementTypeEnum';
import { StatementValue, statementValueSchema } from './statementValue';

export interface Statement {
  /** A unique and immutable identifier used to identify the account resource. This identifier has no meaning to the account owner. */
  accountId: string;
  /** Unique identifier for the statement resource within an servicing institution. This identifier is both unique and immutable. */
  statementId?: string;
  /** Unique reference for the statement. This reference may be optionally populated if available. */
  statementReference?: string;
  /** Statement type, in a coded form. */
  type: StatementTypeEnum;
  /**
   * Date and time at which the statement period starts.
   * All dates in the JSON payloads are represented in ISO 8601 date-time format.
   * All date-time fields in responses must include the timezone. An example is below:
   * 2017-04-05T10:43:07+00:00
   */
  startDateTime: string;
  /**
   * Date and time at which the statement period ends.
   * All dates in the JSON payloads are represented in ISO 8601 date-time format.
   * All date-time fields in responses must include the timezone. An example is below:
   * 2017-04-05T10:43:07+00:00
   */
  endDateTime: string;
  /**
   * Date and time at which the resource was created.
   * All dates in the JSON payloads are represented in ISO 8601 date-time format.
   * All date-time fields in responses must include the timezone. An example is below:
   * 2017-04-05T10:43:07+00:00
   */
  creationDateTime: string;
  /** Other descriptions that may be available for the statement resource. */
  statementDescription?: string[];
  /** Set of elements used to provide details of a benefit or reward amount for the statement resource. */
  statementBenefit?: StatementBenefit[];
  /** Set of elements used to provide details of a fee for the statement resource. */
  statementFee?: StatementFee[];
  /** Set of elements used to provide details of a generic interest amount related to the statement resource. */
  statementInterest?: StatementInterest[];
  /** Set of elements used to provide details of a generic date time for the statement resource. */
  statementDateTime?: StatementDateTime[];
  /** Set of elements used to provide details of a generic rate related to the statement resource. */
  statementRate?: StatementRate[];
  /** Set of elements used to provide details of a generic number value related to the statement resource. */
  statementValue?: StatementValue[];
  /** Set of elements used to provide details of a generic amount for the statement resource. */
  statementAmount?: StatementAmount[];
}

export const statementSchema: Schema<Statement> = object({
  accountId: ['AccountId', string()],
  statementId: ['StatementId', optional(string())],
  statementReference: ['StatementReference', optional(string())],
  type: ['Type', statementTypeEnumSchema],
  startDateTime: ['StartDateTime', string()],
  endDateTime: ['EndDateTime', string()],
  creationDateTime: ['CreationDateTime', string()],
  statementDescription: ['StatementDescription', optional(array(string()))],
  statementBenefit: [
    'StatementBenefit',
    optional(array(lazy(() => statementBenefitSchema))),
  ],
  statementFee: [
    'StatementFee',
    optional(array(lazy(() => statementFeeSchema))),
  ],
  statementInterest: [
    'StatementInterest',
    optional(array(lazy(() => statementInterestSchema))),
  ],
  statementDateTime: [
    'StatementDateTime',
    optional(array(lazy(() => statementDateTimeSchema))),
  ],
  statementRate: [
    'StatementRate',
    optional(array(lazy(() => statementRateSchema))),
  ],
  statementValue: [
    'StatementValue',
    optional(array(lazy(() => statementValueSchema))),
  ],
  statementAmount: [
    'StatementAmount',
    optional(array(lazy(() => statementAmountSchema))),
  ],
});
