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

import { lazy, object, optional, Schema, string } from '../schema';
import { DeliveryAddress, deliveryAddressSchema } from './deliveryAddress';
import { GeoLocation, geoLocationSchema } from './geoLocation';
import {
  PaymentContextCodeEnum,
  paymentContextCodeEnumSchema,
} from './paymentContextCodeEnum';

/** The Risk section is sent by the initiating party to the API Provider. It is used to specify additional details for risk scoring. */
export interface Risk {
  /** Location of the end-user on the earth specified by two numbers representing vertical and horizontal position */
  geoLocation?: GeoLocation;
  /** Specifies the payment context */
  paymentContextCode?: PaymentContextCodeEnum;
  /** Category code conforms to ISO 18245, related to the type of services or goods the merchant provides for the transaction */
  merchantCategoryCode?: string;
  /** The unique customer identifier of the Customer with the merchant. */
  merchantCustomerIdentification?: string;
  /** Information that locates and identifies a specific address, as defined by postal services or in free format text. */
  deliveryAddress?: DeliveryAddress;
  /** Name of the end user facing application */
  endUserAppName?: string;
  /** Version of the end user facing application */
  endUserAppVersion?: string;
  /** Name of the merchant */
  merchantName?: string;
  /** NZ business number for the merchant */
  merchantNZBN?: string;
}

export const riskSchema: Schema<Risk> = object({
  geoLocation: ['GeoLocation', optional(lazy(() => geoLocationSchema))],
  paymentContextCode: [
    'PaymentContextCode',
    optional(paymentContextCodeEnumSchema),
  ],
  merchantCategoryCode: ['MerchantCategoryCode', optional(string())],
  merchantCustomerIdentification: [
    'MerchantCustomerIdentification',
    optional(string()),
  ],
  deliveryAddress: [
    'DeliveryAddress',
    optional(lazy(() => deliveryAddressSchema)),
  ],
  endUserAppName: ['EndUserAppName', optional(string())],
  endUserAppVersion: ['EndUserAppVersion', optional(string())],
  merchantName: ['MerchantName', optional(string())],
  merchantNZBN: ['MerchantNZBN', optional(string())],
});
