"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.PricePlans = void 0;
const codegen_1 = require("../codegen");
const base_1 = require("./base");
class PricePlans extends base_1.BaseResource {
    constructor(apiConfig) {
        super(apiConfig);
        this.api = new codegen_1.PricePlansApi(apiConfig);
    }
    /**
     * Create Price Plan.
     */
    create(createPricePlanArgs, overrides) {
        return this.api.pricePlansPost({ createPricePlanArgs }, overrides);
    }
    /**
     * Fetch an existing price plan.
     */
    retrieve(pricePlanName, overrides) {
        return new Promise((resolve, reject) => {
            this.api
                .pricePlansPricePlanNameGet({ pricePlanName }, overrides)
                .then((pricePlan) => {
                if (!pricePlan.name) {
                    throw new Error('Price plan does not exist');
                }
                resolve(pricePlan);
            })
                .catch(reject);
        });
        // TODO: when price plan does not exist, no 404, just empty response body
        // return this.api.pricePlansPricePlanNameGet(pricePlanName, options);
    }
    /**
     * Update a meter by its unique name.
     */
    update(pricePlanName, updatePricePlanArgs, overrides) {
        return this.api.pricePlansPricePlanNamePut({ updatePricePlanArgs, pricePlanName }, overrides);
    }
    /**
     * Retrieve all meters for a given vendor.
     */
    list(overrides) {
        return this.api.pricePlansGet(overrides);
    }
    /**
     * Delete a meter by its unique name.
     */
    delete(pricePlanName, overrides) {
        return this.api.pricePlansPricePlanNameDelete({ pricePlanName }, overrides);
    }
}
exports.PricePlans = PricePlans;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHJpY2VwbGFucy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9yZXNvdXJjZXMvcHJpY2VwbGFucy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7QUFBQSx3Q0FNb0I7QUFDcEIsaUNBQXNDO0FBRXRDLE1BQU0sVUFBVyxTQUFRLG1CQUFZO0lBR25DLFlBQVksU0FBMkI7UUFDckMsS0FBSyxDQUFDLFNBQVMsQ0FBQyxDQUFDO1FBQ2pCLElBQUksQ0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