@warriorteam/redai-zalo-sdk 1.1.0
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/LICENSE +21 -0
- package/README.md +448 -0
- package/dist/clients/base-client.d.ts +67 -0
- package/dist/clients/base-client.d.ts.map +1 -0
- package/dist/clients/base-client.js +297 -0
- package/dist/clients/base-client.js.map +1 -0
- package/dist/clients/zalo-client.d.ts +131 -0
- package/dist/clients/zalo-client.d.ts.map +1 -0
- package/dist/clients/zalo-client.js +215 -0
- package/dist/clients/zalo-client.js.map +1 -0
- package/dist/index.d.ts +40 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +82 -0
- package/dist/index.js.map +1 -0
- package/dist/services/article.service.d.ts +144 -0
- package/dist/services/article.service.d.ts.map +1 -0
- package/dist/services/article.service.js +518 -0
- package/dist/services/article.service.js.map +1 -0
- package/dist/services/auth.service.d.ts +55 -0
- package/dist/services/auth.service.d.ts.map +1 -0
- package/dist/services/auth.service.js +269 -0
- package/dist/services/auth.service.js.map +1 -0
- package/dist/services/consultation.service.d.ts +73 -0
- package/dist/services/consultation.service.d.ts.map +1 -0
- package/dist/services/consultation.service.js +208 -0
- package/dist/services/consultation.service.js.map +1 -0
- package/dist/services/general-message.service.d.ts +85 -0
- package/dist/services/general-message.service.d.ts.map +1 -0
- package/dist/services/general-message.service.js +248 -0
- package/dist/services/general-message.service.js.map +1 -0
- package/dist/services/group-management.service.d.ts +220 -0
- package/dist/services/group-management.service.d.ts.map +1 -0
- package/dist/services/group-management.service.js +562 -0
- package/dist/services/group-management.service.js.map +1 -0
- package/dist/services/group-message.service.d.ts +102 -0
- package/dist/services/group-message.service.d.ts.map +1 -0
- package/dist/services/group-message.service.js +233 -0
- package/dist/services/group-message.service.js.map +1 -0
- package/dist/services/message-management.service.d.ts +135 -0
- package/dist/services/message-management.service.d.ts.map +1 -0
- package/dist/services/message-management.service.js +237 -0
- package/dist/services/message-management.service.js.map +1 -0
- package/dist/services/oa.service.d.ts +67 -0
- package/dist/services/oa.service.d.ts.map +1 -0
- package/dist/services/oa.service.js +223 -0
- package/dist/services/oa.service.js.map +1 -0
- package/dist/services/promotion.service.d.ts +114 -0
- package/dist/services/promotion.service.d.ts.map +1 -0
- package/dist/services/promotion.service.js +247 -0
- package/dist/services/promotion.service.js.map +1 -0
- package/dist/services/tag.service.d.ts +144 -0
- package/dist/services/tag.service.d.ts.map +1 -0
- package/dist/services/tag.service.js +184 -0
- package/dist/services/tag.service.js.map +1 -0
- package/dist/services/transaction.service.d.ts +110 -0
- package/dist/services/transaction.service.d.ts.map +1 -0
- package/dist/services/transaction.service.js +231 -0
- package/dist/services/transaction.service.js.map +1 -0
- package/dist/services/user-management.service.d.ts +117 -0
- package/dist/services/user-management.service.d.ts.map +1 -0
- package/dist/services/user-management.service.js +239 -0
- package/dist/services/user-management.service.js.map +1 -0
- package/dist/services/user.service.d.ts +84 -0
- package/dist/services/user.service.d.ts.map +1 -0
- package/dist/services/user.service.js +323 -0
- package/dist/services/user.service.js.map +1 -0
- package/dist/services/video-upload.service.d.ts +83 -0
- package/dist/services/video-upload.service.d.ts.map +1 -0
- package/dist/services/video-upload.service.js +267 -0
- package/dist/services/video-upload.service.js.map +1 -0
- package/dist/services/zns.service.d.ts +116 -0
- package/dist/services/zns.service.d.ts.map +1 -0
- package/dist/services/zns.service.js +234 -0
- package/dist/services/zns.service.js.map +1 -0
- package/dist/types/article.d.ts +352 -0
- package/dist/types/article.d.ts.map +1 -0
- package/dist/types/article.js +70 -0
- package/dist/types/article.js.map +1 -0
- package/dist/types/auth.d.ts +233 -0
- package/dist/types/auth.d.ts.map +1 -0
- package/dist/types/auth.js +39 -0
- package/dist/types/auth.js.map +1 -0
- package/dist/types/common.d.ts +237 -0
- package/dist/types/common.d.ts.map +1 -0
- package/dist/types/common.js +42 -0
- package/dist/types/common.js.map +1 -0
- package/dist/types/group.d.ts +523 -0
- package/dist/types/group.d.ts.map +1 -0
- package/dist/types/group.js +6 -0
- package/dist/types/group.js.map +1 -0
- package/dist/types/message.d.ts +333 -0
- package/dist/types/message.d.ts.map +1 -0
- package/dist/types/message.js +17 -0
- package/dist/types/message.js.map +1 -0
- package/dist/types/oa.d.ts +285 -0
- package/dist/types/oa.d.ts.map +1 -0
- package/dist/types/oa.js +25 -0
- package/dist/types/oa.js.map +1 -0
- package/dist/types/social.d.ts +427 -0
- package/dist/types/social.d.ts.map +1 -0
- package/dist/types/social.js +6 -0
- package/dist/types/social.js.map +1 -0
- package/dist/types/user-management.d.ts +280 -0
- package/dist/types/user-management.d.ts.map +1 -0
- package/dist/types/user-management.js +6 -0
- package/dist/types/user-management.js.map +1 -0
- package/dist/types/user.d.ts +365 -0
- package/dist/types/user.d.ts.map +1 -0
- package/dist/types/user.js +17 -0
- package/dist/types/user.js.map +1 -0
- package/dist/types/webhook.d.ts +1972 -0
- package/dist/types/webhook.d.ts.map +1 -0
- package/dist/types/webhook.js +419 -0
- package/dist/types/webhook.js.map +1 -0
- package/dist/types/zns.d.ts +277 -0
- package/dist/types/zns.d.ts.map +1 -0
- package/dist/types/zns.js +6 -0
- package/dist/types/zns.js.map +1 -0
- package/dist/zalo-sdk.d.ts +228 -0
- package/dist/zalo-sdk.d.ts.map +1 -0
- package/dist/zalo-sdk.js +307 -0
- package/dist/zalo-sdk.js.map +1 -0
- package/package.json +59 -0
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Authentication service for Zalo API
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.AuthService = void 0;
|
|
7
|
+
const auth_1 = require("../types/auth");
|
|
8
|
+
const common_1 = require("../types/common");
|
|
9
|
+
const crypto_1 = require("crypto");
|
|
10
|
+
/**
|
|
11
|
+
* Authentication service for handling OAuth flows and token management
|
|
12
|
+
*/
|
|
13
|
+
class AuthService {
|
|
14
|
+
constructor(client, appId, appSecret) {
|
|
15
|
+
this.client = client;
|
|
16
|
+
this.appId = appId;
|
|
17
|
+
this.appSecret = appSecret;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Generate PKCE code verifier and challenge for Social API
|
|
21
|
+
*/
|
|
22
|
+
generatePKCE() {
|
|
23
|
+
const codeVerifier = (0, crypto_1.randomBytes)(32).toString("base64url");
|
|
24
|
+
const codeChallenge = (0, crypto_1.createHash)("sha256")
|
|
25
|
+
.update(codeVerifier)
|
|
26
|
+
.digest("base64url");
|
|
27
|
+
return {
|
|
28
|
+
code_verifier: codeVerifier,
|
|
29
|
+
code_challenge: codeChallenge,
|
|
30
|
+
code_challenge_method: "S256",
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Create OAuth authorization URL for Official Account
|
|
35
|
+
*/
|
|
36
|
+
createOAAuthUrl(redirectUri, state) {
|
|
37
|
+
const params = new URLSearchParams({
|
|
38
|
+
app_id: this.appId,
|
|
39
|
+
redirect_uri: redirectUri,
|
|
40
|
+
state: state || "oa_auth",
|
|
41
|
+
});
|
|
42
|
+
return `https://oauth.zaloapp.com/v4/oa/permission?${params.toString()}`;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Create OAuth authorization URL for Social API
|
|
46
|
+
*/
|
|
47
|
+
createSocialAuthUrl(redirectUri, state, pkce) {
|
|
48
|
+
const params = new URLSearchParams({
|
|
49
|
+
app_id: this.appId,
|
|
50
|
+
redirect_uri: redirectUri,
|
|
51
|
+
state: state || "social_auth",
|
|
52
|
+
});
|
|
53
|
+
if (pkce) {
|
|
54
|
+
params.append("code_challenge", pkce.code_challenge);
|
|
55
|
+
params.append("code_challenge_method", pkce.code_challenge_method);
|
|
56
|
+
}
|
|
57
|
+
return `https://oauth.zaloapp.com/v4/permission?${params.toString()}`;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Exchange authorization code for Official Account access token
|
|
61
|
+
*/
|
|
62
|
+
async getOAAccessToken(params) {
|
|
63
|
+
try {
|
|
64
|
+
const url = "https://openapi.zalo.me/v2.0/oa/oauth/access_token";
|
|
65
|
+
const requestParams = {
|
|
66
|
+
app_id: params.app_id,
|
|
67
|
+
app_secret: params.app_secret,
|
|
68
|
+
code: params.code,
|
|
69
|
+
grant_type: "authorization_code",
|
|
70
|
+
redirect_uri: params.redirect_uri,
|
|
71
|
+
};
|
|
72
|
+
await this.client.oauthRequestWithUrl("POST", url, null, {
|
|
73
|
+
"Content-Type": "application/x-www-form-urlencoded",
|
|
74
|
+
});
|
|
75
|
+
// Convert to URLSearchParams for form data
|
|
76
|
+
const formData = new URLSearchParams();
|
|
77
|
+
Object.entries(requestParams).forEach(([key, value]) => {
|
|
78
|
+
formData.append(key, value);
|
|
79
|
+
});
|
|
80
|
+
const result = await this.client.oauthRequestWithUrl("POST", url, formData.toString(), {
|
|
81
|
+
"Content-Type": "application/x-www-form-urlencoded",
|
|
82
|
+
});
|
|
83
|
+
if (result.error !== 0) {
|
|
84
|
+
throw new common_1.ZaloSDKError(result.error_description ||
|
|
85
|
+
result.message ||
|
|
86
|
+
"Failed to get OA access token", result.error, result);
|
|
87
|
+
}
|
|
88
|
+
if (!result.data) {
|
|
89
|
+
throw new common_1.ZaloSDKError("No data received from Zalo API", -1);
|
|
90
|
+
}
|
|
91
|
+
return result.data;
|
|
92
|
+
}
|
|
93
|
+
catch (error) {
|
|
94
|
+
if (error instanceof common_1.ZaloSDKError) {
|
|
95
|
+
throw error;
|
|
96
|
+
}
|
|
97
|
+
throw new common_1.ZaloSDKError(`Failed to get OA access token: ${error.message}`, -1, error);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Exchange authorization code for Social API access token
|
|
102
|
+
*/
|
|
103
|
+
async getSocialAccessToken(params) {
|
|
104
|
+
try {
|
|
105
|
+
const url = "https://oauth.zaloapp.com/v4/access_token";
|
|
106
|
+
const formData = new URLSearchParams();
|
|
107
|
+
formData.append("code", params.code);
|
|
108
|
+
formData.append("app_id", params.app_id);
|
|
109
|
+
formData.append("grant_type", "authorization_code");
|
|
110
|
+
if (params.code_verifier) {
|
|
111
|
+
formData.append("code_verifier", params.code_verifier);
|
|
112
|
+
}
|
|
113
|
+
const result = await this.client.oauthRequestWithUrl("POST", url, formData.toString(), {
|
|
114
|
+
"Content-Type": "application/x-www-form-urlencoded",
|
|
115
|
+
secret_key: params.app_secret,
|
|
116
|
+
});
|
|
117
|
+
// Handle different response formats
|
|
118
|
+
if (result.error && result.error !== 0) {
|
|
119
|
+
throw new common_1.ZaloSDKError(result.error_description ||
|
|
120
|
+
result.message ||
|
|
121
|
+
"Failed to get Social access token", result.error, result);
|
|
122
|
+
}
|
|
123
|
+
// Response might be direct or wrapped in data
|
|
124
|
+
if (result.data) {
|
|
125
|
+
return result.data;
|
|
126
|
+
}
|
|
127
|
+
else if (result.access_token) {
|
|
128
|
+
return {
|
|
129
|
+
access_token: result.access_token,
|
|
130
|
+
expires_in: result.expires_in,
|
|
131
|
+
refresh_token: result.refresh_token,
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
else {
|
|
135
|
+
throw new common_1.ZaloSDKError("No access token received from Zalo API", -1);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
catch (error) {
|
|
139
|
+
if (error instanceof common_1.ZaloSDKError) {
|
|
140
|
+
throw error;
|
|
141
|
+
}
|
|
142
|
+
throw new common_1.ZaloSDKError(`Failed to get Social access token: ${error.message}`, -1, error);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Refresh Official Account access token
|
|
147
|
+
*/
|
|
148
|
+
async refreshOAAccessToken(params) {
|
|
149
|
+
try {
|
|
150
|
+
const url = "https://oauth.zaloapp.com/v4/oa/access_token";
|
|
151
|
+
const formData = new URLSearchParams();
|
|
152
|
+
formData.append("refresh_token", params.refresh_token);
|
|
153
|
+
formData.append("app_id", params.app_id);
|
|
154
|
+
formData.append("grant_type", "refresh_token");
|
|
155
|
+
const result = await this.client.oauthRequestWithUrl("POST", url, formData.toString(), {
|
|
156
|
+
"Content-Type": "application/x-www-form-urlencoded",
|
|
157
|
+
secret_key: params.app_secret,
|
|
158
|
+
});
|
|
159
|
+
if (!result.access_token) {
|
|
160
|
+
throw new common_1.ZaloSDKError("No access token received when refreshing OA token", -1);
|
|
161
|
+
}
|
|
162
|
+
return {
|
|
163
|
+
access_token: result.access_token,
|
|
164
|
+
refresh_token: result.refresh_token,
|
|
165
|
+
expires_in: parseInt(result.expires_in),
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
catch (error) {
|
|
169
|
+
if (error instanceof common_1.ZaloSDKError) {
|
|
170
|
+
throw error;
|
|
171
|
+
}
|
|
172
|
+
throw new common_1.ZaloSDKError(`Failed to refresh OA access token: ${error.message}`, -1, error);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Refresh Social API access token
|
|
177
|
+
*/
|
|
178
|
+
async refreshSocialAccessToken(params) {
|
|
179
|
+
try {
|
|
180
|
+
const endpoint = this.client.endpoints.auth.refreshSocialToken;
|
|
181
|
+
const requestParams = {
|
|
182
|
+
app_id: params.app_id,
|
|
183
|
+
grant_type: "refresh_token",
|
|
184
|
+
refresh_token: params.refresh_token,
|
|
185
|
+
};
|
|
186
|
+
const result = await this.client.apiGet(endpoint, "", requestParams);
|
|
187
|
+
if (result.error !== 0) {
|
|
188
|
+
throw new common_1.ZaloSDKError(result.error_description ||
|
|
189
|
+
result.message ||
|
|
190
|
+
"Failed to refresh Social access token", result.error, result);
|
|
191
|
+
}
|
|
192
|
+
if (!result.data) {
|
|
193
|
+
throw new common_1.ZaloSDKError("No data received when refreshing Social token", -1);
|
|
194
|
+
}
|
|
195
|
+
return result.data;
|
|
196
|
+
}
|
|
197
|
+
catch (error) {
|
|
198
|
+
if (error instanceof common_1.ZaloSDKError) {
|
|
199
|
+
throw error;
|
|
200
|
+
}
|
|
201
|
+
throw new common_1.ZaloSDKError(`Failed to refresh Social access token: ${error.message}`, -1, error);
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* Get Social user information
|
|
206
|
+
*/
|
|
207
|
+
async getSocialUserInfo(accessToken, fields = "id,name,picture") {
|
|
208
|
+
try {
|
|
209
|
+
const url = "https://graph.zalo.me/v2.0/me";
|
|
210
|
+
const params = { fields };
|
|
211
|
+
const result = await this.client.oauthRequestWithUrl("GET", url, params, {
|
|
212
|
+
access_token: accessToken,
|
|
213
|
+
});
|
|
214
|
+
if (result.error !== 0) {
|
|
215
|
+
throw new common_1.ZaloSDKError(result.message || "Failed to get Social user info", result.error, result);
|
|
216
|
+
}
|
|
217
|
+
if (!result.id) {
|
|
218
|
+
throw new common_1.ZaloSDKError("No user data received from Social API", -1);
|
|
219
|
+
}
|
|
220
|
+
return {
|
|
221
|
+
id: result.id,
|
|
222
|
+
name: result.name,
|
|
223
|
+
picture: result.picture,
|
|
224
|
+
is_sensitive: result.is_sensitive,
|
|
225
|
+
};
|
|
226
|
+
}
|
|
227
|
+
catch (error) {
|
|
228
|
+
if (error instanceof common_1.ZaloSDKError) {
|
|
229
|
+
throw error;
|
|
230
|
+
}
|
|
231
|
+
throw new common_1.ZaloSDKError(`Failed to get Social user info: ${error.message}`, -1, error);
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* Validate access token by attempting to get user info
|
|
236
|
+
*/
|
|
237
|
+
async validateAccessToken(accessToken, scope = auth_1.AuthScope.SOCIAL) {
|
|
238
|
+
try {
|
|
239
|
+
if (scope === auth_1.AuthScope.SOCIAL) {
|
|
240
|
+
const userInfo = await this.getSocialUserInfo(accessToken, "id");
|
|
241
|
+
return {
|
|
242
|
+
valid: true,
|
|
243
|
+
user_info: userInfo,
|
|
244
|
+
};
|
|
245
|
+
}
|
|
246
|
+
else {
|
|
247
|
+
// For OA tokens, we could try to get OA info
|
|
248
|
+
// This is a simplified validation
|
|
249
|
+
return { valid: true };
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
catch (error) {
|
|
253
|
+
return { valid: false };
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
/**
|
|
257
|
+
* Get all authentication URLs
|
|
258
|
+
*/
|
|
259
|
+
getAuthUrls(redirectUri) {
|
|
260
|
+
return {
|
|
261
|
+
oa_auth_url: this.createOAAuthUrl(redirectUri),
|
|
262
|
+
social_auth_url: this.createSocialAuthUrl(redirectUri),
|
|
263
|
+
token_url: "https://oauth.zaloapp.com/v4/access_token",
|
|
264
|
+
refresh_url: "https://oauth.zaloapp.com/v4/oa/access_token",
|
|
265
|
+
};
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
exports.AuthService = AuthService;
|
|
269
|
+
//# sourceMappingURL=auth.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.service.js","sourceRoot":"","sources":["../../src/services/auth.service.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAGH,wCAUuB;AACvB,4CAA+C;AAC/C,mCAAiD;AAEjD;;GAEG;AACH,MAAa,WAAW;IACtB,YACmB,MAAkB,EAClB,KAAa,EACb,SAAiB;QAFjB,WAAM,GAAN,MAAM,CAAY;QAClB,UAAK,GAAL,KAAK,CAAQ;QACb,cAAS,GAAT,SAAS,CAAQ;IACjC,CAAC;IAEJ;;OAEG;IACI,YAAY;QACjB,MAAM,YAAY,GAAG,IAAA,oBAAW,EAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;QAC3D,MAAM,aAAa,GAAG,IAAA,mBAAU,EAAC,QAAQ,CAAC;aACvC,MAAM,CAAC,YAAY,CAAC;aACpB,MAAM,CAAC,WAAW,CAAC,CAAC;QAEvB,OAAO;YACL,aAAa,EAAE,YAAY;YAC3B,cAAc,EAAE,aAAa;YAC7B,qBAAqB,EAAE,MAAM;SAC9B,CAAC;IACJ,CAAC;IAED;;OAEG;IACI,eAAe,CAAC,WAA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AAE,IAAI,EAAE,CAAC;YACzB,CAAC;QACH,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;QAC1B,CAAC;IACH,CAAC;IAED;;OAEG;IACI,WAAW,CAAC,WAAmB;QACpC,OAAO;YACL,WAAW,EAAE,IAAI,CAAC,eAAe,CAAC,WAAW,CAAC;YAC9C,eAAe,EAAE,IAAI,CAAC,mBAAmB,CAAC,WAAW,CAAC;YACtD,SAAS,EAAE,2CAA2C;YACtD,WAAW,EAAE,8CAA8C;SAC5D,CAAC;IACJ,CAAC;CACF;AAnWD,kCAmWC"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { ZaloClient } from "../clients/zalo-client";
|
|
2
|
+
import { Message, SendMessageResponse, TextMessage, ImageMessage, FileMessage, StickerMessage, MessageRecipient } from "../types/message";
|
|
3
|
+
/**
|
|
4
|
+
* Service xử lý các API tin nhắn tư vấn của Zalo Official Account
|
|
5
|
+
*
|
|
6
|
+
* Tin nhắn tư vấn (CS - Customer Service) là loại tin nhắn đặc biệt
|
|
7
|
+
* cho phép OA gửi tin nhắn chủ động đến người dùng trong khung thời gian nhất định
|
|
8
|
+
*
|
|
9
|
+
* ĐIỀU KIỆN GỬI TIN TƯ VẤN:
|
|
10
|
+
*
|
|
11
|
+
* 1. THỜI GIAN GỬI:
|
|
12
|
+
* - Chỉ được gửi trong vòng 48 giờ kể từ khi người dùng tương tác cuối cùng với OA
|
|
13
|
+
* - Tương tác bao gồm: gửi tin nhắn, nhấn button, gọi điện, truy cập website từ OA
|
|
14
|
+
*
|
|
15
|
+
* 2. NỘI DUNG TIN NHẮN:
|
|
16
|
+
* - Phải liên quan đến tư vấn, hỗ trợ khách hàng
|
|
17
|
+
* - Bao gồm: trả lời câu hỏi, hướng dẫn sử dụng, hỗ trợ kỹ thuật
|
|
18
|
+
* - Không được chứa nội dung quảng cáo trực tiếp
|
|
19
|
+
*
|
|
20
|
+
* 3. TẦN SUẤT GỬI:
|
|
21
|
+
* - Không giới hạn số lượng tin nhắn tư vấn trong ngày
|
|
22
|
+
* - Tuy nhiên cần tuân thủ nguyên tắc không spam
|
|
23
|
+
*
|
|
24
|
+
* 4. NGƯỜI DÙNG:
|
|
25
|
+
* - Người dùng phải đã follow OA
|
|
26
|
+
* - Người dùng không được block OA
|
|
27
|
+
* - Người dùng phải có tương tác gần đây với OA
|
|
28
|
+
*/
|
|
29
|
+
export declare class ConsultationService {
|
|
30
|
+
private readonly client;
|
|
31
|
+
constructor(client: ZaloClient);
|
|
32
|
+
/**
|
|
33
|
+
* Gửi tin nhắn tư vấn văn bản
|
|
34
|
+
* @param accessToken Access token của Official Account
|
|
35
|
+
* @param recipient Thông tin người nhận
|
|
36
|
+
* @param message Nội dung tin nhắn văn bản
|
|
37
|
+
* @returns Thông tin tin nhắn đã gửi
|
|
38
|
+
*/
|
|
39
|
+
sendTextMessage(accessToken: string, recipient: MessageRecipient, message: TextMessage): Promise<SendMessageResponse>;
|
|
40
|
+
/**
|
|
41
|
+
* Gửi tin nhắn tư vấn hình ảnh
|
|
42
|
+
* @param accessToken Access token của Official Account
|
|
43
|
+
* @param recipient Thông tin người nhận
|
|
44
|
+
* @param message Nội dung tin nhắn hình ảnh
|
|
45
|
+
* @returns Thông tin tin nhắn đã gửi
|
|
46
|
+
*/
|
|
47
|
+
sendImageMessage(accessToken: string, recipient: MessageRecipient, message: ImageMessage): Promise<SendMessageResponse>;
|
|
48
|
+
/**
|
|
49
|
+
* Gửi tin nhắn tư vấn file đính kèm
|
|
50
|
+
* @param accessToken Access token của Official Account
|
|
51
|
+
* @param recipient Thông tin người nhận
|
|
52
|
+
* @param message Nội dung tin nhắn file
|
|
53
|
+
* @returns Thông tin tin nhắn đã gửi
|
|
54
|
+
*/
|
|
55
|
+
sendFileMessage(accessToken: string, recipient: MessageRecipient, message: FileMessage): Promise<SendMessageResponse>;
|
|
56
|
+
/**
|
|
57
|
+
* Gửi tin nhắn tư vấn sticker
|
|
58
|
+
* @param accessToken Access token của Official Account
|
|
59
|
+
* @param recipient Thông tin người nhận
|
|
60
|
+
* @param message Nội dung tin nhắn sticker
|
|
61
|
+
* @returns Thông tin tin nhắn đã gửi
|
|
62
|
+
*/
|
|
63
|
+
sendStickerMessage(accessToken: string, recipient: MessageRecipient, message: StickerMessage): Promise<SendMessageResponse>;
|
|
64
|
+
/**
|
|
65
|
+
* Gửi tin nhắn tư vấn tổng quát
|
|
66
|
+
* @param accessToken Access token của Official Account
|
|
67
|
+
* @param recipient Thông tin người nhận
|
|
68
|
+
* @param message Nội dung tin nhắn
|
|
69
|
+
* @returns Thông tin tin nhắn đã gửi
|
|
70
|
+
*/
|
|
71
|
+
sendMessage(accessToken: string, recipient: MessageRecipient, message: Message): Promise<SendMessageResponse>;
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=consultation.service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"consultation.service.d.ts","sourceRoot":"","sources":["../../src/services/consultation.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EACL,OAAO,EAEP,mBAAmB,EACnB,WAAW,EACX,YAAY,EACZ,WAAW,EACX,cAAc,EACd,gBAAgB,EACjB,MAAM,kBAAkB,CAAC;AAG1B;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,qBAAa,mBAAmB;IAClB,OAAO,CAAC,QAAQ,CAAC,MAAM;gBAAN,MAAM,EAAE,UAAU;IAE/C;;;;;;OAMG;IACU,eAAe,CAC1B,WAAW,EAAE,MAAM,EACnB,SAAS,EAAE,gBAAgB,EAC3B,OAAO,EAAE,WAAW,GACnB,OAAO,CAAC,mBAAmB,CAAC;IA8C/B;;;;;;OAMG;IACU,gBAAgB,CAC3B,WAAW,EAAE,MAAM,EACnB,SAAS,EAAE,gBAAgB,EAC3B,OAAO,EAAE,YAAY,GACpB,OAAO,CAAC,mBAAmB,CAAC;IAyC/B;;;;;;OAMG;IACU,eAAe,CAC1B,WAAW,EAAE,MAAM,EACnB,SAAS,EAAE,gBAAgB,EAC3B,OAAO,EAAE,WAAW,GACnB,OAAO,CAAC,mBAAmB,CAAC;IAyC/B;;;;;;OAMG;IACU,kBAAkB,CAC7B,WAAW,EAAE,MAAM,EACnB,SAAS,EAAE,gBAAgB,EAC3B,OAAO,EAAE,cAAc,GACtB,OAAO,CAAC,mBAAmB,CAAC;IAyC/B;;;;;;OAMG;IACU,WAAW,CACtB,WAAW,EAAE,MAAM,EACnB,SAAS,EAAE,gBAAgB,EAC3B,OAAO,EAAE,OAAO,GACf,OAAO,CAAC,mBAAmB,CAAC;CAoChC"}
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ConsultationService = void 0;
|
|
4
|
+
const common_1 = require("../types/common");
|
|
5
|
+
/**
|
|
6
|
+
* Service xử lý các API tin nhắn tư vấn của Zalo Official Account
|
|
7
|
+
*
|
|
8
|
+
* Tin nhắn tư vấn (CS - Customer Service) là loại tin nhắn đặc biệt
|
|
9
|
+
* cho phép OA gửi tin nhắn chủ động đến người dùng trong khung thời gian nhất định
|
|
10
|
+
*
|
|
11
|
+
* ĐIỀU KIỆN GỬI TIN TƯ VẤN:
|
|
12
|
+
*
|
|
13
|
+
* 1. THỜI GIAN GỬI:
|
|
14
|
+
* - Chỉ được gửi trong vòng 48 giờ kể từ khi người dùng tương tác cuối cùng với OA
|
|
15
|
+
* - Tương tác bao gồm: gửi tin nhắn, nhấn button, gọi điện, truy cập website từ OA
|
|
16
|
+
*
|
|
17
|
+
* 2. NỘI DUNG TIN NHẮN:
|
|
18
|
+
* - Phải liên quan đến tư vấn, hỗ trợ khách hàng
|
|
19
|
+
* - Bao gồm: trả lời câu hỏi, hướng dẫn sử dụng, hỗ trợ kỹ thuật
|
|
20
|
+
* - Không được chứa nội dung quảng cáo trực tiếp
|
|
21
|
+
*
|
|
22
|
+
* 3. TẦN SUẤT GỬI:
|
|
23
|
+
* - Không giới hạn số lượng tin nhắn tư vấn trong ngày
|
|
24
|
+
* - Tuy nhiên cần tuân thủ nguyên tắc không spam
|
|
25
|
+
*
|
|
26
|
+
* 4. NGƯỜI DÙNG:
|
|
27
|
+
* - Người dùng phải đã follow OA
|
|
28
|
+
* - Người dùng không được block OA
|
|
29
|
+
* - Người dùng phải có tương tác gần đây với OA
|
|
30
|
+
*/
|
|
31
|
+
class ConsultationService {
|
|
32
|
+
constructor(client) {
|
|
33
|
+
this.client = client;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Gửi tin nhắn tư vấn văn bản
|
|
37
|
+
* @param accessToken Access token của Official Account
|
|
38
|
+
* @param recipient Thông tin người nhận
|
|
39
|
+
* @param message Nội dung tin nhắn văn bản
|
|
40
|
+
* @returns Thông tin tin nhắn đã gửi
|
|
41
|
+
*/
|
|
42
|
+
async sendTextMessage(accessToken, recipient, message) {
|
|
43
|
+
try {
|
|
44
|
+
// Validate text length theo quy định của Zalo
|
|
45
|
+
if (!message.text || message.text.trim().length === 0) {
|
|
46
|
+
throw new common_1.ZaloSDKError("Nội dung tin nhắn không được để trống", -1);
|
|
47
|
+
}
|
|
48
|
+
if (message.text.length > 2000) {
|
|
49
|
+
throw new common_1.ZaloSDKError("Nội dung tin nhắn không được vượt quá 2000 ký tự", -1);
|
|
50
|
+
}
|
|
51
|
+
const endpoint = this.client.endpoints.message.send;
|
|
52
|
+
const request = {
|
|
53
|
+
recipient,
|
|
54
|
+
message,
|
|
55
|
+
messaging_type: "consultation",
|
|
56
|
+
};
|
|
57
|
+
const result = await this.client.apiPost(endpoint, accessToken, request);
|
|
58
|
+
if (result.error !== 0) {
|
|
59
|
+
throw new common_1.ZaloSDKError(result.message || "Failed to send consultation text message", result.error, result);
|
|
60
|
+
}
|
|
61
|
+
if (!result.data) {
|
|
62
|
+
throw new common_1.ZaloSDKError("No response data received", -1);
|
|
63
|
+
}
|
|
64
|
+
return result.data;
|
|
65
|
+
}
|
|
66
|
+
catch (error) {
|
|
67
|
+
if (error instanceof common_1.ZaloSDKError) {
|
|
68
|
+
throw error;
|
|
69
|
+
}
|
|
70
|
+
throw new common_1.ZaloSDKError(`Failed to send consultation text message: ${error.message}`, -1, error);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Gửi tin nhắn tư vấn hình ảnh
|
|
75
|
+
* @param accessToken Access token của Official Account
|
|
76
|
+
* @param recipient Thông tin người nhận
|
|
77
|
+
* @param message Nội dung tin nhắn hình ảnh
|
|
78
|
+
* @returns Thông tin tin nhắn đã gửi
|
|
79
|
+
*/
|
|
80
|
+
async sendImageMessage(accessToken, recipient, message) {
|
|
81
|
+
try {
|
|
82
|
+
if (!message.attachment?.payload?.url) {
|
|
83
|
+
throw new common_1.ZaloSDKError("URL hình ảnh không được để trống", -1);
|
|
84
|
+
}
|
|
85
|
+
const endpoint = this.client.endpoints.message.send;
|
|
86
|
+
const request = {
|
|
87
|
+
recipient,
|
|
88
|
+
message,
|
|
89
|
+
messaging_type: "consultation",
|
|
90
|
+
};
|
|
91
|
+
const result = await this.client.apiPost(endpoint, accessToken, request);
|
|
92
|
+
if (result.error !== 0) {
|
|
93
|
+
throw new common_1.ZaloSDKError(result.message || "Failed to send consultation image message", result.error, result);
|
|
94
|
+
}
|
|
95
|
+
if (!result.data) {
|
|
96
|
+
throw new common_1.ZaloSDKError("No response data received", -1);
|
|
97
|
+
}
|
|
98
|
+
return result.data;
|
|
99
|
+
}
|
|
100
|
+
catch (error) {
|
|
101
|
+
if (error instanceof common_1.ZaloSDKError) {
|
|
102
|
+
throw error;
|
|
103
|
+
}
|
|
104
|
+
throw new common_1.ZaloSDKError(`Failed to send consultation image message: ${error.message}`, -1, error);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Gửi tin nhắn tư vấn file đính kèm
|
|
109
|
+
* @param accessToken Access token của Official Account
|
|
110
|
+
* @param recipient Thông tin người nhận
|
|
111
|
+
* @param message Nội dung tin nhắn file
|
|
112
|
+
* @returns Thông tin tin nhắn đã gửi
|
|
113
|
+
*/
|
|
114
|
+
async sendFileMessage(accessToken, recipient, message) {
|
|
115
|
+
try {
|
|
116
|
+
if (!message.attachment?.payload?.url) {
|
|
117
|
+
throw new common_1.ZaloSDKError("URL file không được để trống", -1);
|
|
118
|
+
}
|
|
119
|
+
const endpoint = this.client.endpoints.message.send;
|
|
120
|
+
const request = {
|
|
121
|
+
recipient,
|
|
122
|
+
message,
|
|
123
|
+
messaging_type: "consultation",
|
|
124
|
+
};
|
|
125
|
+
const result = await this.client.apiPost(endpoint, accessToken, request);
|
|
126
|
+
if (result.error !== 0) {
|
|
127
|
+
throw new common_1.ZaloSDKError(result.message || "Failed to send consultation file message", result.error, result);
|
|
128
|
+
}
|
|
129
|
+
if (!result.data) {
|
|
130
|
+
throw new common_1.ZaloSDKError("No response data received", -1);
|
|
131
|
+
}
|
|
132
|
+
return result.data;
|
|
133
|
+
}
|
|
134
|
+
catch (error) {
|
|
135
|
+
if (error instanceof common_1.ZaloSDKError) {
|
|
136
|
+
throw error;
|
|
137
|
+
}
|
|
138
|
+
throw new common_1.ZaloSDKError(`Failed to send consultation file message: ${error.message}`, -1, error);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Gửi tin nhắn tư vấn sticker
|
|
143
|
+
* @param accessToken Access token của Official Account
|
|
144
|
+
* @param recipient Thông tin người nhận
|
|
145
|
+
* @param message Nội dung tin nhắn sticker
|
|
146
|
+
* @returns Thông tin tin nhắn đã gửi
|
|
147
|
+
*/
|
|
148
|
+
async sendStickerMessage(accessToken, recipient, message) {
|
|
149
|
+
try {
|
|
150
|
+
if (!message.attachment?.payload?.id) {
|
|
151
|
+
throw new common_1.ZaloSDKError("ID sticker không được để trống", -1);
|
|
152
|
+
}
|
|
153
|
+
const endpoint = this.client.endpoints.message.send;
|
|
154
|
+
const request = {
|
|
155
|
+
recipient,
|
|
156
|
+
message,
|
|
157
|
+
messaging_type: "consultation",
|
|
158
|
+
};
|
|
159
|
+
const result = await this.client.apiPost(endpoint, accessToken, request);
|
|
160
|
+
if (result.error !== 0) {
|
|
161
|
+
throw new common_1.ZaloSDKError(result.message || "Failed to send consultation sticker message", result.error, result);
|
|
162
|
+
}
|
|
163
|
+
if (!result.data) {
|
|
164
|
+
throw new common_1.ZaloSDKError("No response data received", -1);
|
|
165
|
+
}
|
|
166
|
+
return result.data;
|
|
167
|
+
}
|
|
168
|
+
catch (error) {
|
|
169
|
+
if (error instanceof common_1.ZaloSDKError) {
|
|
170
|
+
throw error;
|
|
171
|
+
}
|
|
172
|
+
throw new common_1.ZaloSDKError(`Failed to send consultation sticker message: ${error.message}`, -1, error);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Gửi tin nhắn tư vấn tổng quát
|
|
177
|
+
* @param accessToken Access token của Official Account
|
|
178
|
+
* @param recipient Thông tin người nhận
|
|
179
|
+
* @param message Nội dung tin nhắn
|
|
180
|
+
* @returns Thông tin tin nhắn đã gửi
|
|
181
|
+
*/
|
|
182
|
+
async sendMessage(accessToken, recipient, message) {
|
|
183
|
+
try {
|
|
184
|
+
const endpoint = this.client.endpoints.message.send;
|
|
185
|
+
const request = {
|
|
186
|
+
recipient,
|
|
187
|
+
message,
|
|
188
|
+
messaging_type: "consultation",
|
|
189
|
+
};
|
|
190
|
+
const result = await this.client.apiPost(endpoint, accessToken, request);
|
|
191
|
+
if (result.error !== 0) {
|
|
192
|
+
throw new common_1.ZaloSDKError(result.message || "Failed to send consultation message", result.error, result);
|
|
193
|
+
}
|
|
194
|
+
if (!result.data) {
|
|
195
|
+
throw new common_1.ZaloSDKError("No response data received", -1);
|
|
196
|
+
}
|
|
197
|
+
return result.data;
|
|
198
|
+
}
|
|
199
|
+
catch (error) {
|
|
200
|
+
if (error instanceof common_1.ZaloSDKError) {
|
|
201
|
+
throw error;
|
|
202
|
+
}
|
|
203
|
+
throw new common_1.ZaloSDKError(`Failed to send consultation message: ${error.message}`, -1, error);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
exports.ConsultationService = ConsultationService;
|
|
208
|
+
//# sourceMappingURL=consultation.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"consultation.service.js","sourceRoot":"","sources":["../../src/services/consultation.service.ts"],"names":[],"mappings":";;;AAWA,4CAA6D;AAE7D;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAa,mBAAmB;IAC9B,YAA6B,MAAkB;QAAlB,WAAM,GAAN,MAAM,CAAY;IAAG,CAAC;IAEnD;;;;;;OAMG;IACI,KAAK,CAAC,eAAe,CAC1B,WAAmB,EACnB,SAA2B,EAC3B,OAAoB;QAEpB,IAAI,CAAC;YACH,8CAA8C;YAC9C,IAAI,CAAC,OAAO,CAAC,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;gBACtD,MAAM,IAAI,qBAAY,CAAC,uCAAuC,EAAE,CAAC,CAAC,CAAC,CAAC;YACtE,CAAC;YAED,IAAI,OAAO,CAAC,IAAI,CAAC,MAAM,GAAG,IAAI,EAAE,CAAC;gBAC/B,MAAM,IAAI,qBAAY,CAAC,kDAAkD,EAAE,CAAC,CAAC,CAAC,CAAC;YACjF,CAAC;YAED,MAAM,QAAQ,GAAG,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC;YACpD,MAAM,OAAO,GAAuB;gBAClC,SAAS;gBACT,OAAO;gBACP,cAAc,EAAE,cAAc;aAC/B,CAAC;YAEF,MAAM,MAAM,GACV,MAAM,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,QAAQ,EAAE,WAAW,EAAE,OAAO,CAAC,CAAC;YA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ACJ,CAAC;IACH,CAAC;CACF;AAvQD,kDAuQC"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { ZaloClient } from "../clients/zalo-client";
|
|
2
|
+
import { Message, SendMessageResponse, UploadFileResponse, TextMessage, ImageMessage, MessageRecipient, AnonymousTextMessage } from "../types/message";
|
|
3
|
+
/**
|
|
4
|
+
* Service xử lý các API tin nhắn tổng quát của Zalo Official Account
|
|
5
|
+
*
|
|
6
|
+
* Bao gồm các loại tin nhắn:
|
|
7
|
+
* - Tin nhắn phản hồi (Response Message)
|
|
8
|
+
* - Tin nhắn ẩn danh (Anonymous Message)
|
|
9
|
+
* - Tin nhắn tự động (Auto Message)
|
|
10
|
+
* - Tin nhắn hệ thống (System Message)
|
|
11
|
+
*
|
|
12
|
+
* ĐIỀU KIỆN GỬI TIN NHẮN TỔNG QUÁT:
|
|
13
|
+
*
|
|
14
|
+
* 1. TIN NHẮN PHẢN HỒI:
|
|
15
|
+
* - Chỉ được gửi trong vòng 24 giờ kể từ khi người dùng gửi tin nhắn đến OA
|
|
16
|
+
* - Không giới hạn số lượng tin nhắn phản hồi
|
|
17
|
+
* - Có thể chứa bất kỳ nội dung nào (tư vấn, quảng cáo, thông tin)
|
|
18
|
+
*
|
|
19
|
+
* 2. TIN NHẮN ẨN DANH:
|
|
20
|
+
* - Gửi tin nhắn mà không hiển thị thông tin OA
|
|
21
|
+
* - Chỉ dành cho các trường hợp đặc biệt
|
|
22
|
+
* - Cần được Zalo phê duyệt trước khi sử dụng
|
|
23
|
+
*
|
|
24
|
+
* 3. TIN NHẮN TỰ ĐỘNG:
|
|
25
|
+
* - Tin nhắn được gửi tự động dựa trên trigger
|
|
26
|
+
* - Bao gồm: tin chào mừng, tin cảm ơn, tin nhắc nhở
|
|
27
|
+
*
|
|
28
|
+
* 4. TIN NHẮN HỆ THỐNG:
|
|
29
|
+
* - Tin nhắn thông báo từ hệ thống
|
|
30
|
+
* - Bao gồm: thông báo bảo trì, cập nhật chính sách
|
|
31
|
+
*/
|
|
32
|
+
export declare class GeneralMessageService {
|
|
33
|
+
private readonly client;
|
|
34
|
+
constructor(client: ZaloClient);
|
|
35
|
+
/**
|
|
36
|
+
* Gửi tin nhắn phản hồi văn bản
|
|
37
|
+
* @param accessToken Access token của Official Account
|
|
38
|
+
* @param recipient Thông tin người nhận
|
|
39
|
+
* @param message Nội dung tin nhắn văn bản
|
|
40
|
+
* @returns Thông tin tin nhắn đã gửi
|
|
41
|
+
*/
|
|
42
|
+
sendResponseTextMessage(accessToken: string, recipient: MessageRecipient, message: TextMessage): Promise<SendMessageResponse>;
|
|
43
|
+
/**
|
|
44
|
+
* Gửi tin nhắn phản hồi hình ảnh
|
|
45
|
+
* @param accessToken Access token của Official Account
|
|
46
|
+
* @param recipient Thông tin người nhận
|
|
47
|
+
* @param message Nội dung tin nhắn hình ảnh
|
|
48
|
+
* @returns Thông tin tin nhắn đã gửi
|
|
49
|
+
*/
|
|
50
|
+
sendResponseImageMessage(accessToken: string, recipient: MessageRecipient, message: ImageMessage): Promise<SendMessageResponse>;
|
|
51
|
+
/**
|
|
52
|
+
* Gửi tin nhắn ẩn danh
|
|
53
|
+
* @param accessToken Access token của Official Account
|
|
54
|
+
* @param recipient Thông tin người nhận
|
|
55
|
+
* @param message Nội dung tin nhắn ẩn danh
|
|
56
|
+
* @returns Thông tin tin nhắn đã gửi
|
|
57
|
+
*/
|
|
58
|
+
sendAnonymousMessage(accessToken: string, recipient: MessageRecipient, message: AnonymousTextMessage): Promise<SendMessageResponse>;
|
|
59
|
+
/**
|
|
60
|
+
* Upload file để sử dụng trong tin nhắn
|
|
61
|
+
* @param accessToken Access token của Official Account
|
|
62
|
+
* @param file File data (base64 hoặc buffer)
|
|
63
|
+
* @param fileName Tên file
|
|
64
|
+
* @returns Thông tin file đã upload
|
|
65
|
+
*/
|
|
66
|
+
uploadFile(accessToken: string, file: string | Buffer, fileName: string): Promise<UploadFileResponse>;
|
|
67
|
+
/**
|
|
68
|
+
* Upload hình ảnh để sử dụng trong tin nhắn
|
|
69
|
+
* @param accessToken Access token của Official Account
|
|
70
|
+
* @param image Image data (base64 hoặc buffer)
|
|
71
|
+
* @param fileName Tên file hình ảnh
|
|
72
|
+
* @returns Thông tin hình ảnh đã upload
|
|
73
|
+
*/
|
|
74
|
+
uploadImage(accessToken: string, image: string | Buffer, fileName: string): Promise<UploadFileResponse>;
|
|
75
|
+
/**
|
|
76
|
+
* Gửi tin nhắn tổng quát
|
|
77
|
+
* @param accessToken Access token của Official Account
|
|
78
|
+
* @param recipient Thông tin người nhận
|
|
79
|
+
* @param message Nội dung tin nhắn
|
|
80
|
+
* @param messagingType Loại tin nhắn (response, update, message_tag)
|
|
81
|
+
* @returns Thông tin tin nhắn đã gửi
|
|
82
|
+
*/
|
|
83
|
+
sendMessage(accessToken: string, recipient: MessageRecipient, message: Message, messagingType?: "consultation" | "transaction" | "promotion" | "response" | "update" | "message_tag"): Promise<SendMessageResponse>;
|
|
84
|
+
}
|
|
85
|
+
//# sourceMappingURL=general-message.service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"general-message.service.d.ts","sourceRoot":"","sources":["../../src/services/general-message.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EACL,OAAO,EAEP,mBAAmB,EACnB,kBAAkB,EAClB,WAAW,EACX,YAAY,EAGZ,gBAAgB,EAChB,oBAAoB,EACrB,MAAM,kBAAkB,CAAC;AAG1B;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,qBAAa,qBAAqB;IACpB,OAAO,CAAC,QAAQ,CAAC,MAAM;gBAAN,MAAM,EAAE,UAAU;IAE/C;;;;;;OAMG;IACU,uBAAuB,CAClC,WAAW,EAAE,MAAM,EACnB,SAAS,EAAE,gBAAgB,EAC3B,OAAO,EAAE,WAAW,GACnB,OAAO,CAAC,mBAAmB,CAAC;IAgD/B;;;;;;OAMG;IACU,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