UNPKG

@sourceloop/ctrl-plane-subscription-service

Version:

Subscription management microservice for SaaS control plane.

251 lines 9.92 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.CurrencyController = void 0; const tslib_1 = require("tslib"); const repository_1 = require("@loopback/repository"); const rest_1 = require("@loopback/rest"); const models_1 = require("../models"); const repositories_1 = require("../repositories"); const loopback4_authorization_1 = require("loopback4-authorization"); const loopback4_authentication_1 = require("loopback4-authentication"); const permissions_1 = require("../permissions"); const core_1 = require("@sourceloop/core"); const basePath = '/currencies'; let CurrencyController = class CurrencyController { constructor(currencyRepository) { this.currencyRepository = currencyRepository; } async create(currency) { return this.currencyRepository.create(currency); } async count(where) { return this.currencyRepository.count(where); } async find(filter) { return this.currencyRepository.find(filter); } async updateAll(currency, where) { return this.currencyRepository.updateAll(currency, where); } async findById(id, filter) { return this.currencyRepository.findById(id, filter); } async updateById(id, currency) { await this.currencyRepository.updateById(id, currency); } async replaceById(id, currency) { await this.currencyRepository.replaceById(id, currency); } async deleteById(id) { await this.currencyRepository.deleteById(id); } }; exports.CurrencyController = CurrencyController; tslib_1.__decorate([ (0, loopback4_authorization_1.authorize)({ permissions: [permissions_1.PermissionKey.CreateCurrency], }), (0, loopback4_authentication_1.authenticate)("bearer" /* STRATEGY.BEARER */, { passReqToCallback: true, }), (0, rest_1.post)(basePath, { security: core_1.OPERATION_SECURITY_SPEC, responses: { [200 /* STATUS_CODE.OK */]: { description: 'Currency model instance', content: { 'application/json': { schema: (0, rest_1.getModelSchemaRef)(models_1.Currency) }, }, }, }, }), tslib_1.__param(0, (0, rest_1.requestBody)({ content: { 'application/json': { schema: (0, rest_1.getModelSchemaRef)(models_1.Currency, { title: 'NewCurrency', exclude: ['id'], }), }, }, })), tslib_1.__metadata("design:type", Function), tslib_1.__metadata("design:paramtypes", [Object]), tslib_1.__metadata("design:returntype", Promise) ], CurrencyController.prototype, "create", null); tslib_1.__decorate([ (0, loopback4_authorization_1.authorize)({ permissions: [permissions_1.PermissionKey.ViewCurrency], }), (0, loopback4_authentication_1.authenticate)("bearer" /* STRATEGY.BEARER */, { passReqToCallback: true, }), (0, rest_1.get)(`${basePath}/count`, { security: core_1.OPERATION_SECURITY_SPEC, responses: { [200 /* STATUS_CODE.OK */]: { description: 'Currency model count', content: { 'application/json': { schema: repository_1.CountSchema } }, }, }, }), tslib_1.__param(0, rest_1.param.where(models_1.Currency)), tslib_1.__metadata("design:type", Function), tslib_1.__metadata("design:paramtypes", [Object]), tslib_1.__metadata("design:returntype", Promise) ], CurrencyController.prototype, "count", null); tslib_1.__decorate([ (0, loopback4_authorization_1.authorize)({ permissions: [permissions_1.PermissionKey.ViewCurrency], }), (0, loopback4_authentication_1.authenticate)("bearer" /* STRATEGY.BEARER */, { passReqToCallback: true, }), (0, rest_1.get)(basePath, { security: core_1.OPERATION_SECURITY_SPEC, responses: { [200 /* STATUS_CODE.OK */]: { description: 'Array of Currency model instances', content: { 'application/json': { schema: { type: 'array', items: (0, rest_1.getModelSchemaRef)(models_1.Currency, { includeRelations: true }), }, }, }, }, }, }), tslib_1.__param(0, rest_1.param.filter(models_1.Currency)), tslib_1.__metadata("design:type", Function), tslib_1.__metadata("design:paramtypes", [Object]), tslib_1.__metadata("design:returntype", Promise) ], CurrencyController.prototype, "find", null); tslib_1.__decorate([ (0, loopback4_authorization_1.authorize)({ permissions: [permissions_1.PermissionKey.UpdateCurrency], }), (0, loopback4_authentication_1.authenticate)("bearer" /* STRATEGY.BEARER */, { passReqToCallback: true, }), (0, rest_1.patch)(basePath, { security: core_1.OPERATION_SECURITY_SPEC, responses: { [200 /* STATUS_CODE.OK */]: { description: 'Currency PATCH success count', content: { 'application/json': { schema: repository_1.CountSchema } }, }, }, }), tslib_1.__param(0, (0, rest_1.requestBody)({ content: { 'application/json': { schema: (0, rest_1.getModelSchemaRef)(models_1.Currency, { partial: true }), }, }, })), tslib_1.__param(1, rest_1.param.where(models_1.Currency)), tslib_1.__metadata("design:type", Function), tslib_1.__metadata("design:paramtypes", [models_1.Currency, Object]), tslib_1.__metadata("design:returntype", Promise) ], CurrencyController.prototype, "updateAll", null); tslib_1.__decorate([ (0, loopback4_authorization_1.authorize)({ permissions: [permissions_1.PermissionKey.ViewCurrency], }), (0, loopback4_authentication_1.authenticate)("bearer" /* STRATEGY.BEARER */, { passReqToCallback: true, }), (0, rest_1.get)(`${basePath}/{id}`, { security: core_1.OPERATION_SECURITY_SPEC, responses: { [200 /* STATUS_CODE.OK */]: { description: 'Currency model instance', content: { 'application/json': { schema: (0, rest_1.getModelSchemaRef)(models_1.Currency, { includeRelations: true }), }, }, }, }, }), tslib_1.__param(0, rest_1.param.path.string('id')), tslib_1.__param(1, rest_1.param.filter(models_1.Currency, { exclude: 'where' })), tslib_1.__metadata("design:type", Function), tslib_1.__metadata("design:paramtypes", [String, Object]), tslib_1.__metadata("design:returntype", Promise) ], CurrencyController.prototype, "findById", null); tslib_1.__decorate([ (0, loopback4_authorization_1.authorize)({ permissions: [permissions_1.PermissionKey.UpdateCurrency], }), (0, loopback4_authentication_1.authenticate)("bearer" /* STRATEGY.BEARER */, { passReqToCallback: true, }), (0, rest_1.patch)(`${basePath}/{id}`, { security: core_1.OPERATION_SECURITY_SPEC, responses: { [204 /* STATUS_CODE.NO_CONTENT */]: { description: 'Currency PATCH success', }, }, }), tslib_1.__param(0, rest_1.param.path.string('id')), tslib_1.__param(1, (0, rest_1.requestBody)({ content: { 'application/json': { schema: (0, rest_1.getModelSchemaRef)(models_1.Currency, { partial: true }), }, }, })), tslib_1.__metadata("design:type", Function), tslib_1.__metadata("design:paramtypes", [String, models_1.Currency]), tslib_1.__metadata("design:returntype", Promise) ], CurrencyController.prototype, "updateById", null); tslib_1.__decorate([ (0, loopback4_authorization_1.authorize)({ permissions: [permissions_1.PermissionKey.UpdateCurrency], }), (0, loopback4_authentication_1.authenticate)("bearer" /* STRATEGY.BEARER */, { passReqToCallback: true, }), (0, rest_1.put)(`${basePath}/{id}`, { security: core_1.OPERATION_SECURITY_SPEC, responses: { [204 /* STATUS_CODE.NO_CONTENT */]: { description: 'Currency PUT success', }, }, }), tslib_1.__param(0, rest_1.param.path.string('id')), tslib_1.__param(1, (0, rest_1.requestBody)()), tslib_1.__metadata("design:type", Function), tslib_1.__metadata("design:paramtypes", [String, models_1.Currency]), tslib_1.__metadata("design:returntype", Promise) ], CurrencyController.prototype, "replaceById", null); tslib_1.__decorate([ (0, loopback4_authorization_1.authorize)({ permissions: [permissions_1.PermissionKey.DeleteCurrency], }), (0, loopback4_authentication_1.authenticate)("bearer" /* STRATEGY.BEARER */, { passReqToCallback: true, }), (0, rest_1.del)(`${basePath}/{id}`, { security: core_1.OPERATION_SECURITY_SPEC, responses: { [204 /* STATUS_CODE.NO_CONTENT */]: { description: 'Currency DELETE success', }, }, }), tslib_1.__param(0, rest_1.param.path.string('id')), tslib_1.__metadata("design:type", Function), tslib_1.__metadata("design:paramtypes", [String]), tslib_1.__metadata("design:returntype", Promise) ], CurrencyController.prototype, "deleteById", null); exports.CurrencyController = CurrencyController = tslib_1.__decorate([ tslib_1.__param(0, (0, repository_1.repository)(repositories_1.CurrencyRepository)), tslib_1.__metadata("design:paramtypes", [repositories_1.CurrencyRepository]) ], CurrencyController); //# sourceMappingURL=currency.controller.js.map