import { CountryISO, Timestamp, ValueOf } from "../types";
import { entityBase } from "./entityBase";
import { money } from "./money";
import { enums } from "../enums";
import { payIn } from "./payIn";
import { base } from "../base";
import { billing } from "./billing";
import { shipping } from "./shipping";
import { card } from "./card";

export namespace deposit {
    import MoneyData = money.MoneyData;
    import PayInPaymentType = payIn.PayInPaymentType;
    import PayInExecutionType = payIn.PayInExecutionType;
    import BrowserInfoData = base.BrowserInfoData;
    import ShippingData = shipping.ShippingData;
    import CompleteBillingData = billing.CompleteBillingData;
    import _3DSVersion = payIn._3DSVersion;
    import CardInfoData = card.CardInfoData;
    import AuthenticationResult = payIn.AuthenticationResult;
    import FlowDescriptor = payIn.FlowDescriptor;
    import ShippingPreference = payIn.ShippingPreference;
    import PayPalWebTrackingData = payIn.PayPalWebTrackingData;
    import LineItemData = payIn.LineItemData;
    import CreateLineItem = payIn.CreateLineItem;

    type DepositStatus = ValueOf<enums.IDepositStatus>;

    type PaymentStatus = ValueOf<enums.IPaymentStatus>;

    interface DepositData extends entityBase.EntityBaseData {
        AuthorId: string;

        DebitedFunds: MoneyData;

        Status: DepositStatus;

        PaymentStatus: PaymentStatus;

        PayinsLinked: PayinsLinkedData;

        ResultCode: string;

        ResultMessage: string;

        CardId: string;

        SecureModeReturnURL: string;

        SecureModeRedirectURL: string;

        SecureModeNeeded: boolean;

        ExpirationDate: Timestamp;

        PaymentType: PayInPaymentType;

        ExecutionType: PayInExecutionType;

        StatementDescriptor: string;

        Culture: CountryISO;

        IpAddress: string;

        BrowserInfo: BrowserInfoData;

        Billing: CompleteBillingData;

        Shipping: ShippingData;

        Requested3DSVersion: _3DSVersion;

        Applied3DSVersion: _3DSVersion;

        CardInfo: CardInfoData;

        /**
         * Authentication result
         */
        AuthenticationResult?: AuthenticationResult;

        /**
         * Information about the payment flow and its Beneficiaries.
         */
        FlowDescriptor?: FlowDescriptor;

        /**
         * The unique identifier of the buyer's PayPal account, provided by PayPal.
         */
        PaypalPayerID?: string;

        /**
         * The unique identifier of the order on the PayPal side.
         */
        PaypalOrderID?: string;

        /**
         * The first name of the buyer, returned by PayPal.
         */
        BuyerFirstname?: string;

        /**
         * The last name of the buyer, returned by PayPal.
         */
        BuyerLastname?: string;

        /**
         * The phone number of the buyer, returned by PayPal.
         */
        BuyerPhone?: string;

        /**
         * The country of the buyer, returned by PayPal.
         */
        BuyerCountry?: CountryISO;

        /**
         * The email address of the buyer's PayPal account.
         */
        PaypalBuyerAccountEmail?: string;

        /**
         * The URL to which the user is returned after canceling the payment.
         */
        CancelURL?: string;

        /**
         * Information about the shipment trackings.
         */
        Trackings?: PayPalWebTrackingData[];

        /**
         * The shipping preference used for the PayPal payment.
         */
        ShippingPreference?: ShippingPreference;

        /**
         * The platform’s order reference for the transaction.
         */
        Reference?: string;

        /**
         * Information about the items bought by the buyer.
         */
        LineItems?: LineItemData[];

        /**
         * The URL to which the user is redirected to complete the payment.
         */
        RedirectURL?: string;

        /**
         * The URL to which the user is returned after the payment, whether successful or not.
         */
        ReturnURL?: string;

        /**
         * The unique identifier of the Data Collection object containing the data PayPal needs to process the pay-in.
         */
        DataCollectionId?: string;
    }

    interface CreateDeposit {
        AuthorId: string;

        DebitedFunds: MoneyData;

        CardId: string;

        SecureModeReturnURL: string;

        StatementDescriptor?: string;

        Culture?: CountryISO;

        IpAddress: string;

        BrowserInfo: BrowserInfoData;

        Billing?: CompleteBillingData;

        Shipping?: ShippingData;

        /**
         * Information about the payment flow and its Beneficiaries.
         */
        FlowDescriptor?: FlowDescriptor;
    }

    interface CreatePayPalDepositPreauthorization {
        /**
         * The unique identifier of the user at the source of the transaction.
         */
        AuthorId: string;

        /**
         * Information about the preauthorized funds.
         */
        DebitedFunds: MoneyData;

        /**
         * The URL to which the user is returned after the payment, whether the transaction is successful or not.
         */
        ReturnURL: string;

        /**
         * The URL to which the user is returned after canceling the payment.
         * If not provided, the user is returned to the ReturnURL.
         */
        CancelURL?: string;

        /**
         * The unique identifier of the Data Collection object containing the data PayPal needs to process the pay-in.
         */
        DataCollectionId?: string;

        /**
         * The shipping preference for the payment.
         * One of SET_PROVIDED_ADDRESS, GET_FROM_FILE, or NO_SHIPPING.
         */
        ShippingPreference?: ShippingPreference;

        /**
         * Information about the end user’s shipping address.
         * Required if ShippingPreference is SET_PROVIDED_ADDRESS.
         */
        Shipping?: ShippingData;

        /**
         * The platform’s order reference for the transaction (max. 127 characters).
         */
        Reference?: string;

        /**
         * Custom data that you can add to this object (max. 255 characters).
         */
        Tag?: string;

        /**
         * Custom description to appear on the user’s bank statement (max. 10 characters, alphanumeric and spaces).
         */
        StatementDescriptor?: string;

        /**
         * The language in which the PayPal payment page is to be displayed, in ISO 639-1 format.
         */
        Culture?: CountryISO;

        /**
         * The reference to the profiling session used for fraud prevention.
         */
        ProfilingAttemptReference?: string;

        /**
         * Information about the items bought by the buyer.
         */
        LineItems?: CreateLineItem[];

        /**
         * Information about the payment flow and its Beneficiaries.
         */
        FlowDescriptor?: FlowDescriptor;
    }

    interface PayinsLinkedData {
        PayinCaptureId: string;
        PayinComplementId: string;
    }

    interface UpdateDeposit {
        Id: string;
        PaymentStatus?: PaymentStatus;
    }
}
