mirror of
https://github.com/SyncrowIOT/backend.git
synced 2025-07-14 09:57:28 +00:00
functioning API Call
This commit is contained in:
@ -112,7 +112,7 @@ export class AuthenticationService {
|
|||||||
return {
|
return {
|
||||||
t,
|
t,
|
||||||
path: url,
|
path: url,
|
||||||
client_id: this.accessKey,
|
client_id: 'this.accessKey',
|
||||||
sign: await this.encryptStr(signStr, this.secretKey),
|
sign: await this.encryptStr(signStr, this.secretKey),
|
||||||
sign_method: 'HMAC-SHA256',
|
sign_method: 'HMAC-SHA256',
|
||||||
access_token: this.token,
|
access_token: this.token,
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { Controller, Get, Query } from '@nestjs/common';
|
import { Controller, Get, Query } from '@nestjs/common';
|
||||||
import { UserService } from '../services/user.service';
|
import { UserService } from '../services/user.service';
|
||||||
import { UserListDto } from '../dtos/user.list.dto';
|
import { UserListDto } from '../dtos/user.list.dto';
|
||||||
|
|
||||||
|
@ -5,29 +5,24 @@ import { ConfigService } from '@nestjs/config';
|
|||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class UserService {
|
export class UserService {
|
||||||
private accessKey: string;
|
private tuya: TuyaContext;
|
||||||
private secretKey: string;
|
|
||||||
constructor(private readonly configService: ConfigService) {
|
constructor(private readonly configService: ConfigService) {
|
||||||
(this.accessKey = this.configService.get<string>('auth-config.ACCESS_KEY')),
|
const accessKey = this.configService.get<string>('auth-config.ACCESS_KEY');
|
||||||
(this.secretKey = this.configService.get<string>(
|
const secretKey = this.configService.get<string>('auth-config.SECRET_KEY');
|
||||||
'auth-config.SECRET_KEY',
|
// const clientId = this.configService.get<string>('auth-config.CLIENT_ID');
|
||||||
));
|
this.tuya = new TuyaContext({
|
||||||
|
baseUrl: 'https://openapi.tuyaeu.com',
|
||||||
|
accessKey,
|
||||||
|
secretKey,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
async userDetails(userListDto: UserListDto) {
|
async userDetails(userListDto: UserListDto) {
|
||||||
const url = `https://openapi.tuyaeu.com/v2.0/apps/${userListDto.schema}/users`;
|
const path = `/v2.0/apps/${userListDto.schema}/users`;
|
||||||
|
const data = await this.tuya.request({
|
||||||
const tuya = new TuyaContext({
|
|
||||||
baseUrl: 'https://openapi.tuyacn.com',
|
|
||||||
accessKey:this.secretKey,
|
|
||||||
secretKey:this.accessKey,
|
|
||||||
});
|
|
||||||
|
|
||||||
const data = await tuya.request({
|
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
path: url,
|
path,
|
||||||
query: userListDto,
|
query: userListDto,
|
||||||
});
|
});
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user