/**
 * 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 { Error, errorSchema } from './error';

/** An array of detail error codes, and messages, and URLs to documentation to help remediation. */
export interface ErrorResponse {
  /** High level textual error code to help categorise the errors. */
  code: string;
  /** A unique reference for the error instance, for audit purposes, in case of unknown/unclassified errors. */
  id?: string;
  /** Brief Error message. E.g., 'There is something wrong with the request parameters provided' */
  message: string;
  errors: Error[];
}

export const errorResponseSchema: Schema<ErrorResponse> = object({
  code: ['Code', string()],
  id: ['Id', optional(string())],
  message: ['Message', string()],
  errors: ['Errors', array(lazy(() => errorSchema))],
});
