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