@constructorfleet/ultimate-govee
Version:
Library for interacting with Govee devices written in Typescript.
40 lines • 2.09 kB
JavaScript
;
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.RefreshAuthenticationCommandHandler = void 0;
const cqrs_1 = require("@nestjs/cqrs");
const _ultimate_govee_data_1 = require("../../../data");
const commands_1 = require("../commands");
const auth_service_1 = require("../auth.service");
let RefreshAuthenticationCommandHandler = class RefreshAuthenticationCommandHandler {
constructor(goveeApi, authService) {
this.goveeApi = goveeApi;
this.authService = authService;
}
async execute(command) {
const authdata = await this.goveeApi.refresh(command.oauth);
if (authdata === undefined) {
return authdata;
}
this.authService.setAuthData({
accountId: command.accountId,
clientId: command.clientId,
oauth: authdata,
});
}
};
exports.RefreshAuthenticationCommandHandler = RefreshAuthenticationCommandHandler;
exports.RefreshAuthenticationCommandHandler = RefreshAuthenticationCommandHandler = __decorate([
(0, cqrs_1.CommandHandler)(commands_1.RefreshAuthenticationCommand),
__metadata("design:paramtypes", [_ultimate_govee_data_1.GoveeAccountService,
auth_service_1.AuthService])
], RefreshAuthenticationCommandHandler);
//# sourceMappingURL=refresh-authentication.handler.js.map