"use strict";
var __rest = (this && this.__rest) || function (s, e) {
    var t = {};
    for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
        t[p] = s[p];
    if (s != null && typeof Object.getOwnPropertySymbols === "function")
        for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
            if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
                t[p[i]] = s[p[i]];
        }
    return t;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.Customers = void 0;
const dayjs_1 = __importDefault(require("dayjs"));
const utc_1 = __importDefault(require("dayjs/plugin/utc"));
const codegen_1 = require("../codegen");
const base_1 = require("./base");
dayjs_1.default.extend(utc_1.default);
/**
 * Returns a date object if the input is a string, otherwise returns the input.
 */
const transformDate = (date) => {
    if (!date) {
        return undefined;
    }
    return date instanceof Date ? date : (0, dayjs_1.default)(date).utc(true).toDate();
};
class Customers extends base_1.BaseResource {
    constructor(apiConfig) {
        super(apiConfig);
        this.api = new codegen_1.CustomersApi(apiConfig);
    }
    /**
     * Create a new customer.
     */
    create(createCustomerArgs, overrides) {
        return this.api.customersPost({ createCustomerArgs }, overrides);
    }
    /**
     * Fetch a customer by their unique name.
     */
    retrieve(customerName, overrides) {
        return this.api.customersCustomerNameGet({ customerName }, overrides);
    }
    /**
     * Update a single customer.
     */
    update(customerName, updateCustomerArgs, overrides) {
        return this.api.customersCustomerNamePut({ customerName, updateCustomerArgs }, overrides);
    }
    /**
     * Retrieve all customers for a given vendor.
     */
    list(overrides) {
        return this.api.customersGet(overrides);
    }
    /**
     * Delete a customer by their unique name.
     */
    delete(customerName, overrides) {
        return this.api.customersCustomerNameDelete({ customerName }, overrides);
    }
    /**
     * Add PaymentGatewayCredential for a customer.
     */
    createPaymentGatewayCredential(customerName, customerPaymentGatewayCredentialInputArgs, overrides) {
        return this.api.customersCustomerNamePaymentGatewayCredentialsPost({
            customerName,
            customerPaymentGatewayCredentialInputArgs,
        }, overrides);
    }
    /**
     * Retrieve PaymentGatewayCredential for a customer.
     */
    retrievePaymentGatewayCredential(customerName, overrides) {
        return this.api.customersCustomerNamePaymentGatewayCredentialsGet({
            customerName,
        }, overrides);
    }
    /**
     * Create a new subscription for a customer / price plan combination (by unique name).
     */
    createSubscription(customerName, createSubscriptionArgs, overrides) {
        return this.api.customersCustomerNameSubscriptionsPost({ customerName, createSubscriptionArgs }, overrides);
    }
    /**
     * Get active subscription for the customer.
     */
    getActiveSubscription(customerName, overrides) {
        return this.api.customersCustomerNameActiveSubscriptionGet({ customerName }, overrides);
    }
    /**
     * Get all subscriptions for the customer.
     */
    listSubscriptions(customerName, overrides) {
        return this.api.customersCustomerNameSubscriptionsGet({ customerName }, overrides);
    }
    /**
     * Update a subscription for a specific customer (by customer name).
     */
    updateSubscription(customerName, updateSubscriptionArgs, overrides) {
        return this.api.customersCustomerNameSubscriptionPut({ customerName, updateSubscriptionArgs }, overrides);
    }
    /**
     * Delete a subscription for a specific customer (by customer name).
     */
    deleteSubscription(customerName, deleteSubscriptionArgs, overrides) {
        return this.api.customersCustomerNameSubscriptionDelete({ customerName, deleteSubscriptionArgs }, overrides);
    }
    /**
     * Modify subscription add ons.
     */
    modifySubscriptionAddOns(customerName, subscriptionAddOnItems, overrides) {
        return this.api.customersCustomerNameSubscriptionAddOnsPost({ customerName, subscriptionAddOnItem: subscriptionAddOnItems }, overrides);
    }
    /**
     * Retreive a customer's access to feature/limitation.
     */
    retrieveUsage(_a, overrides) {
        var { startTime, endTime } = _a, rest = __rest(_a, ["startTime", "endTime"]);
        return this.api.customersCustomerNameUsageGet(Object.assign({ startTime: transformDate(startTime), endTime: transformDate(endTime) }, rest), overrides);
    }
    /**
     * Retreive a customer's access to feature/limitation.
     */
    retrieveFeature(retrieveFeatureArgs, overrides) {
        return this.api.customersCustomerNameFeaturesFeatureNameGet(retrieveFeatureArgs, overrides);
    }
    /**
     * Get a list of scheduled subscriptions for the given customer.
     */
    getScheduledSubscription(retrieveFeatureArgs, overrides) {
        return this.api.customersCustomerNameScheduledSubscriptionsGet(retrieveFeatureArgs, overrides);
    }
    /**
     * Create the customer entity tied to your accounting software.
     */
    createAccountingCustomer(customerName, overrides) {
        return this.api.customersCustomerNameAccountingGenerationPost({ customerName }, overrides);
    }
    /**
     * Create customer's billing settings.
     */
    createBillingSettings(customerName, customerBillingSettingsInputArgs, overrides) {
        return this.api.customersCustomerNameBillingSettingsPost({ customerName, customerBillingSettingsInputArgs }, overrides);
    }
    /**
     * Update customer's billing settings.
     */
    updateBillingSettings(customerName, customerBillingSettingsInputArgs, overrides) {
        return this.api.customersCustomerNameBillingSettingsPut({ customerName, customerBillingSettingsInputArgs }, overrides);
    }
    /**
     * Delete customer's billing settings.
     */
    deleteBillingSettings(customerName, overrides) {
        return this.api.customersCustomerNameBillingSettingsDelete({ customerName }, overrides);
    }
    /**
     * Get Customer's status.
     */
    getCustomerStatus(customerName, overrides) {
        return this.api.customersCustomerNameStatusGet({ customerName }, overrides);
    }
    getCustomerInvoices(customerName, overrides) {
        return this.api.customersCustomerNameInvoicesGet({ customerName }, overrides);
    }
    getTotalAccrueRevenue(customerName, overrides) {
        return this.api.customersCustomerNameTotalAccruedRevenueGet({ customerName }, overrides);
    }
}
exports.Customers = Customers;
//# sourceMappingURL=data:application/json;base64, 