@congminh1254/shopee-sdk 0.9.0 → 1.0.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.
Files changed (137) hide show
  1. package/README.md +178 -36
  2. package/lib/fetch.js +13 -0
  3. package/lib/fetch.js.map +1 -1
  4. package/lib/managers/add-on-deal.manager.d.ts +140 -0
  5. package/lib/managers/add-on-deal.manager.js +240 -0
  6. package/lib/managers/add-on-deal.manager.js.map +1 -0
  7. package/lib/managers/ads.manager.d.ts +217 -1
  8. package/lib/managers/ads.manager.js +312 -0
  9. package/lib/managers/ads.manager.js.map +1 -1
  10. package/lib/managers/bundle-deal.manager.d.ts +106 -0
  11. package/lib/managers/bundle-deal.manager.js +178 -0
  12. package/lib/managers/bundle-deal.manager.js.map +1 -0
  13. package/lib/managers/discount.manager.d.ts +102 -0
  14. package/lib/managers/discount.manager.js +167 -0
  15. package/lib/managers/discount.manager.js.map +1 -0
  16. package/lib/managers/fbs.manager.d.ts +115 -0
  17. package/lib/managers/fbs.manager.js +145 -0
  18. package/lib/managers/fbs.manager.js.map +1 -0
  19. package/lib/managers/first-mile.manager.d.ts +150 -0
  20. package/lib/managers/first-mile.manager.js +264 -0
  21. package/lib/managers/first-mile.manager.js.map +1 -0
  22. package/lib/managers/follow-prize.manager.d.ts +108 -0
  23. package/lib/managers/follow-prize.manager.js +152 -0
  24. package/lib/managers/follow-prize.manager.js.map +1 -0
  25. package/lib/managers/global-product.manager.d.ts +664 -0
  26. package/lib/managers/global-product.manager.js +904 -0
  27. package/lib/managers/global-product.manager.js.map +1 -0
  28. package/lib/managers/index.d.ts +17 -1
  29. package/lib/managers/index.js +17 -1
  30. package/lib/managers/index.js.map +1 -1
  31. package/lib/managers/livestream.manager.d.ts +377 -0
  32. package/lib/managers/livestream.manager.js +529 -0
  33. package/lib/managers/livestream.manager.js.map +1 -0
  34. package/lib/managers/logistics.manager.d.ts +267 -1
  35. package/lib/managers/logistics.manager.js +544 -0
  36. package/lib/managers/logistics.manager.js.map +1 -1
  37. package/lib/managers/media-space.manager.d.ts +179 -0
  38. package/lib/managers/media-space.manager.js +220 -0
  39. package/lib/managers/media-space.manager.js.map +1 -0
  40. package/lib/managers/media.manager.d.ts +226 -0
  41. package/lib/managers/media.manager.js +274 -0
  42. package/lib/managers/media.manager.js.map +1 -0
  43. package/lib/managers/merchant.manager.d.ts +100 -0
  44. package/lib/managers/merchant.manager.js +144 -0
  45. package/lib/managers/merchant.manager.js.map +1 -0
  46. package/lib/managers/order.manager.d.ts +213 -1
  47. package/lib/managers/order.manager.js +305 -0
  48. package/lib/managers/order.manager.js.map +1 -1
  49. package/lib/managers/payment.manager.d.ts +186 -1
  50. package/lib/managers/payment.manager.js +288 -0
  51. package/lib/managers/payment.manager.js.map +1 -1
  52. package/lib/managers/product.manager.d.ts +346 -1
  53. package/lib/managers/product.manager.js +718 -0
  54. package/lib/managers/product.manager.js.map +1 -1
  55. package/lib/managers/returns.manager.d.ts +200 -0
  56. package/lib/managers/returns.manager.js +300 -0
  57. package/lib/managers/returns.manager.js.map +1 -0
  58. package/lib/managers/sbs.manager.d.ts +112 -0
  59. package/lib/managers/sbs.manager.js +149 -0
  60. package/lib/managers/sbs.manager.js.map +1 -0
  61. package/lib/managers/shop-category.manager.d.ts +207 -0
  62. package/lib/managers/shop-category.manager.js +258 -0
  63. package/lib/managers/shop-category.manager.js.map +1 -0
  64. package/lib/managers/shop-flash-sale.manager.d.ts +242 -0
  65. package/lib/managers/shop-flash-sale.manager.js +321 -0
  66. package/lib/managers/shop-flash-sale.manager.js.map +1 -0
  67. package/lib/managers/shop.manager.d.ts +173 -0
  68. package/lib/managers/shop.manager.js +217 -0
  69. package/lib/managers/shop.manager.js.map +1 -0
  70. package/lib/managers/top-picks.manager.d.ts +62 -0
  71. package/lib/managers/top-picks.manager.js +91 -0
  72. package/lib/managers/top-picks.manager.js.map +1 -0
  73. package/lib/schemas/add-on-deal.d.ts +390 -0
  74. package/lib/schemas/add-on-deal.js +45 -0
  75. package/lib/schemas/add-on-deal.js.map +1 -0
  76. package/lib/schemas/ads.d.ts +437 -0
  77. package/lib/schemas/bundle-deal.d.ts +300 -0
  78. package/lib/schemas/bundle-deal.js +27 -0
  79. package/lib/schemas/bundle-deal.js.map +1 -0
  80. package/lib/schemas/discount.d.ts +334 -0
  81. package/lib/schemas/discount.js +15 -0
  82. package/lib/schemas/discount.js.map +1 -0
  83. package/lib/schemas/fbs.d.ts +117 -0
  84. package/lib/schemas/fbs.js +2 -0
  85. package/lib/schemas/fbs.js.map +1 -0
  86. package/lib/schemas/first-mile.d.ts +551 -0
  87. package/lib/schemas/first-mile.js +2 -0
  88. package/lib/schemas/first-mile.js.map +1 -0
  89. package/lib/schemas/follow-prize.d.ts +198 -0
  90. package/lib/schemas/follow-prize.js +27 -0
  91. package/lib/schemas/follow-prize.js.map +1 -0
  92. package/lib/schemas/global-product.d.ts +1127 -0
  93. package/lib/schemas/global-product.js +2 -0
  94. package/lib/schemas/global-product.js.map +1 -0
  95. package/lib/schemas/index.d.ts +13 -0
  96. package/lib/schemas/index.js +17 -0
  97. package/lib/schemas/index.js.map +1 -1
  98. package/lib/schemas/livestream.d.ts +649 -0
  99. package/lib/schemas/livestream.js +2 -0
  100. package/lib/schemas/livestream.js.map +1 -0
  101. package/lib/schemas/logistics.d.ts +979 -0
  102. package/lib/schemas/logistics.js +13 -0
  103. package/lib/schemas/logistics.js.map +1 -1
  104. package/lib/schemas/media-space.d.ts +189 -0
  105. package/lib/schemas/media-space.js +2 -0
  106. package/lib/schemas/media-space.js.map +1 -0
  107. package/lib/schemas/media.d.ts +230 -0
  108. package/lib/schemas/media.js +2 -0
  109. package/lib/schemas/media.js.map +1 -0
  110. package/lib/schemas/merchant.d.ts +236 -0
  111. package/lib/schemas/merchant.js +2 -0
  112. package/lib/schemas/merchant.js.map +1 -0
  113. package/lib/schemas/order.d.ts +431 -0
  114. package/lib/schemas/payment.d.ts +397 -0
  115. package/lib/schemas/product.d.ts +1157 -0
  116. package/lib/schemas/returns.d.ts +632 -0
  117. package/lib/schemas/returns.js +63 -0
  118. package/lib/schemas/returns.js.map +1 -0
  119. package/lib/schemas/sbs.d.ts +484 -0
  120. package/lib/schemas/sbs.js +2 -0
  121. package/lib/schemas/sbs.js.map +1 -0
  122. package/lib/schemas/shop-category.d.ts +176 -0
  123. package/lib/schemas/shop-category.js +2 -0
  124. package/lib/schemas/shop-category.js.map +1 -0
  125. package/lib/schemas/shop-flash-sale.d.ts +473 -0
  126. package/lib/schemas/shop-flash-sale.js +43 -0
  127. package/lib/schemas/shop-flash-sale.js.map +1 -0
  128. package/lib/schemas/shop.d.ts +250 -0
  129. package/lib/schemas/shop.js +2 -0
  130. package/lib/schemas/shop.js.map +1 -0
  131. package/lib/schemas/top-picks.d.ts +99 -0
  132. package/lib/schemas/top-picks.js +2 -0
  133. package/lib/schemas/top-picks.js.map +1 -0
  134. package/lib/sdk.d.ts +34 -0
  135. package/lib/sdk.js +34 -0
  136. package/lib/sdk.js.map +1 -1
  137. package/package.json +7 -4
@@ -0,0 +1,274 @@
1
+ import { BaseManager } from "./base.manager.js";
2
+ import { ShopeeFetch } from "../fetch.js";
3
+ /**
4
+ * MediaManager handles media upload operations for the Shopee API
5
+ *
6
+ * Provides methods for:
7
+ * - Image upload for various business scenarios
8
+ * - Video upload with multi-part upload support
9
+ * - Video upload status tracking
10
+ */
11
+ export class MediaManager extends BaseManager {
12
+ constructor(config) {
13
+ super(config);
14
+ }
15
+ /**
16
+ * Upload images for specific business scenarios (e.g., returns)
17
+ *
18
+ * @param {UploadMediaImageParams} params - Parameters for uploading images
19
+ * @param {number} params.business - Business type (2 = Returns)
20
+ * @param {number} params.scene - Scene type (1 = Return Seller Self Arrange Pickup Proof)
21
+ * @param {string | Buffer | Array<string | Buffer>} params.images - Image files to upload
22
+ * @returns {Promise<UploadMediaImageResponse>} Response containing uploaded image information
23
+ *
24
+ * @example
25
+ * ```typescript
26
+ * const result = await sdk.media.uploadMediaImage({
27
+ * business: 2,
28
+ * scene: 1,
29
+ * images: '/path/to/image.jpg'
30
+ * });
31
+ * console.log('Uploaded images:', result.response.image_list);
32
+ * ```
33
+ *
34
+ * **Restrictions:**
35
+ * - business = 2, scene = 1: Up to 3 images, max 10MB each, formats: JPG, JPEG, PNG
36
+ *
37
+ * @throws {Error} When the API request fails
38
+ */
39
+ async uploadMediaImage(params) {
40
+ const response = await ShopeeFetch.fetch(this.config, "/media/upload_image", {
41
+ method: "POST",
42
+ body: params,
43
+ });
44
+ return response;
45
+ }
46
+ /**
47
+ * Upload multiple image files for general use
48
+ *
49
+ * @param {UploadImageParams} params - Parameters for uploading images
50
+ * @param {string | Buffer | Array<string | Buffer>} params.image - Image files (up to 9 images)
51
+ * @param {string} [params.scene] - Scene type ("normal" or "desc")
52
+ * @param {string} [params.ratio] - Image ratio ("1:1" or "3:4", whitelisted sellers only)
53
+ * @returns {Promise<UploadImageResponse>} Response containing uploaded image information
54
+ *
55
+ * @example
56
+ * ```typescript
57
+ * // Upload product images (square processing)
58
+ * const result = await sdk.media.uploadImage({
59
+ * image: ['/path/to/image1.jpg', '/path/to/image2.jpg'],
60
+ * scene: 'normal',
61
+ * ratio: '1:1'
62
+ * });
63
+ *
64
+ * // Upload description images (no processing)
65
+ * const descResult = await sdk.media.uploadImage({
66
+ * image: '/path/to/desc-image.jpg',
67
+ * scene: 'desc'
68
+ * });
69
+ * ```
70
+ *
71
+ * **Image Requirements:**
72
+ * - Maximum: 9 images per request
73
+ * - Maximum size: 10MB per image
74
+ * - Formats: JPG, JPEG, PNG
75
+ * - Scene "normal": Image processed as square (recommended for item images)
76
+ * - Scene "desc": No processing (recommended for extended descriptions)
77
+ *
78
+ * @throws {Error} When the API request fails
79
+ */
80
+ async uploadImage(params) {
81
+ const response = await ShopeeFetch.fetch(this.config, "/media_space/upload_image", {
82
+ method: "POST",
83
+ auth: true,
84
+ body: params,
85
+ });
86
+ return response;
87
+ }
88
+ /**
89
+ * Initiate a video upload session
90
+ *
91
+ * @param {InitVideoUploadParams} params - Parameters for initiating video upload
92
+ * @param {string} params.file_md5 - MD5 hash of the video file
93
+ * @param {number} params.file_size - Size of video file in bytes (max 30MB)
94
+ * @returns {Promise<InitVideoUploadResponse>} Response containing video_upload_id
95
+ *
96
+ * @example
97
+ * ```typescript
98
+ * const result = await sdk.media.initVideoUpload({
99
+ * file_md5: '2abf0b6e5ff90ff24437a0808f171a93',
100
+ * file_size: 1261876
101
+ * });
102
+ * const videoUploadId = result.response.video_upload_id;
103
+ * ```
104
+ *
105
+ * **Video Requirements:**
106
+ * - Duration: 10-60 seconds (inclusive)
107
+ * - Maximum size: 30MB
108
+ * - Must upload by parts after initialization
109
+ *
110
+ * @throws {Error} When the API request fails
111
+ * - error_file_size: File size is too large (max 30MB)
112
+ */
113
+ async initVideoUpload(params) {
114
+ const response = await ShopeeFetch.fetch(this.config, "/media_space/init_video_upload", {
115
+ method: "POST",
116
+ auth: true,
117
+ body: params,
118
+ });
119
+ return response;
120
+ }
121
+ /**
122
+ * Upload a video file by parts
123
+ *
124
+ * @param {UploadVideoPartParams} params - Parameters for uploading video part
125
+ * @param {string} params.video_upload_id - Upload ID from initVideoUpload
126
+ * @param {number} params.part_seq - Sequence number starting from 0
127
+ * @param {string} params.content_md5 - MD5 hash of this part
128
+ * @param {string | Buffer} params.part_content - Content of this part
129
+ * @returns {Promise<UploadVideoPartResponse>} Response indicating upload success
130
+ *
131
+ * @example
132
+ * ```typescript
133
+ * // Upload video parts sequentially
134
+ * for (let i = 0; i < partCount; i++) {
135
+ * await sdk.media.uploadVideoPart({
136
+ * video_upload_id: videoUploadId,
137
+ * part_seq: i,
138
+ * content_md5: partMd5,
139
+ * part_content: partBuffer
140
+ * });
141
+ * }
142
+ * ```
143
+ *
144
+ * **Part Requirements:**
145
+ * - Part size: Exactly 4MB except for the last part
146
+ * - Must provide MD5 hash for each part
147
+ * - Upload parts sequentially starting from 0
148
+ *
149
+ * @throws {Error} When the API request fails
150
+ * - error_invalid_upload_id: Invalid upload_id
151
+ * - error_invalid_part_seq: Invalid part_seq
152
+ * - error_invalid_part_size: Invalid part_size
153
+ */
154
+ async uploadVideoPart(params) {
155
+ const response = await ShopeeFetch.fetch(this.config, "/media_space/upload_video_part", {
156
+ method: "POST",
157
+ body: params,
158
+ });
159
+ return response;
160
+ }
161
+ /**
162
+ * Complete the video upload and start transcoding
163
+ *
164
+ * @param {CompleteVideoUploadParams} params - Parameters for completing video upload
165
+ * @param {string} params.video_upload_id - Upload ID from initVideoUpload
166
+ * @param {number[]} params.part_seq_list - List of all uploaded part sequences
167
+ * @param {object} params.report_data - Upload performance tracking data
168
+ * @param {number} params.report_data.upload_cost - Upload time in milliseconds
169
+ * @returns {Promise<CompleteVideoUploadResponse>} Response indicating completion
170
+ *
171
+ * @example
172
+ * ```typescript
173
+ * const startTime = Date.now();
174
+ * // ... upload all parts ...
175
+ * const uploadCost = Date.now() - startTime;
176
+ *
177
+ * await sdk.media.completeVideoUpload({
178
+ * video_upload_id: videoUploadId,
179
+ * part_seq_list: [0, 1, 2, 3],
180
+ * report_data: {
181
+ * upload_cost: uploadCost
182
+ * }
183
+ * });
184
+ * ```
185
+ *
186
+ * **Notes:**
187
+ * - Call this after all parts are uploaded successfully
188
+ * - Transcoding process begins after this call
189
+ * - Use getVideoUploadResult to check transcoding status
190
+ *
191
+ * @throws {Error} When the API request fails
192
+ * - error_invalid_upload_id: Invalid upload_id
193
+ * - error_already_completed: Upload already completed
194
+ */
195
+ async completeVideoUpload(params) {
196
+ const response = await ShopeeFetch.fetch(this.config, "/media_space/complete_video_upload", {
197
+ method: "POST",
198
+ body: params,
199
+ });
200
+ return response;
201
+ }
202
+ /**
203
+ * Query the upload status and result of a video upload
204
+ *
205
+ * @param {GetVideoUploadResultParams} params - Parameters for querying video status
206
+ * @param {string} params.video_upload_id - Upload ID from initVideoUpload
207
+ * @returns {Promise<GetVideoUploadResultResponse>} Response containing upload status and video info
208
+ *
209
+ * @example
210
+ * ```typescript
211
+ * const result = await sdk.media.getVideoUploadResult({
212
+ * video_upload_id: videoUploadId
213
+ * });
214
+ *
215
+ * if (result.response.status === 'SUCCEEDED') {
216
+ * console.log('Video URL:', result.response.video_info.video_url_list);
217
+ * console.log('Duration:', result.response.video_info.duration);
218
+ * } else if (result.response.status === 'FAILED') {
219
+ * console.error('Upload failed:', result.response.message);
220
+ * }
221
+ * ```
222
+ *
223
+ * **Upload Status:**
224
+ * - INITIATED: Waiting for parts or complete_video_upload call
225
+ * - TRANSCODING: Transcoding the video file
226
+ * - SUCCEEDED: Transcoding completed, video ready to use
227
+ * - FAILED: Upload failed, check message for details
228
+ * - CANCELLED: Upload was cancelled
229
+ *
230
+ * @throws {Error} When the API request fails
231
+ * - error_invalid_upload_id: Invalid upload_id
232
+ */
233
+ async getVideoUploadResult(params) {
234
+ const response = await ShopeeFetch.fetch(this.config, "/media_space/get_video_upload_result", {
235
+ method: "GET",
236
+ auth: true,
237
+ params,
238
+ });
239
+ return response;
240
+ }
241
+ /**
242
+ * Cancel a video upload session
243
+ *
244
+ * @param {CancelVideoUploadParams} params - Parameters for cancelling video upload
245
+ * @param {string} params.video_upload_id - Upload ID from initVideoUpload
246
+ * @returns {Promise<CancelVideoUploadResponse>} Response indicating cancellation
247
+ *
248
+ * @example
249
+ * ```typescript
250
+ * await sdk.media.cancelVideoUpload({
251
+ * video_upload_id: videoUploadId
252
+ * });
253
+ * console.log('Video upload cancelled');
254
+ * ```
255
+ *
256
+ * **Use Cases:**
257
+ * - Cancel upload on user request
258
+ * - Cancel failed upload to free resources
259
+ * - Cancel when upload takes too long
260
+ *
261
+ * @throws {Error} When the API request fails
262
+ * - error_invalid_upload_id: Invalid upload_id
263
+ * - error_already_completed: Upload already completed (cannot cancel)
264
+ */
265
+ async cancelVideoUpload(params) {
266
+ const response = await ShopeeFetch.fetch(this.config, "/media_space/cancel_video_upload", {
267
+ method: "POST",
268
+ auth: true,
269
+ body: params,
270
+ });
271
+ return response;
272
+ }
273
+ }
274
+ //# sourceMappingURL=media.manager.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"media.manager.js","sourceRoot":"","sources":["../../src/managers/media.manager.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAiBhD,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE1C;;;;;;;GAOG;AACH,MAAM,OAAO,YAAa,SAAQ,WAAW;IAC3C,YAAY,MAAoB;QAC9B,KAAK,CAAC,MAAM,CAAC,CAAC;IAChB,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;OAuBG;IACH,KAAK,CAAC,gBAAgB,CAAC,MAA8B;QACnD,MAAM,QAAQ,GAAG,MAAM,WAAW,CAAC,KAAK,CACtC,IAAI,CAAC,MAAM,EACX,qBAAqB,EACrB;YACE,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,MAAM;SACb,CACF,CAAC;QAEF,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAiCG;IACH,KAAK,CAAC,WAAW,CAAC,MAAyB;QACzC,MAAM,QAAQ,GAAG,MAAM,WAAW,CAAC,KAAK,CACtC,IAAI,CAAC,MAAM,EACX,2BAA2B,EAC3B;YACE,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,IAAI;YACV,IAAI,EAAE,MAAM;SACb,CACF,CAAC;QAEF,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;;OAwBG;IACH,KAAK,CAAC,eAAe,CAAC,MAA6B;QACjD,MAAM,QAAQ,GAAG,MAAM,WAAW,CAAC,KAAK,CACtC,IAAI,CAAC,MAAM,EACX,gCAAgC,EAChC;YACE,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,IAAI;YACV,IAAI,EAAE,MAAM;SACb,CACF,CAAC;QAEF,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAgCG;IACH,KAAK,CAAC,eAAe,CAAC,MAA6B;QACjD,MAAM,QAAQ,GAAG,MAAM,WAAW,CAAC,KAAK,CACtC,IAAI,CAAC,MAAM,EACX,gCAAgC,EAChC;YACE,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,MAAM;SACb,CACF,CAAC;QAEF,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAiCG;IACH,KAAK,CAAC,mBAAmB,CACvB,MAAiC;QAEjC,MAAM,QAAQ,GAAG,MAAM,WAAW,CAAC,KAAK,CACtC,IAAI,CAAC,MAAM,EACX,oCAAoC,EACpC;YACE,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,MAAM;SACb,CACF,CAAC;QAEF,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA8BG;IACH,KAAK,CAAC,oBAAoB,CACxB,MAAkC;QAElC,MAAM,QAAQ,GAAG,MAAM,WAAW,CAAC,KAAK,CACtC,IAAI,CAAC,MAAM,EACX,sCAAsC,EACtC;YACE,MAAM,EAAE,KAAK;YACb,IAAI,EAAE,IAAI;YACV,MAAM;SACP,CACF,CAAC;QAEF,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;OAuBG;IACH,KAAK,CAAC,iBAAiB,CAAC,MAA+B;QACrD,MAAM,QAAQ,GAAG,MAAM,WAAW,CAAC,KAAK,CACtC,IAAI,CAAC,MAAM,EACX,kCAAkC,EAClC;YACE,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,IAAI;YACV,IAAI,EAAE,MAAM;SACb,CACF,CAAC;QAEF,OAAO,QAAQ,CAAC;IAClB,CAAC;CACF"}
@@ -0,0 +1,100 @@
1
+ import { ShopeeConfig } from "../sdk.js";
2
+ import { BaseManager } from "./base.manager.js";
3
+ import { GetMerchantInfoParams, GetMerchantInfoResponse, GetMerchantPrepaidAccountListParams, GetMerchantPrepaidAccountListResponse, GetMerchantWarehouseListParams, GetMerchantWarehouseListResponse, GetMerchantWarehouseLocationListParams, GetMerchantWarehouseLocationListResponse, GetShopListByMerchantParams, GetShopListByMerchantResponse, GetWarehouseEligibleShopListParams, GetWarehouseEligibleShopListResponse } from "../schemas/merchant.js";
4
+ export declare class MerchantManager extends BaseManager {
5
+ constructor(config: ShopeeConfig);
6
+ /**
7
+ * Get information of merchant
8
+ * @returns {Promise<GetMerchantInfoResponse>} The response containing merchant information including name, authorization time, currency, region, and CBSC status
9
+ *
10
+ * This endpoint retrieves comprehensive information about the merchant including:
11
+ * - Merchant name and region
12
+ * - Authorization and expiration times
13
+ * - Supported currency
14
+ * - CNSC/CBSC upgrade status
15
+ */
16
+ getMerchantInfo(params?: GetMerchantInfoParams): Promise<GetMerchantInfoResponse>;
17
+ /**
18
+ * Get seller's courier prepaid account list
19
+ * @param {GetMerchantPrepaidAccountListParams} params - Pagination parameters
20
+ * @param {number} params.page_no - Page number starting from 1
21
+ * @param {number} params.page_size - Number of items per page (max 100)
22
+ * @returns {Promise<GetMerchantPrepaidAccountListResponse>} The response containing list of prepaid accounts with courier details
23
+ *
24
+ * This endpoint retrieves the merchant's prepaid courier accounts including:
25
+ * - Account IDs and default status
26
+ * - Courier information (name, key)
27
+ * - Partner credentials (may be masked for security)
28
+ * - Account configuration details
29
+ */
30
+ getMerchantPrepaidAccountList(params: GetMerchantPrepaidAccountListParams): Promise<GetMerchantPrepaidAccountListResponse>;
31
+ /**
32
+ * Get merchant warehouse list with pagination
33
+ * @param {GetMerchantWarehouseListParams} params - Parameters with cursor for pagination
34
+ * @param {DoubleSidedCursor} params.cursor - Cursor for pagination (next_id, prev_id, page_size)
35
+ * @returns {Promise<GetMerchantWarehouseListResponse>} The response containing list of warehouses with full address details
36
+ *
37
+ * This endpoint retrieves the merchant's warehouse list including:
38
+ * - Warehouse IDs, names, and types (pickup/return)
39
+ * - Complete address information (street, city, state, region, zip code)
40
+ * - Location identifiers
41
+ * - Enterprise information (for applicable regions like Brazil)
42
+ * - Support for double-sided cursor pagination (next/prev)
43
+ *
44
+ * Pagination guide:
45
+ * - First page: Set next_id = 0 or null
46
+ * - Next page: Use next_id from previous response, set prev_id = null
47
+ * - Previous page: Use prev_id from previous response, set next_id = null
48
+ * - No more next data: next_id in response is null
49
+ * - No more prev data: prev_id in response is null
50
+ */
51
+ getMerchantWarehouseList(params: GetMerchantWarehouseListParams): Promise<GetMerchantWarehouseListResponse>;
52
+ /**
53
+ * Get merchant warehouse location list
54
+ * @returns {Promise<GetMerchantWarehouseLocationListResponse>} The response containing list of warehouse locations with location IDs and names
55
+ *
56
+ * This endpoint retrieves a simplified list of warehouse locations including:
57
+ * - Location IDs
58
+ * - Warehouse names
59
+ *
60
+ * This is useful for getting a quick overview of available warehouse locations
61
+ * without the full address details provided by getMerchantWarehouseList.
62
+ */
63
+ getMerchantWarehouseLocationList(params?: GetMerchantWarehouseLocationListParams): Promise<GetMerchantWarehouseLocationListResponse>;
64
+ /**
65
+ * Get shop list bound to merchant
66
+ * @param {GetShopListByMerchantParams} params - Pagination parameters
67
+ * @param {number} params.page_no - Page number starting from 1
68
+ * @param {number} params.page_size - Number of items per page (max 500)
69
+ * @returns {Promise<GetShopListByMerchantResponse>} The response containing list of shops with SIP affiliate information
70
+ *
71
+ * This endpoint retrieves all shops that are authorized to the partner and bound to the merchant including:
72
+ * - Shop IDs
73
+ * - SIP affiliate shops (only returned for primary shops)
74
+ * - CNSC status indicator
75
+ * - Pagination support with more flag
76
+ */
77
+ getShopListByMerchant(params: GetShopListByMerchantParams): Promise<GetShopListByMerchantResponse>;
78
+ /**
79
+ * Get eligible shop list by warehouse id
80
+ * @param {GetWarehouseEligibleShopListParams} params - Parameters with warehouse ID, type, and cursor
81
+ * @param {number} params.warehouse_id - Warehouse address identifier
82
+ * @param {number} params.warehouse_type - 1 = pickup warehouse, 2 = return warehouse
83
+ * @param {DoubleSidedCursor} params.cursor - Cursor for pagination
84
+ * @returns {Promise<GetWarehouseEligibleShopListResponse>} The response containing list of eligible shops with names
85
+ *
86
+ * This endpoint retrieves shops that are eligible for a specific warehouse including:
87
+ * - Shop IDs and names
88
+ * - Support for double-sided cursor pagination
89
+ *
90
+ * Useful for determining which shops can use a particular warehouse for
91
+ * pickups (warehouse_type = 1) or returns (warehouse_type = 2).
92
+ *
93
+ * Pagination guide:
94
+ * - First page: Set next_id = 0 or null, specify page_size
95
+ * - Next page: Use next_id from previous response, set prev_id = null
96
+ * - Previous page: Use prev_id from previous response, set next_id = null
97
+ * - Page size limit: [1, 30]
98
+ */
99
+ getWarehouseEligibleShopList(params: GetWarehouseEligibleShopListParams): Promise<GetWarehouseEligibleShopListResponse>;
100
+ }
@@ -0,0 +1,144 @@
1
+ import { BaseManager } from "./base.manager.js";
2
+ import { ShopeeFetch } from "../fetch.js";
3
+ export class MerchantManager extends BaseManager {
4
+ constructor(config) {
5
+ super(config);
6
+ }
7
+ /**
8
+ * Get information of merchant
9
+ * @returns {Promise<GetMerchantInfoResponse>} The response containing merchant information including name, authorization time, currency, region, and CBSC status
10
+ *
11
+ * This endpoint retrieves comprehensive information about the merchant including:
12
+ * - Merchant name and region
13
+ * - Authorization and expiration times
14
+ * - Supported currency
15
+ * - CNSC/CBSC upgrade status
16
+ */
17
+ async getMerchantInfo(params) {
18
+ const response = await ShopeeFetch.fetch(this.config, "/merchant/get_merchant_info", {
19
+ method: "GET",
20
+ auth: true,
21
+ params,
22
+ });
23
+ return response;
24
+ }
25
+ /**
26
+ * Get seller's courier prepaid account list
27
+ * @param {GetMerchantPrepaidAccountListParams} params - Pagination parameters
28
+ * @param {number} params.page_no - Page number starting from 1
29
+ * @param {number} params.page_size - Number of items per page (max 100)
30
+ * @returns {Promise<GetMerchantPrepaidAccountListResponse>} The response containing list of prepaid accounts with courier details
31
+ *
32
+ * This endpoint retrieves the merchant's prepaid courier accounts including:
33
+ * - Account IDs and default status
34
+ * - Courier information (name, key)
35
+ * - Partner credentials (may be masked for security)
36
+ * - Account configuration details
37
+ */
38
+ async getMerchantPrepaidAccountList(params) {
39
+ const response = await ShopeeFetch.fetch(this.config, "/merchant/get_merchant_prepaid_account_list", {
40
+ method: "POST",
41
+ auth: true,
42
+ body: params,
43
+ });
44
+ return response;
45
+ }
46
+ /**
47
+ * Get merchant warehouse list with pagination
48
+ * @param {GetMerchantWarehouseListParams} params - Parameters with cursor for pagination
49
+ * @param {DoubleSidedCursor} params.cursor - Cursor for pagination (next_id, prev_id, page_size)
50
+ * @returns {Promise<GetMerchantWarehouseListResponse>} The response containing list of warehouses with full address details
51
+ *
52
+ * This endpoint retrieves the merchant's warehouse list including:
53
+ * - Warehouse IDs, names, and types (pickup/return)
54
+ * - Complete address information (street, city, state, region, zip code)
55
+ * - Location identifiers
56
+ * - Enterprise information (for applicable regions like Brazil)
57
+ * - Support for double-sided cursor pagination (next/prev)
58
+ *
59
+ * Pagination guide:
60
+ * - First page: Set next_id = 0 or null
61
+ * - Next page: Use next_id from previous response, set prev_id = null
62
+ * - Previous page: Use prev_id from previous response, set next_id = null
63
+ * - No more next data: next_id in response is null
64
+ * - No more prev data: prev_id in response is null
65
+ */
66
+ async getMerchantWarehouseList(params) {
67
+ const response = await ShopeeFetch.fetch(this.config, "/merchant/get_merchant_warehouse_list", {
68
+ method: "POST",
69
+ auth: true,
70
+ body: params,
71
+ });
72
+ return response;
73
+ }
74
+ /**
75
+ * Get merchant warehouse location list
76
+ * @returns {Promise<GetMerchantWarehouseLocationListResponse>} The response containing list of warehouse locations with location IDs and names
77
+ *
78
+ * This endpoint retrieves a simplified list of warehouse locations including:
79
+ * - Location IDs
80
+ * - Warehouse names
81
+ *
82
+ * This is useful for getting a quick overview of available warehouse locations
83
+ * without the full address details provided by getMerchantWarehouseList.
84
+ */
85
+ async getMerchantWarehouseLocationList(params) {
86
+ const response = await ShopeeFetch.fetch(this.config, "/merchant/get_merchant_warehouse_location_list", {
87
+ method: "GET",
88
+ auth: true,
89
+ params,
90
+ });
91
+ return response;
92
+ }
93
+ /**
94
+ * Get shop list bound to merchant
95
+ * @param {GetShopListByMerchantParams} params - Pagination parameters
96
+ * @param {number} params.page_no - Page number starting from 1
97
+ * @param {number} params.page_size - Number of items per page (max 500)
98
+ * @returns {Promise<GetShopListByMerchantResponse>} The response containing list of shops with SIP affiliate information
99
+ *
100
+ * This endpoint retrieves all shops that are authorized to the partner and bound to the merchant including:
101
+ * - Shop IDs
102
+ * - SIP affiliate shops (only returned for primary shops)
103
+ * - CNSC status indicator
104
+ * - Pagination support with more flag
105
+ */
106
+ async getShopListByMerchant(params) {
107
+ const response = await ShopeeFetch.fetch(this.config, "/merchant/get_shop_list_by_merchant", {
108
+ method: "GET",
109
+ auth: true,
110
+ params,
111
+ });
112
+ return response;
113
+ }
114
+ /**
115
+ * Get eligible shop list by warehouse id
116
+ * @param {GetWarehouseEligibleShopListParams} params - Parameters with warehouse ID, type, and cursor
117
+ * @param {number} params.warehouse_id - Warehouse address identifier
118
+ * @param {number} params.warehouse_type - 1 = pickup warehouse, 2 = return warehouse
119
+ * @param {DoubleSidedCursor} params.cursor - Cursor for pagination
120
+ * @returns {Promise<GetWarehouseEligibleShopListResponse>} The response containing list of eligible shops with names
121
+ *
122
+ * This endpoint retrieves shops that are eligible for a specific warehouse including:
123
+ * - Shop IDs and names
124
+ * - Support for double-sided cursor pagination
125
+ *
126
+ * Useful for determining which shops can use a particular warehouse for
127
+ * pickups (warehouse_type = 1) or returns (warehouse_type = 2).
128
+ *
129
+ * Pagination guide:
130
+ * - First page: Set next_id = 0 or null, specify page_size
131
+ * - Next page: Use next_id from previous response, set prev_id = null
132
+ * - Previous page: Use prev_id from previous response, set next_id = null
133
+ * - Page size limit: [1, 30]
134
+ */
135
+ async getWarehouseEligibleShopList(params) {
136
+ const response = await ShopeeFetch.fetch(this.config, "/merchant/get_warehouse_eligible_shop_list", {
137
+ method: "POST",
138
+ auth: true,
139
+ body: params,
140
+ });
141
+ return response;
142
+ }
143
+ }
144
+ //# sourceMappingURL=merchant.manager.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"merchant.manager.js","sourceRoot":"","sources":["../../src/managers/merchant.manager.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAehD,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE1C,MAAM,OAAO,eAAgB,SAAQ,WAAW;IAC9C,YAAY,MAAoB;QAC9B,KAAK,CAAC,MAAM,CAAC,CAAC;IAChB,CAAC;IAED;;;;;;;;;OASG;IACH,KAAK,CAAC,eAAe,CAAC,MAA8B;QAClD,MAAM,QAAQ,GAAG,MAAM,WAAW,CAAC,KAAK,CACtC,IAAI,CAAC,MAAM,EACX,6BAA6B,EAC7B;YACE,MAAM,EAAE,KAAK;YACb,IAAI,EAAE,IAAI;YACV,MAAM;SACP,CACF,CAAC;QAEF,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED;;;;;;;;;;;;OAYG;IACH,KAAK,CAAC,6BAA6B,CACjC,MAA2C;QAE3C,MAAM,QAAQ,GAAG,MAAM,WAAW,CAAC,KAAK,CACtC,IAAI,CAAC,MAAM,EACX,6CAA6C,EAC7C;YACE,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,IAAI;YACV,IAAI,EAAE,MAAM;SACb,CACF,CAAC;QAEF,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED;;;;;;;;;;;;;;;;;;;OAmBG;IACH,KAAK,CAAC,wBAAwB,CAC5B,MAAsC;QAEtC,MAAM,QAAQ,GAAG,MAAM,WAAW,CAAC,KAAK,CACtC,IAAI,CAAC,MAAM,EACX,uCAAuC,EACvC;YACE,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,IAAI;YACV,IAAI,EAAE,MAAM;SACb,CACF,CAAC;QAEF,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED;;;;;;;;;;OAUG;IACH,KAAK,CAAC,gCAAgC,CACpC,MAA+C;QAE/C,MAAM,QAAQ,GAAG,MAAM,WAAW,CAAC,KAAK,CACtC,IAAI,CAAC,MAAM,EACX,gDAAgD,EAChD;YACE,MAAM,EAAE,KAAK;YACb,IAAI,EAAE,IAAI;YACV,MAAM;SACP,CACF,CAAC;QAEF,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED;;;;;;;;;;;;OAYG;IACH,KAAK,CAAC,qBAAqB,CACzB,MAAmC;QAEnC,MAAM,QAAQ,GAAG,MAAM,WAAW,CAAC,KAAK,CACtC,IAAI,CAAC,MAAM,EACX,qCAAqC,EACrC;YACE,MAAM,EAAE,KAAK;YACb,IAAI,EAAE,IAAI;YACV,MAAM;SACP,CACF,CAAC;QAEF,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,KAAK,CAAC,4BAA4B,CAChC,MAA0C;QAE1C,MAAM,QAAQ,GAAG,MAAM,WAAW,CAAC,KAAK,CACtC,IAAI,CAAC,MAAM,EACX,4CAA4C,EAC5C;YACE,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,IAAI;YACV,IAAI,EAAE,MAAM;SACb,CACF,CAAC;QAEF,OAAO,QAAQ,CAAC;IAClB,CAAC;CACF"}