UNPKG

@warriorteam/redai-zalo-sdk

Version:

Comprehensive TypeScript/JavaScript SDK for Zalo APIs - Official Account, ZNS, Consultation Service, Group Messaging, and Social APIs

184 lines 7.42 kB
/** * User management service for Zalo API * Handles all user-related operations with specific endpoints */ import { ZaloClient } from "../clients/zalo-client"; import { UserInfo, UserListRequest, UserListResponse, TagUserRequest, RemoveTagFromUserRequest, UpdateUserRequest, GetUserCustomInfoRequest, UserCustomInfoResponse, UpdateUserCustomInfoRequest } from "../types/user"; /** * User management service for handling user operations * Each method uses specific Zalo API endpoints */ export declare class UserService { private readonly client; private readonly endpoints; constructor(client: ZaloClient); /** * Truy xuất chi tiết người dùng * Endpoint: https://openapi.zalo.me/v3.0/oa/user/detail * Method: GET with data parameter as JSON string * * @param accessToken OA access token * @param userId User ID to get details for * @returns Promise<UserInfo> - Detailed user information */ getUserInfo(accessToken: string, userId: string): Promise<UserInfo>; /** * Truy xuất danh sách người dùng * Endpoint: https://openapi.zalo.me/v3.0/oa/user/getlist * Method: GET with data parameter as JSON string * * @param accessToken OA access token * @param request User list request parameters * @returns Promise<UserListResponse> - List of users with pagination info */ getUserList(accessToken: string, request: UserListRequest): Promise<UserListResponse>; /** * Truy xuất danh sách người dùng (POST method) * Endpoint: https://openapi.zalo.me/v3.0/oa/user/getlist * Method: POST with data in request body * * @param accessToken OA access token * @param request User list request parameters * @returns Promise<UserListResponse> - List of users with pagination info */ postUserList(accessToken: string, request: UserListRequest): Promise<UserListResponse>; /** * Get all users with automatic pagination * Lấy tất cả users với phân trang tự động, đảm bảo lấy 100% * * @param accessToken Access token của OA * @param filters Bộ lọc tùy chọn * @returns Promise<UserInfo[]> - Danh sách đầy đủ tất cả users */ getAllUsers(accessToken: string, filters?: { tag_name?: string; last_interaction_period?: string; is_follower?: boolean; }): Promise<UserInfo[]>; /** * Get all user IDs only (without detailed info) - Faster version * Chỉ lấy danh sách user ID, không lấy thông tin chi tiết - Nhanh hơn * * @param accessToken Access token của OA * @param filters Bộ lọc tùy chọn * @returns Promise<string[]> - Danh sách user IDs */ getAllUserIds(accessToken: string, filters?: { tag_name?: string; last_interaction_period?: string; is_follower?: boolean; }): Promise<string[]>; /** * Cập nhật chi tiết người dùng * Endpoint: https://openapi.zalo.me/v3.0/oa/user/update * Method: POST * * @param accessToken OA access token * @param request Update user request with user_id and optional fields * @returns Promise<boolean> - true if successful */ updateUser(accessToken: string, request: UpdateUserRequest): Promise<boolean>; /** * Xóa thông tin người dùng * Endpoint: https://openapi.zalo.me/v2.0/oa/deletefollowerinfo * Method: POST * * @param accessToken OA access token * @param userId User ID to delete info for * @returns Promise<boolean> - true if successful * * Note: Chỉ xóa thông tin lưu trữ ở phía OA, không thay đổi tài khoản Zalo */ deleteUserInfo(accessToken: string, userId: string): Promise<boolean>; /** * Truy xuất thông tin tùy biến của người dùng * Endpoint: https://openapi.zalo.me/v3.0/oa/user/detail/custominfo * Method: GET with data parameter as JSON string * * @param accessToken OA access token * @param request Get custom info request with user_id and optional fields_to_export * @returns Promise<UserCustomInfoResponse> - Custom info data * * Note: Tất cả giá trị trong custom_info đều được trả về dưới dạng string */ getUserCustomInfo(accessToken: string, request: GetUserCustomInfoRequest): Promise<UserCustomInfoResponse>; /** * Cập nhật thông tin tùy biến của người dùng * Endpoint: https://openapi.zalo.me/v3.0/oa/user/update/custominfo * Method: POST * * @param accessToken OA access token * @param request Update custom info request with user_id and custom_info * @returns Promise<boolean> - true if successful * * Note: Cấu trúc custom_info phụ thuộc vào thiết lập OA */ updateUserCustomInfo(accessToken: string, request: UpdateUserCustomInfoRequest): Promise<boolean>; /** * Lấy danh sách nhãn * Endpoint: https://openapi.zalo.me/v2.0/oa/tag/gettagsofoa * Method: GET * * @param accessToken OA access token * @returns Promise<string[]> - Array of tag names */ getLabels(accessToken: string): Promise<string[]>; /** * Gắn nhãn người dùng * Endpoint: https://openapi.zalo.me/v2.0/oa/tag/tagfollower * * @param accessToken OA access token * @param request Tag user request with user_id and tag_name * @returns Promise<boolean> - true if successful * * Note: Nếu tag_name không tồn tại, API sẽ tự động tạo nhãn mới */ addTagToUser(accessToken: string, request: TagUserRequest): Promise<boolean>; /** * Gỡ nhãn người dùng * Endpoint: https://openapi.zalo.me/v2.0/oa/tag/rmfollowerfromtag * * @param accessToken OA access token * @param request Remove tag request with user_id and tag_name * @returns Promise<boolean> - true if successful */ removeTagFromUser(accessToken: string, request: RemoveTagFromUserRequest): Promise<boolean>; /** * Xóa nhãn * Endpoint: https://openapi.zalo.me/v2.0/oa/tag/rmtag * Method: POST * * @param accessToken OA access token * @param tagName Tag name to delete * @returns Promise<boolean> - true if successful */ deleteLabel(accessToken: string, tagName: string): Promise<boolean>; /** * Get users by tag */ getUsersByTag(accessToken: string, tagName: string, offset?: number, count?: number): Promise<UserListResponse>; /** * Get followers only */ getFollowers(accessToken: string, offset?: number, count?: number): Promise<UserListResponse>; /** * Get users by interaction period */ getUsersByInteraction(accessToken: string, period: "TODAY" | "YESTERDAY" | "L7D" | "L30D", offset?: number, count?: number): Promise<UserListResponse>; /** * Bulk tag operations */ bulkAddTag(accessToken: string, userIds: string[], tagName: string): Promise<{ success: string[]; failed: string[]; }>; /** * Bulk remove tag operations */ bulkRemoveTag(accessToken: string, userIds: string[], tagName: string): Promise<{ success: string[]; failed: string[]; }>; private handleError; } //# sourceMappingURL=user.service.d.ts.map