/**
 * Shell Card Management APIsLib
 *
 * This file was automatically generated by APIMATIC v3.0 ( https://www.apimatic.io ).
 */

import {
  array,
  lazy,
  number,
  object,
  optional,
  Schema,
  string,
} from '../schema';
import {
  CreateCardGroupResponseErrorCardsItems,
  createCardGroupResponseErrorCardsItemsSchema,
} from './createCardGroupResponseErrorCardsItems';
import {
  CreateCardGroupResponseSuccessfulRequestsItems,
  createCardGroupResponseSuccessfulRequestsItemsSchema,
} from './createCardGroupResponseSuccessfulRequestsItems';
import { ErrorStatus, errorStatusSchema } from './errorStatus';

export interface CreateCardGroupResponse {
  /**
   * Reference number for tracking the execution of the requests – new Card Group creation and to move the cards to the new card group.
   * Reference number will be null when the validations of new card group parameters fail.
   */
  mainReference?: number;
  /**
   * Reference number for tracking the execution of card group creation.
   * Reference number will be null when the validations of new card group parameters fail.
   */
  newCardGroupReference?: number;
  /** List of cards validated and submitted successfully for processing. */
  successfulRequests?: CreateCardGroupResponseSuccessfulRequestsItems[];
  /**
   * List of cards that failed validation and not submitted for processing.
   * Entity: FailedCardReference
   * This list will be empty when the validations of new card group parameters fail.
   */
  errorCards?: CreateCardGroupResponseErrorCardsItems[];
  error?: ErrorStatus;
  /** API Request Id */
  requestId?: string;
}

export const createCardGroupResponseSchema: Schema<CreateCardGroupResponse> = object(
  {
    mainReference: ['MainReference', optional(number())],
    newCardGroupReference: ['NewCardGroupReference', optional(number())],
    successfulRequests: [
      'SuccessfulRequests',
      optional(
        array(lazy(() => createCardGroupResponseSuccessfulRequestsItemsSchema))
      ),
    ],
    errorCards: [
      'ErrorCards',
      optional(array(lazy(() => createCardGroupResponseErrorCardsItemsSchema))),
    ],
    error: ['Error', optional(lazy(() => errorStatusSchema))],
    requestId: ['RequestId', optional(string())],
  }
);
