From 4902f0e6ae13d52870f2b423251fb29c7d6b8a74 Mon Sep 17 00:00:00 2001 From: IlirEdis Date: Sun, 2 Jun 2024 20:36:59 +0200 Subject: [PATCH 1/3] I noticed that there is an array called product inside the products object so i fixed the type of it --- src/interface/orders/get-products.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/interface/orders/get-products.ts b/src/interface/orders/get-products.ts index 5277ed1..d32c714 100644 --- a/src/interface/orders/get-products.ts +++ b/src/interface/orders/get-products.ts @@ -7,9 +7,9 @@ export interface GetProductsRequest { export interface GetProductsResponse { result: string; totalresults: number; - startnumber; number; + startnumber: number; numreturned: number; - products: Product[]; + products: { product: Product[] }; } export interface Product { From f6bd1b048a2d2dea4147fb0fc92fb86561c86959 Mon Sep 17 00:00:00 2001 From: IlirEdis Date: Fri, 7 Jun 2024 14:25:27 +0200 Subject: [PATCH 2/3] this should be optional --- src/interface/client/add-client.ts | 54 +++++++++++++++--------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/src/interface/client/add-client.ts b/src/interface/client/add-client.ts index bc53483..dd7fe5d 100644 --- a/src/interface/client/add-client.ts +++ b/src/interface/client/add-client.ts @@ -1,32 +1,32 @@ export interface AddClientRequest { - owner_user_id: number; - firstname: string; - lastname: string; - companyname?: string; - email: string; - address1: string; - address2?: string; - city: string; - state: string; - postcode: string; - country: string; - phonenumber: string; - tax_id?: string; - password2?: string; - securityqid?: number; - securityqans?: string; - currency?: number; - groupid?: number; - customfields?: string; - language?: string; - clientip?: string; - notes?: string; - marketingoptin?: boolean; - noemail?: boolean; - skipvalidation?: boolean; + owner_user_id?: number; + firstname: string; + lastname: string; + companyname?: string; + email: string; + address1: string; + address2?: string; + city: string; + state: string; + postcode: string; + country: string; + phonenumber: string; + tax_id?: string; + password2?: string; + securityqid?: number; + securityqans?: string; + currency?: number; + groupid?: number; + customfields?: string; + language?: string; + clientip?: string; + notes?: string; + marketingoptin?: boolean; + noemail?: boolean; + skipvalidation?: boolean; } export interface AddClientResponse { - result: string; - clientid: string; + result: string; + clientid: string; } From 5f185c58565ea45bb4390b350ee7c751fff74dc8 Mon Sep 17 00:00:00 2001 From: IlirEdis Date: Fri, 7 Jun 2024 19:48:41 +0200 Subject: [PATCH 3/3] getUsers function added --- src/interface/users/get-users.ts | 14 +++++ src/module/users.ts | 105 +++++++++++++++++++++---------- 2 files changed, 87 insertions(+), 32 deletions(-) create mode 100644 src/interface/users/get-users.ts diff --git a/src/interface/users/get-users.ts b/src/interface/users/get-users.ts new file mode 100644 index 0000000..8449abb --- /dev/null +++ b/src/interface/users/get-users.ts @@ -0,0 +1,14 @@ +export interface GetUsersRequest { + limitstart?: number; + limitnum?: number; + sorting?: string; + search?: string; +} + +export interface GetUsersResponse { + result: string; + totalresults: number; + startnumber: number; + numreturned: number; + users: []; +} diff --git a/src/module/users.ts b/src/module/users.ts index 5b04911..5ef8b00 100644 --- a/src/module/users.ts +++ b/src/module/users.ts @@ -1,45 +1,86 @@ import { AddUserRequest, AddUserResponse } from "../interface/users/add-user"; -import { CreateClientInviteRequest, CreateClientInviteResponse } from "../interface/users/create-client-invite"; -import { DeleteUserClientRequest, DeleteUserClientResponse } from "../interface/users/delete-user-client"; -import { GetPermissionsListRequest, GetPermissionsListResponse } from "../interface/users/get-permissions-list"; -import { GetUserPermissionsRequest, GetUserPermissionsResponse } from "../interface/users/get-user-permissions"; -import { ResetPasswordRequest, ResetPasswordResponse } from "../interface/users/reset-password"; -import { UpdateUserRequest, UpdateUserResponse } from "../interface/users/update-user"; -import { UpdateUserPermissionsRequest, UpdateUserPermissionsResponse } from "../interface/users/update-user-permissions"; +import { + CreateClientInviteRequest, + CreateClientInviteResponse, +} from "../interface/users/create-client-invite"; +import { + DeleteUserClientRequest, + DeleteUserClientResponse, +} from "../interface/users/delete-user-client"; +import { + GetPermissionsListRequest, + GetPermissionsListResponse, +} from "../interface/users/get-permissions-list"; +import { + GetUserPermissionsRequest, + GetUserPermissionsResponse, +} from "../interface/users/get-user-permissions"; +import { + GetUsersRequest, + GetUsersResponse, +} from "../interface/users/get-users"; +import { + ResetPasswordRequest, + ResetPasswordResponse, +} from "../interface/users/reset-password"; +import { + UpdateUserRequest, + UpdateUserResponse, +} from "../interface/users/update-user"; +import { + UpdateUserPermissionsRequest, + UpdateUserPermissionsResponse, +} from "../interface/users/update-user-permissions"; import { BaseModule } from "./base"; export class WhmcsUsersService extends BaseModule { - public async addUser(options: AddUserRequest): Promise { - return this.request('AddUser', options); + return this.request("AddUser", options); } - - public async createClientInvite(options: CreateClientInviteRequest): Promise { - return this.request('CreateClientInvite', options); + + public async createClientInvite( + options: CreateClientInviteRequest + ): Promise { + return this.request("CreateClientInvite", options); } - - public async deleteUserClient(options: DeleteUserClientRequest): Promise { - return this.request('DeleteUserClient', options); + + public async deleteUserClient( + options: DeleteUserClientRequest + ): Promise { + return this.request("DeleteUserClient", options); } - - public async getPermissionsList(options: GetPermissionsListRequest): Promise { - return this.request('GetPermissionsList', options); + + public async getPermissionsList( + options: GetPermissionsListRequest + ): Promise { + return this.request("GetPermissionsList", options); } - - public async getUserPermissions(options: GetUserPermissionsRequest): Promise { - return this.request('GetUserPermissions', options); + + public async getUserPermissions( + options: GetUserPermissionsRequest + ): Promise { + return this.request("GetUserPermissions", options); } - - public async resetPassword(options: ResetPasswordRequest): Promise { - return this.request('ResetPassword', options); + + public async getUsers(options: GetUsersRequest): Promise { + return this.request("GetUsers", options); } - - public async updateUser(options: UpdateUserRequest): Promise { - return this.request('UpdateUser', options); + + public async resetPassword( + options: ResetPasswordRequest + ): Promise { + return this.request("ResetPassword", options); + } + + public async updateUser( + options: UpdateUserRequest + ): Promise { + return this.request("UpdateUser", options); } - - public async updateUserPermissions(options: UpdateUserPermissionsRequest): Promise { - return this.request('UpdateUserPermissions', options); + + public async updateUserPermissions( + options: UpdateUserPermissionsRequest + ): Promise { + return this.request("UpdateUserPermissions", options); } - -} \ No newline at end of file +}