zalo-toolkit 1.1.6 → 1.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/apis/getAvatarUrlProfile.d.ts +7 -0
- package/dist/apis/getAvatarUrlProfile.js +30 -0
- package/dist/apis/getFullAvatar.d.ts +5 -0
- package/dist/apis/getFullAvatar.js +25 -0
- package/dist/apis.d.ts +4 -0
- package/dist/apis.js +4 -0
- package/dist/cjs/apis/getAvatarUrlProfile.cjs +43 -0
- package/dist/cjs/apis/getFullAvatar.cjs +30 -0
- package/dist/cjs/apis.cjs +4 -0
- package/dist/cjs/index.cjs +4 -0
- package/dist/cjs/models/Enum.cjs +5 -0
- package/dist/models/Enum.d.ts +4 -0
- package/dist/models/Enum.js +5 -0
- package/package.json +1 -1
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { AvatarSize } from '../models/index.js';
|
|
2
|
+
export type GetAvatarUrlProfileResponse = {
|
|
3
|
+
[userId: string]: {
|
|
4
|
+
avatar: string;
|
|
5
|
+
};
|
|
6
|
+
};
|
|
7
|
+
export declare const getAvatarUrlProfileFactory: (ctx: import("../context.js").ContextBase, api: import("../apis.js").ZaloAPI) => (friendIds: string | string[], avatarSize?: AvatarSize) => Promise<GetAvatarUrlProfileResponse>;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { ZaloApiError } from '../Errors/ZaloApiError.js';
|
|
2
|
+
import { AvatarSize } from '../models/index.js';
|
|
3
|
+
import { apiFactory } from '../utils.js';
|
|
4
|
+
export const getAvatarUrlProfileFactory = apiFactory()((api, _ctx, utils) => {
|
|
5
|
+
const serviceURL = utils.makeURL(`${api.zpwServiceMap.profile[0]}/api/social/profile/avatar-url`);
|
|
6
|
+
/**
|
|
7
|
+
* Get avatar url profile
|
|
8
|
+
*
|
|
9
|
+
* @param friendId friend id(s)
|
|
10
|
+
* @param avatarSize Avatar size (default: AvatarSize.Large)
|
|
11
|
+
*
|
|
12
|
+
* @throws {ZaloApiError}
|
|
13
|
+
*/
|
|
14
|
+
return async function getAvatarUrlProfile(friendIds, avatarSize = AvatarSize.Large) {
|
|
15
|
+
if (!Array.isArray(friendIds))
|
|
16
|
+
friendIds = [friendIds];
|
|
17
|
+
const params = {
|
|
18
|
+
friend_ids: friendIds,
|
|
19
|
+
avatar_size: avatarSize,
|
|
20
|
+
srcReq: -1,
|
|
21
|
+
};
|
|
22
|
+
const encryptedParams = utils.encodeAES(JSON.stringify(params));
|
|
23
|
+
if (!encryptedParams)
|
|
24
|
+
throw new ZaloApiError('Failed to encrypt params');
|
|
25
|
+
const response = await utils.request(utils.makeURL(serviceURL, { params: encryptedParams }), {
|
|
26
|
+
method: 'GET',
|
|
27
|
+
});
|
|
28
|
+
return utils.resolve(response);
|
|
29
|
+
};
|
|
30
|
+
});
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { ZaloApiError } from '../Errors/ZaloApiError.js';
|
|
2
|
+
import { apiFactory } from '../utils.js';
|
|
3
|
+
export const getFullAvatarFactory = apiFactory()((api, ctx, utils) => {
|
|
4
|
+
const serviceURL = utils.makeURL(`${api.zpwServiceMap.profile[0]}/api/social/profile/avatar`);
|
|
5
|
+
/**
|
|
6
|
+
* Get full avatar
|
|
7
|
+
*
|
|
8
|
+
* @param friendId friend id
|
|
9
|
+
*
|
|
10
|
+
* @throws {ZaloApiError}
|
|
11
|
+
*/
|
|
12
|
+
return async function getFullAvatar(friendId) {
|
|
13
|
+
const params = {
|
|
14
|
+
fid: friendId,
|
|
15
|
+
imei: ctx.imei,
|
|
16
|
+
};
|
|
17
|
+
const encryptedParams = utils.encodeAES(JSON.stringify(params));
|
|
18
|
+
if (!encryptedParams)
|
|
19
|
+
throw new ZaloApiError('Failed to encrypt params');
|
|
20
|
+
const response = await utils.request(utils.makeURL(serviceURL, { params: encryptedParams }), {
|
|
21
|
+
method: 'GET',
|
|
22
|
+
});
|
|
23
|
+
return utils.resolve(response);
|
|
24
|
+
};
|
|
25
|
+
});
|
package/dist/apis.d.ts
CHANGED
|
@@ -80,6 +80,7 @@ import { updateLabelsFactory } from "./apis/updateLabels.js";
|
|
|
80
80
|
import { updateActiveStatusFactory } from "./apis/updateActiveStatus.js";
|
|
81
81
|
import { sendTypingEventFactory } from "./apis/sendTypingEvent.js";
|
|
82
82
|
import { removeGroupBlockedMemberFactory } from "./apis/removeGroupBlockedMember.js";
|
|
83
|
+
import { getFullAvatarFactory } from "./apis/getFullAvatar.js";
|
|
83
84
|
import { getAutoDeleteChatFactory } from "./apis/getAutoDeleteChat.js";
|
|
84
85
|
import { getAliasListFactory } from "./apis/getAliasList.js";
|
|
85
86
|
import { getLabelsFactory } from "./apis/getLabels.js";
|
|
@@ -121,6 +122,7 @@ import { sendCardFactory } from "./apis/sendCard.js";
|
|
|
121
122
|
import { getRelatedFriendGroupFactory } from "./apis/getRelatedFriendGroup.js";
|
|
122
123
|
import { inviteUserToGroupsFactory } from "./apis/inviteUserToGroups.js";
|
|
123
124
|
import { blockUserFactory } from "./apis/blockUser.js";
|
|
125
|
+
import { getAvatarUrlProfileFactory } from "./apis/getAvatarUrlProfile.js";
|
|
124
126
|
import { sendMessageFactory } from "./apis/sendMessage.js";
|
|
125
127
|
import { updateProfileFactory } from "./apis/updateProfile.js";
|
|
126
128
|
import { getHiddenConversationsFactory } from "./apis/getHiddenConversations.js";
|
|
@@ -231,6 +233,7 @@ export declare class ZaloAPI {
|
|
|
231
233
|
updateActiveStatus: ReturnType<typeof updateActiveStatusFactory>;
|
|
232
234
|
sendTypingEvent: ReturnType<typeof sendTypingEventFactory>;
|
|
233
235
|
removeGroupBlockedMember: ReturnType<typeof removeGroupBlockedMemberFactory>;
|
|
236
|
+
getFullAvatar: ReturnType<typeof getFullAvatarFactory>;
|
|
234
237
|
getAutoDeleteChat: ReturnType<typeof getAutoDeleteChatFactory>;
|
|
235
238
|
getAliasList: ReturnType<typeof getAliasListFactory>;
|
|
236
239
|
getLabels: ReturnType<typeof getLabelsFactory>;
|
|
@@ -272,6 +275,7 @@ export declare class ZaloAPI {
|
|
|
272
275
|
getRelatedFriendGroup: ReturnType<typeof getRelatedFriendGroupFactory>;
|
|
273
276
|
inviteUserToGroups: ReturnType<typeof inviteUserToGroupsFactory>;
|
|
274
277
|
blockUser: ReturnType<typeof blockUserFactory>;
|
|
278
|
+
getAvatarUrlProfile: ReturnType<typeof getAvatarUrlProfileFactory>;
|
|
275
279
|
sendMessage: ReturnType<typeof sendMessageFactory>;
|
|
276
280
|
updateProfile: ReturnType<typeof updateProfileFactory>;
|
|
277
281
|
getHiddenConversations: ReturnType<typeof getHiddenConversationsFactory>;
|
package/dist/apis.js
CHANGED
|
@@ -79,6 +79,7 @@ import { updateLabelsFactory } from "./apis/updateLabels.js";
|
|
|
79
79
|
import { updateActiveStatusFactory } from "./apis/updateActiveStatus.js";
|
|
80
80
|
import { sendTypingEventFactory } from "./apis/sendTypingEvent.js";
|
|
81
81
|
import { removeGroupBlockedMemberFactory } from "./apis/removeGroupBlockedMember.js";
|
|
82
|
+
import { getFullAvatarFactory } from "./apis/getFullAvatar.js";
|
|
82
83
|
import { getAutoDeleteChatFactory } from "./apis/getAutoDeleteChat.js";
|
|
83
84
|
import { getAliasListFactory } from "./apis/getAliasList.js";
|
|
84
85
|
import { getLabelsFactory } from "./apis/getLabels.js";
|
|
@@ -120,6 +121,7 @@ import { sendCardFactory } from "./apis/sendCard.js";
|
|
|
120
121
|
import { getRelatedFriendGroupFactory } from "./apis/getRelatedFriendGroup.js";
|
|
121
122
|
import { inviteUserToGroupsFactory } from "./apis/inviteUserToGroups.js";
|
|
122
123
|
import { blockUserFactory } from "./apis/blockUser.js";
|
|
124
|
+
import { getAvatarUrlProfileFactory } from "./apis/getAvatarUrlProfile.js";
|
|
123
125
|
import { sendMessageFactory } from "./apis/sendMessage.js";
|
|
124
126
|
import { updateProfileFactory } from "./apis/updateProfile.js";
|
|
125
127
|
import { getHiddenConversationsFactory } from "./apis/getHiddenConversations.js";
|
|
@@ -225,6 +227,7 @@ export class ZaloAPI {
|
|
|
225
227
|
this.updateActiveStatus = updateActiveStatusFactory(ctx, this);
|
|
226
228
|
this.sendTypingEvent = sendTypingEventFactory(ctx, this);
|
|
227
229
|
this.removeGroupBlockedMember = removeGroupBlockedMemberFactory(ctx, this);
|
|
230
|
+
this.getFullAvatar = getFullAvatarFactory(ctx, this);
|
|
228
231
|
this.getAutoDeleteChat = getAutoDeleteChatFactory(ctx, this);
|
|
229
232
|
this.getAliasList = getAliasListFactory(ctx, this);
|
|
230
233
|
this.getLabels = getLabelsFactory(ctx, this);
|
|
@@ -266,6 +269,7 @@ export class ZaloAPI {
|
|
|
266
269
|
this.getRelatedFriendGroup = getRelatedFriendGroupFactory(ctx, this);
|
|
267
270
|
this.inviteUserToGroups = inviteUserToGroupsFactory(ctx, this);
|
|
268
271
|
this.blockUser = blockUserFactory(ctx, this);
|
|
272
|
+
this.getAvatarUrlProfile = getAvatarUrlProfileFactory(ctx, this);
|
|
269
273
|
this.sendMessage = sendMessageFactory(ctx, this);
|
|
270
274
|
this.updateProfile = updateProfileFactory(ctx, this);
|
|
271
275
|
this.getHiddenConversations = getHiddenConversationsFactory(ctx, this);
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var ZaloApiError = require('../Errors/ZaloApiError.cjs');
|
|
4
|
+
require('../models/AutoReply.cjs');
|
|
5
|
+
require('../models/Board.cjs');
|
|
6
|
+
var Enum = require('../models/Enum.cjs');
|
|
7
|
+
require('../models/FriendEvent.cjs');
|
|
8
|
+
require('../models/Group.cjs');
|
|
9
|
+
require('../models/GroupEvent.cjs');
|
|
10
|
+
var utils = require('../utils.cjs');
|
|
11
|
+
require('../models/Reaction.cjs');
|
|
12
|
+
require('../models/Reminder.cjs');
|
|
13
|
+
require('../models/ZBusiness.cjs');
|
|
14
|
+
|
|
15
|
+
const getAvatarUrlProfileFactory = utils.apiFactory()((api, _ctx, utils) => {
|
|
16
|
+
const serviceURL = utils.makeURL(`${api.zpwServiceMap.profile[0]}/api/social/profile/avatar-url`);
|
|
17
|
+
/**
|
|
18
|
+
* Get avatar url profile
|
|
19
|
+
*
|
|
20
|
+
* @param friendId friend id(s)
|
|
21
|
+
* @param avatarSize Avatar size (default: AvatarSize.Large)
|
|
22
|
+
*
|
|
23
|
+
* @throws {ZaloApiError}
|
|
24
|
+
*/
|
|
25
|
+
return async function getAvatarUrlProfile(friendIds, avatarSize = Enum.AvatarSize.Large) {
|
|
26
|
+
if (!Array.isArray(friendIds))
|
|
27
|
+
friendIds = [friendIds];
|
|
28
|
+
const params = {
|
|
29
|
+
friend_ids: friendIds,
|
|
30
|
+
avatar_size: avatarSize,
|
|
31
|
+
srcReq: -1,
|
|
32
|
+
};
|
|
33
|
+
const encryptedParams = utils.encodeAES(JSON.stringify(params));
|
|
34
|
+
if (!encryptedParams)
|
|
35
|
+
throw new ZaloApiError.ZaloApiError('Failed to encrypt params');
|
|
36
|
+
const response = await utils.request(utils.makeURL(serviceURL, { params: encryptedParams }), {
|
|
37
|
+
method: 'GET',
|
|
38
|
+
});
|
|
39
|
+
return utils.resolve(response);
|
|
40
|
+
};
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
exports.getAvatarUrlProfileFactory = getAvatarUrlProfileFactory;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var ZaloApiError = require('../Errors/ZaloApiError.cjs');
|
|
4
|
+
var utils = require('../utils.cjs');
|
|
5
|
+
|
|
6
|
+
const getFullAvatarFactory = utils.apiFactory()((api, ctx, utils) => {
|
|
7
|
+
const serviceURL = utils.makeURL(`${api.zpwServiceMap.profile[0]}/api/social/profile/avatar`);
|
|
8
|
+
/**
|
|
9
|
+
* Get full avatar
|
|
10
|
+
*
|
|
11
|
+
* @param friendId friend id
|
|
12
|
+
*
|
|
13
|
+
* @throws {ZaloApiError}
|
|
14
|
+
*/
|
|
15
|
+
return async function getFullAvatar(friendId) {
|
|
16
|
+
const params = {
|
|
17
|
+
fid: friendId,
|
|
18
|
+
imei: ctx.imei,
|
|
19
|
+
};
|
|
20
|
+
const encryptedParams = utils.encodeAES(JSON.stringify(params));
|
|
21
|
+
if (!encryptedParams)
|
|
22
|
+
throw new ZaloApiError.ZaloApiError('Failed to encrypt params');
|
|
23
|
+
const response = await utils.request(utils.makeURL(serviceURL, { params: encryptedParams }), {
|
|
24
|
+
method: 'GET',
|
|
25
|
+
});
|
|
26
|
+
return utils.resolve(response);
|
|
27
|
+
};
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
exports.getFullAvatarFactory = getFullAvatarFactory;
|
package/dist/cjs/apis.cjs
CHANGED
|
@@ -81,6 +81,7 @@ var updateLabels = require('./apis/updateLabels.cjs');
|
|
|
81
81
|
var updateActiveStatus = require('./apis/updateActiveStatus.cjs');
|
|
82
82
|
var sendTypingEvent = require('./apis/sendTypingEvent.cjs');
|
|
83
83
|
var removeGroupBlockedMember = require('./apis/removeGroupBlockedMember.cjs');
|
|
84
|
+
var getFullAvatar = require('./apis/getFullAvatar.cjs');
|
|
84
85
|
var getAutoDeleteChat = require('./apis/getAutoDeleteChat.cjs');
|
|
85
86
|
var getAliasList = require('./apis/getAliasList.cjs');
|
|
86
87
|
var getLabels = require('./apis/getLabels.cjs');
|
|
@@ -122,6 +123,7 @@ var sendCard = require('./apis/sendCard.cjs');
|
|
|
122
123
|
var getRelatedFriendGroup = require('./apis/getRelatedFriendGroup.cjs');
|
|
123
124
|
var inviteUserToGroups = require('./apis/inviteUserToGroups.cjs');
|
|
124
125
|
var blockUser = require('./apis/blockUser.cjs');
|
|
126
|
+
var getAvatarUrlProfile = require('./apis/getAvatarUrlProfile.cjs');
|
|
125
127
|
var sendMessage = require('./apis/sendMessage.cjs');
|
|
126
128
|
var updateProfile = require('./apis/updateProfile.cjs');
|
|
127
129
|
var getHiddenConversations = require('./apis/getHiddenConversations.cjs');
|
|
@@ -228,6 +230,7 @@ class ZaloAPI {
|
|
|
228
230
|
this.updateActiveStatus = updateActiveStatus.updateActiveStatusFactory(ctx, this);
|
|
229
231
|
this.sendTypingEvent = sendTypingEvent.sendTypingEventFactory(ctx, this);
|
|
230
232
|
this.removeGroupBlockedMember = removeGroupBlockedMember.removeGroupBlockedMemberFactory(ctx, this);
|
|
233
|
+
this.getFullAvatar = getFullAvatar.getFullAvatarFactory(ctx, this);
|
|
231
234
|
this.getAutoDeleteChat = getAutoDeleteChat.getAutoDeleteChatFactory(ctx, this);
|
|
232
235
|
this.getAliasList = getAliasList.getAliasListFactory(ctx, this);
|
|
233
236
|
this.getLabels = getLabels.getLabelsFactory(ctx, this);
|
|
@@ -269,6 +272,7 @@ class ZaloAPI {
|
|
|
269
272
|
this.getRelatedFriendGroup = getRelatedFriendGroup.getRelatedFriendGroupFactory(ctx, this);
|
|
270
273
|
this.inviteUserToGroups = inviteUserToGroups.inviteUserToGroupsFactory(ctx, this);
|
|
271
274
|
this.blockUser = blockUser.blockUserFactory(ctx, this);
|
|
275
|
+
this.getAvatarUrlProfile = getAvatarUrlProfile.getAvatarUrlProfileFactory(ctx, this);
|
|
272
276
|
this.sendMessage = sendMessage.sendMessageFactory(ctx, this);
|
|
273
277
|
this.updateProfile = updateProfile.updateProfileFactory(ctx, this);
|
|
274
278
|
this.getHiddenConversations = getHiddenConversations.getHiddenConversationsFactory(ctx, this);
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -48,6 +48,10 @@ Object.defineProperty(exports, "BoardType", {
|
|
|
48
48
|
});
|
|
49
49
|
exports.GroupDeliveredMessage = DeliveredMessage.GroupDeliveredMessage;
|
|
50
50
|
exports.UserDeliveredMessage = DeliveredMessage.UserDeliveredMessage;
|
|
51
|
+
Object.defineProperty(exports, "AvatarSize", {
|
|
52
|
+
enumerable: true,
|
|
53
|
+
get: function () { return Enum.AvatarSize; }
|
|
54
|
+
});
|
|
51
55
|
Object.defineProperty(exports, "BinBankCard", {
|
|
52
56
|
enumerable: true,
|
|
53
57
|
get: function () { return Enum.BinBankCard; }
|
package/dist/cjs/models/Enum.cjs
CHANGED
|
@@ -16,6 +16,11 @@ exports.Gender = void 0;
|
|
|
16
16
|
Gender[Gender["Male"] = 0] = "Male";
|
|
17
17
|
Gender[Gender["Female"] = 1] = "Female";
|
|
18
18
|
})(exports.Gender || (exports.Gender = {}));
|
|
19
|
+
exports.AvatarSize = void 0;
|
|
20
|
+
(function (AvatarSize) {
|
|
21
|
+
AvatarSize[AvatarSize["Small"] = 120] = "Small";
|
|
22
|
+
AvatarSize[AvatarSize["Large"] = 240] = "Large";
|
|
23
|
+
})(exports.AvatarSize || (exports.AvatarSize = {}));
|
|
19
24
|
/**
|
|
20
25
|
* @note Bank codes list after Mitm on Mobile and Bank's supported by Zalo
|
|
21
26
|
* @documents https://developers.zalo.me/docs/zalo-notification-service/phu-luc/danh-sach-bin-code - docs missing bin code and short_name bank
|
package/dist/models/Enum.d.ts
CHANGED
|
@@ -11,6 +11,10 @@ export declare enum Gender {
|
|
|
11
11
|
Male = 0,
|
|
12
12
|
Female = 1
|
|
13
13
|
}
|
|
14
|
+
export declare enum AvatarSize {
|
|
15
|
+
Small = 120,
|
|
16
|
+
Large = 240
|
|
17
|
+
}
|
|
14
18
|
/**
|
|
15
19
|
* @note Bank codes list after Mitm on Mobile and Bank's supported by Zalo
|
|
16
20
|
* @documents https://developers.zalo.me/docs/zalo-notification-service/phu-luc/danh-sach-bin-code - docs missing bin code and short_name bank
|
package/dist/models/Enum.js
CHANGED
|
@@ -14,6 +14,11 @@ export var Gender;
|
|
|
14
14
|
Gender[Gender["Male"] = 0] = "Male";
|
|
15
15
|
Gender[Gender["Female"] = 1] = "Female";
|
|
16
16
|
})(Gender || (Gender = {}));
|
|
17
|
+
export var AvatarSize;
|
|
18
|
+
(function (AvatarSize) {
|
|
19
|
+
AvatarSize[AvatarSize["Small"] = 120] = "Small";
|
|
20
|
+
AvatarSize[AvatarSize["Large"] = 240] = "Large";
|
|
21
|
+
})(AvatarSize || (AvatarSize = {}));
|
|
17
22
|
/**
|
|
18
23
|
* @note Bank codes list after Mitm on Mobile and Bank's supported by Zalo
|
|
19
24
|
* @documents https://developers.zalo.me/docs/zalo-notification-service/phu-luc/danh-sach-bin-code - docs missing bin code and short_name bank
|