UNPKG

@sourceloop/ctrl-plane-subscription-service

Version:

Subscription management microservice for SaaS control plane.

152 lines 6.64 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.BillingCustomerController = void 0; const tslib_1 = require("tslib"); const core_1 = require("@loopback/core"); const rest_1 = require("@loopback/rest"); const core_2 = require("@sourceloop/core"); const loopback4_authentication_1 = require("loopback4-authentication"); const loopback4_authorization_1 = require("loopback4-authorization"); const billing_customer_model_1 = require("../models/billing-customer.model"); const customer_dto_model_1 = require("../models/dto/customer-dto.model"); const permissions_1 = require("../permissions"); const billing_customer_service_1 = require("../services/billing-customer.service"); const basePath = '/billing-customer'; let BillingCustomerController = class BillingCustomerController { /** * This TypeScript constructor injects the BillingCustomerService dependency using the @inject * decorator. * @param {BillingCustomerService} billingCustomerService - The `billingCustomerService` parameter is * an instance of the `BillingCustomerService` class that is being injected into the constructor * using dependency injection. This allows the class to have access to the functionality provided by * the `BillingCustomerService` class within its methods. */ constructor(billingCustomerService) { this.billingCustomerService = billingCustomerService; } async create(customerDto, tenantId) { return this.billingCustomerService.createCustomer(customerDto, tenantId); } async getCustomer(filter) { return this.billingCustomerService.getCustomer(filter); } async updateById(tenantId, customerDto) { return this.billingCustomerService.updateCustomerByTenantId(tenantId, customerDto); } async deleteById(tenantId) { return this.billingCustomerService.deleteCustomerByTenantId(tenantId); } }; exports.BillingCustomerController = BillingCustomerController; tslib_1.__decorate([ (0, loopback4_authorization_1.authorize)({ permissions: [permissions_1.PermissionKey.CreateBillingCustomer], }), (0, loopback4_authentication_1.authenticate)("bearer" /* STRATEGY.BEARER */, { passReqToCallback: true, }), (0, rest_1.post)(basePath, { security: core_2.OPERATION_SECURITY_SPEC, responses: { [200 /* STATUS_CODE.OK */]: { description: 'BillingCustomer model instance', content: { 'application/json': { schema: (0, core_2.getModelSchemaRefSF)(customer_dto_model_1.CustomerDto, { title: 'NewBillingCustomer', }), }, }, }, }, }), tslib_1.__param(0, (0, rest_1.requestBody)({ content: { 'application/json': { schema: (0, core_2.getModelSchemaRefSF)(customer_dto_model_1.CustomerDto, { title: 'NewCustomer', exclude: ['id'], }), }, }, })), tslib_1.__param(1, rest_1.param.header.string('tenantId')), tslib_1.__metadata("design:type", Function), tslib_1.__metadata("design:paramtypes", [Object, String]), tslib_1.__metadata("design:returntype", Promise) ], BillingCustomerController.prototype, "create", null); tslib_1.__decorate([ (0, loopback4_authorization_1.authorize)({ permissions: [permissions_1.PermissionKey.GetBillingCustomer], }), (0, loopback4_authentication_1.authenticate)("bearer" /* STRATEGY.BEARER */, { passReqToCallback: true, }), (0, rest_1.get)(basePath, { security: core_2.OPERATION_SECURITY_SPEC, responses: { [200 /* STATUS_CODE.OK */]: { description: 'BillingCustomer model ', content: { 'application/json': { schema: (0, core_2.getModelSchemaRefSF)(customer_dto_model_1.CustomerDto) }, }, }, }, }), tslib_1.__param(0, rest_1.param.filter(billing_customer_model_1.BillingCustomer)), tslib_1.__metadata("design:type", Function), tslib_1.__metadata("design:paramtypes", [Object]), tslib_1.__metadata("design:returntype", Promise) ], BillingCustomerController.prototype, "getCustomer", null); tslib_1.__decorate([ (0, loopback4_authorization_1.authorize)({ permissions: [permissions_1.PermissionKey.UpdateBillingCustomer], }), (0, loopback4_authentication_1.authenticate)("bearer" /* STRATEGY.BEARER */, { passReqToCallback: true, }), (0, rest_1.patch)(`${basePath}/{tenantId}`, { security: core_2.OPERATION_SECURITY_SPEC, responses: { [204 /* STATUS_CODE.NO_CONTENT */]: { description: 'BillingCustomer PATCH success', }, }, }), tslib_1.__param(0, rest_1.param.path.string('tenantId')), tslib_1.__param(1, (0, rest_1.requestBody)({ content: { 'application/json': { schema: (0, core_2.getModelSchemaRefSF)(customer_dto_model_1.CustomerDto, { partial: true }), }, }, })), tslib_1.__metadata("design:type", Function), tslib_1.__metadata("design:paramtypes", [String, Object]), tslib_1.__metadata("design:returntype", Promise) ], BillingCustomerController.prototype, "updateById", null); tslib_1.__decorate([ (0, loopback4_authorization_1.authorize)({ permissions: [permissions_1.PermissionKey.DeleteBillingCustomer], }), (0, loopback4_authentication_1.authenticate)("bearer" /* STRATEGY.BEARER */, { passReqToCallback: true, }), (0, rest_1.del)(`${basePath}/{tenantId}`, { security: core_2.OPERATION_SECURITY_SPEC, responses: { [204 /* STATUS_CODE.NO_CONTENT */]: { description: 'BillingCustomer DELETE success', }, }, }), tslib_1.__param(0, rest_1.param.path.string('tenantId')), tslib_1.__metadata("design:type", Function), tslib_1.__metadata("design:paramtypes", [String]), tslib_1.__metadata("design:returntype", Promise) ], BillingCustomerController.prototype, "deleteById", null); exports.BillingCustomerController = BillingCustomerController = tslib_1.__decorate([ tslib_1.__param(0, (0, core_1.inject)('services.BillingCustomerService')), tslib_1.__metadata("design:paramtypes", [billing_customer_service_1.BillingCustomerService]) ], BillingCustomerController); //# sourceMappingURL=billing-customer.controller.js.map