@congminh1254/shopee-sdk 0.10.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.
- package/README.md +172 -36
- package/lib/fetch.js +13 -0
- package/lib/fetch.js.map +1 -1
- package/lib/managers/add-on-deal.manager.d.ts +140 -0
- package/lib/managers/add-on-deal.manager.js +240 -0
- package/lib/managers/add-on-deal.manager.js.map +1 -0
- package/lib/managers/ads.manager.d.ts +217 -1
- package/lib/managers/ads.manager.js +312 -0
- package/lib/managers/ads.manager.js.map +1 -1
- package/lib/managers/bundle-deal.manager.d.ts +106 -0
- package/lib/managers/bundle-deal.manager.js +178 -0
- package/lib/managers/bundle-deal.manager.js.map +1 -0
- package/lib/managers/discount.manager.d.ts +102 -0
- package/lib/managers/discount.manager.js +167 -0
- package/lib/managers/discount.manager.js.map +1 -0
- package/lib/managers/fbs.manager.d.ts +115 -0
- package/lib/managers/fbs.manager.js +145 -0
- package/lib/managers/fbs.manager.js.map +1 -0
- package/lib/managers/first-mile.manager.d.ts +150 -0
- package/lib/managers/first-mile.manager.js +264 -0
- package/lib/managers/first-mile.manager.js.map +1 -0
- package/lib/managers/follow-prize.manager.d.ts +108 -0
- package/lib/managers/follow-prize.manager.js +152 -0
- package/lib/managers/follow-prize.manager.js.map +1 -0
- package/lib/managers/global-product.manager.d.ts +664 -0
- package/lib/managers/global-product.manager.js +904 -0
- package/lib/managers/global-product.manager.js.map +1 -0
- package/lib/managers/index.d.ts +17 -1
- package/lib/managers/index.js +17 -1
- package/lib/managers/index.js.map +1 -1
- package/lib/managers/livestream.manager.d.ts +377 -0
- package/lib/managers/livestream.manager.js +529 -0
- package/lib/managers/livestream.manager.js.map +1 -0
- package/lib/managers/logistics.manager.d.ts +267 -1
- package/lib/managers/logistics.manager.js +544 -0
- package/lib/managers/logistics.manager.js.map +1 -1
- package/lib/managers/media-space.manager.d.ts +179 -0
- package/lib/managers/media-space.manager.js +220 -0
- package/lib/managers/media-space.manager.js.map +1 -0
- package/lib/managers/media.manager.d.ts +226 -0
- package/lib/managers/media.manager.js +274 -0
- package/lib/managers/media.manager.js.map +1 -0
- package/lib/managers/merchant.manager.d.ts +100 -0
- package/lib/managers/merchant.manager.js +144 -0
- package/lib/managers/merchant.manager.js.map +1 -0
- package/lib/managers/order.manager.d.ts +213 -1
- package/lib/managers/order.manager.js +305 -0
- package/lib/managers/order.manager.js.map +1 -1
- package/lib/managers/payment.manager.d.ts +186 -1
- package/lib/managers/payment.manager.js +288 -0
- package/lib/managers/payment.manager.js.map +1 -1
- package/lib/managers/returns.manager.d.ts +200 -0
- package/lib/managers/returns.manager.js +300 -0
- package/lib/managers/returns.manager.js.map +1 -0
- package/lib/managers/sbs.manager.d.ts +112 -0
- package/lib/managers/sbs.manager.js +149 -0
- package/lib/managers/sbs.manager.js.map +1 -0
- package/lib/managers/shop-category.manager.d.ts +207 -0
- package/lib/managers/shop-category.manager.js +258 -0
- package/lib/managers/shop-category.manager.js.map +1 -0
- package/lib/managers/shop-flash-sale.manager.d.ts +242 -0
- package/lib/managers/shop-flash-sale.manager.js +321 -0
- package/lib/managers/shop-flash-sale.manager.js.map +1 -0
- package/lib/managers/shop.manager.d.ts +173 -0
- package/lib/managers/shop.manager.js +217 -0
- package/lib/managers/shop.manager.js.map +1 -0
- package/lib/managers/top-picks.manager.d.ts +62 -0
- package/lib/managers/top-picks.manager.js +91 -0
- package/lib/managers/top-picks.manager.js.map +1 -0
- package/lib/schemas/add-on-deal.d.ts +390 -0
- package/lib/schemas/add-on-deal.js +45 -0
- package/lib/schemas/add-on-deal.js.map +1 -0
- package/lib/schemas/ads.d.ts +437 -0
- package/lib/schemas/bundle-deal.d.ts +300 -0
- package/lib/schemas/bundle-deal.js +27 -0
- package/lib/schemas/bundle-deal.js.map +1 -0
- package/lib/schemas/discount.d.ts +334 -0
- package/lib/schemas/discount.js +15 -0
- package/lib/schemas/discount.js.map +1 -0
- package/lib/schemas/fbs.d.ts +117 -0
- package/lib/schemas/fbs.js +2 -0
- package/lib/schemas/fbs.js.map +1 -0
- package/lib/schemas/first-mile.d.ts +551 -0
- package/lib/schemas/first-mile.js +2 -0
- package/lib/schemas/first-mile.js.map +1 -0
- package/lib/schemas/follow-prize.d.ts +198 -0
- package/lib/schemas/follow-prize.js +27 -0
- package/lib/schemas/follow-prize.js.map +1 -0
- package/lib/schemas/global-product.d.ts +1127 -0
- package/lib/schemas/global-product.js +2 -0
- package/lib/schemas/global-product.js.map +1 -0
- package/lib/schemas/index.d.ts +13 -0
- package/lib/schemas/index.js +17 -0
- package/lib/schemas/index.js.map +1 -1
- package/lib/schemas/livestream.d.ts +649 -0
- package/lib/schemas/livestream.js +2 -0
- package/lib/schemas/livestream.js.map +1 -0
- package/lib/schemas/logistics.d.ts +979 -0
- package/lib/schemas/logistics.js +13 -0
- package/lib/schemas/logistics.js.map +1 -1
- package/lib/schemas/media-space.d.ts +189 -0
- package/lib/schemas/media-space.js +2 -0
- package/lib/schemas/media-space.js.map +1 -0
- package/lib/schemas/media.d.ts +230 -0
- package/lib/schemas/media.js +2 -0
- package/lib/schemas/media.js.map +1 -0
- package/lib/schemas/merchant.d.ts +236 -0
- package/lib/schemas/merchant.js +2 -0
- package/lib/schemas/merchant.js.map +1 -0
- package/lib/schemas/order.d.ts +431 -0
- package/lib/schemas/payment.d.ts +397 -0
- package/lib/schemas/returns.d.ts +632 -0
- package/lib/schemas/returns.js +63 -0
- package/lib/schemas/returns.js.map +1 -0
- package/lib/schemas/sbs.d.ts +484 -0
- package/lib/schemas/sbs.js +2 -0
- package/lib/schemas/sbs.js.map +1 -0
- package/lib/schemas/shop-category.d.ts +176 -0
- package/lib/schemas/shop-category.js +2 -0
- package/lib/schemas/shop-category.js.map +1 -0
- package/lib/schemas/shop-flash-sale.d.ts +473 -0
- package/lib/schemas/shop-flash-sale.js +43 -0
- package/lib/schemas/shop-flash-sale.js.map +1 -0
- package/lib/schemas/shop.d.ts +250 -0
- package/lib/schemas/shop.js +2 -0
- package/lib/schemas/shop.js.map +1 -0
- package/lib/schemas/top-picks.d.ts +99 -0
- package/lib/schemas/top-picks.js +2 -0
- package/lib/schemas/top-picks.js.map +1 -0
- package/lib/sdk.d.ts +34 -0
- package/lib/sdk.js +34 -0
- package/lib/sdk.js.map +1 -1
- package/package.json +2 -4
package/README.md
CHANGED
|
@@ -6,62 +6,198 @@
|
|
|
6
6
|
[](https://www.npmjs.com/package/@congminh1254/shopee-sdk)
|
|
7
7
|
[](https://opensource.org/licenses/MIT)
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
🎉 **The most complete, production-ready TypeScript SDK for Shopee Open API** 🎉
|
|
10
|
+
|
|
11
|
+
Build powerful Shopee integrations with confidence using our fully-featured SDK that covers **100% of Shopee's API endpoints**. Trusted by developers, built by the community.
|
|
12
|
+
|
|
13
|
+
## 📚 Documentation
|
|
14
|
+
|
|
15
|
+
**[Complete Documentation](./docs/README.md)** - Comprehensive guides and API references
|
|
16
|
+
|
|
17
|
+
### Quick Links
|
|
18
|
+
|
|
19
|
+
**Getting Started:**
|
|
20
|
+
- [Setup Guide](./docs/guides/setup.md) - Installation and configuration
|
|
21
|
+
- [Authentication](./docs/guides/authentication.md) - OAuth flow and token management
|
|
22
|
+
- [Token Storage](./docs/guides/token-storage.md) - Managing access tokens
|
|
23
|
+
- [Proxy Configuration](./docs/guides/proxy.md) - Using HTTP/HTTPS proxies
|
|
24
|
+
|
|
25
|
+
**API Managers:**
|
|
26
|
+
- [AuthManager](./docs/managers/auth.md) - Authentication operations
|
|
27
|
+
- [ProductManager](./docs/managers/product.md) - Product catalog management
|
|
28
|
+
- [OrderManager](./docs/managers/order.md) - Order processing
|
|
29
|
+
- [LogisticsManager](./docs/managers/logistics.md) - Shipping operations
|
|
30
|
+
- [PaymentManager](./docs/managers/payment.md) - Payment information
|
|
31
|
+
- [VoucherManager](./docs/managers/voucher.md) - Discount management
|
|
32
|
+
- [PushManager](./docs/managers/push.md) - Webhooks and notifications
|
|
33
|
+
- [PublicManager](./docs/managers/public.md) - Public API endpoints
|
|
34
|
+
- [AdsManager](./docs/managers/ads.md) - Advertising campaigns
|
|
35
|
+
- [AccountHealthManager](./docs/managers/account-health.md) - Performance metrics
|
|
36
|
+
- [ShopManager](./docs/managers/shop.md) - Shop information and settings
|
|
37
|
+
- [MediaManager](./docs/managers/media.md) - Image and video upload
|
|
38
|
+
- [MediaSpaceManager](./docs/managers/media-space.md) - Media uploads (images and videos)
|
|
39
|
+
- [MerchantManager](./docs/managers/merchant.md) - Merchant information and warehouses
|
|
40
|
+
- [GlobalProductManager](./docs/managers/global-product.md) - Global product management
|
|
41
|
+
- [FirstMileManager](./docs/managers/first-mile.md) - First mile logistics
|
|
42
|
+
- [DiscountManager](./docs/managers/discount.md) - Discount campaigns
|
|
43
|
+
- [BundleDealManager](./docs/managers/bundle-deal.md) - Bundle deal promotions
|
|
44
|
+
- [AddOnDealManager](./docs/managers/add-on-deal.md) - Add-on deal promotions
|
|
45
|
+
- [ShopFlashSaleManager](./docs/managers/shop-flash-sale.md) - Flash sale campaigns
|
|
46
|
+
- [FollowPrizeManager](./docs/managers/follow-prize.md) - Follow prize activities
|
|
47
|
+
- [TopPicksManager](./docs/managers/top-picks.md) - Top picks collections
|
|
48
|
+
- [ShopCategoryManager](./docs/managers/shop-category.md) - Shop category management
|
|
49
|
+
- [ReturnsManager](./docs/managers/returns.md) - Return and refund management
|
|
50
|
+
- [SbsManager](./docs/managers/sbs.md) - Shopee Business Services (SBS) warehouse inventory
|
|
51
|
+
- [FbsManager](./docs/managers/fbs.md) - Fulfillment by Shopee operations
|
|
52
|
+
- [LivestreamManager](./docs/managers/livestream.md) - Live streaming features
|
|
10
53
|
|
|
11
54
|
## Installation
|
|
12
55
|
|
|
13
56
|
```bash
|
|
14
|
-
npm install shopee-sdk
|
|
57
|
+
npm install @congminh1254/shopee-sdk
|
|
15
58
|
```
|
|
16
59
|
|
|
17
|
-
|
|
60
|
+
**Requirements:** Node.js >= 18.0.0
|
|
61
|
+
|
|
62
|
+
### What You Get
|
|
63
|
+
✅ Complete TypeScript definitions for all 27 API managers
|
|
64
|
+
✅ Automatic token refresh and management
|
|
65
|
+
✅ Built-in error handling and retry logic
|
|
66
|
+
✅ Zero dependencies (except node-fetch)
|
|
67
|
+
✅ Full documentation and examples
|
|
68
|
+
|
|
69
|
+
## Quick Start
|
|
70
|
+
|
|
71
|
+
Get up and running in minutes! Here's how easy it is to integrate with Shopee:
|
|
18
72
|
|
|
19
73
|
```typescript
|
|
20
|
-
import {
|
|
74
|
+
import { ShopeeSDK, ShopeeRegion } from '@congminh1254/shopee-sdk';
|
|
21
75
|
|
|
22
|
-
// Initialize the
|
|
23
|
-
const
|
|
76
|
+
// 1. Initialize the SDK with your credentials
|
|
77
|
+
const sdk = new ShopeeSDK({
|
|
24
78
|
partner_id: 123456,
|
|
25
|
-
partner_key:
|
|
26
|
-
|
|
27
|
-
|
|
79
|
+
partner_key: 'your-partner-key',
|
|
80
|
+
region: ShopeeRegion.GLOBAL,
|
|
81
|
+
shop_id: 789012, // Optional for shop-specific operations
|
|
28
82
|
});
|
|
29
83
|
|
|
30
|
-
// Authenticate
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
84
|
+
// 2. Authenticate your shop (OAuth flow)
|
|
85
|
+
const authUrl = sdk.getAuthorizationUrl('https://your-app.com/callback');
|
|
86
|
+
console.log('Visit:', authUrl);
|
|
87
|
+
|
|
88
|
+
// After user authorizes, exchange code for token (automatic token storage!)
|
|
89
|
+
await sdk.authenticateWithCode('auth-code-from-callback');
|
|
90
|
+
|
|
91
|
+
// 3. Start using the API - it's that simple!
|
|
35
92
|
|
|
36
|
-
//
|
|
37
|
-
const products = await
|
|
93
|
+
// Manage your products
|
|
94
|
+
const products = await sdk.product.getItemList({
|
|
38
95
|
offset: 0,
|
|
39
|
-
page_size:
|
|
96
|
+
page_size: 20,
|
|
40
97
|
});
|
|
41
98
|
|
|
42
|
-
//
|
|
43
|
-
const
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
voucher_type: 1, // shop voucher
|
|
49
|
-
reward_type: 1, // fixed amount
|
|
50
|
-
usage_quantity: 100,
|
|
51
|
-
min_basket_price: 20,
|
|
52
|
-
discount_amount: 10,
|
|
99
|
+
// Process orders
|
|
100
|
+
const orders = await sdk.order.getOrderList({
|
|
101
|
+
time_range_field: 'create_time',
|
|
102
|
+
time_from: Math.floor(Date.now() / 1000) - 86400,
|
|
103
|
+
time_to: Math.floor(Date.now() / 1000),
|
|
104
|
+
page_size: 50,
|
|
53
105
|
});
|
|
54
106
|
|
|
55
|
-
//
|
|
56
|
-
const
|
|
57
|
-
|
|
107
|
+
// Track shipments
|
|
108
|
+
const shipping = await sdk.logistics.getShippingParameter({
|
|
109
|
+
order_sn: '220615ABCDEF',
|
|
110
|
+
});
|
|
58
111
|
|
|
59
|
-
|
|
112
|
+
// Handle returns
|
|
113
|
+
const returns = await sdk.returns.getReturnList({
|
|
114
|
+
page_size: 20,
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
// And much more - all with full TypeScript support! 🎉
|
|
118
|
+
```
|
|
60
119
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
120
|
+
**That's it!** The SDK handles token refresh, request signing, error handling, and more automatically.
|
|
121
|
+
|
|
122
|
+
See the [Setup Guide](./docs/guides/setup.md) and [Authentication Guide](./docs/guides/authentication.md) for detailed instructions.
|
|
123
|
+
|
|
124
|
+
## Why Choose This SDK?
|
|
125
|
+
|
|
126
|
+
### 🚀 Production-Ready & Battle-Tested
|
|
127
|
+
- **75%+ test coverage** with 86 comprehensive tests - ensuring reliability in production
|
|
128
|
+
- **Zero compromises** - Every Shopee API endpoint is implemented and documented
|
|
129
|
+
- **Type-safe** - Full TypeScript definitions prevent errors before they happen
|
|
130
|
+
- **Actively maintained** - Regular updates to stay in sync with Shopee API changes
|
|
131
|
+
|
|
132
|
+
### 💪 Complete API Coverage - All 27 Managers Implemented
|
|
133
|
+
Unlike other SDKs with partial coverage, we provide **complete access** to every Shopee API:
|
|
134
|
+
|
|
135
|
+
**Core Commerce:**
|
|
136
|
+
- 📦 **ProductManager** - Full product catalog management with 55+ endpoints
|
|
137
|
+
- 🛒 **OrderManager** - Complete order processing and fulfillment workflow
|
|
138
|
+
- 🚚 **LogisticsManager** - Comprehensive shipping and tracking operations
|
|
139
|
+
- 💳 **PaymentManager** - Payment and escrow information management
|
|
140
|
+
|
|
141
|
+
**Marketing & Promotions:**
|
|
142
|
+
- 🎟️ **VoucherManager** - Discount voucher campaigns
|
|
143
|
+
- 💥 **DiscountManager** - Discount promotion campaigns
|
|
144
|
+
- 🎁 **BundleDealManager** - Bundle deal promotions
|
|
145
|
+
- ➕ **AddOnDealManager** - Add-on deal promotions
|
|
146
|
+
- ⚡ **ShopFlashSaleManager** - Flash sale campaigns
|
|
147
|
+
- 🎯 **FollowPrizeManager** - Follow prize activities
|
|
148
|
+
- ⭐ **TopPicksManager** - Top picks product collections
|
|
149
|
+
|
|
150
|
+
**Store Management:**
|
|
151
|
+
- 🏪 **ShopManager** - Shop information and profile management
|
|
152
|
+
- 🏢 **MerchantManager** - Merchant information, warehouses, and multi-shop management
|
|
153
|
+
- 📂 **ShopCategoryManager** - Shop category organization
|
|
154
|
+
- 🖼️ **MediaManager** & **MediaSpaceManager** - Image and video upload operations
|
|
155
|
+
|
|
156
|
+
**Advanced Features:**
|
|
157
|
+
- 🔐 **AuthManager** - OAuth flow and token lifecycle management
|
|
158
|
+
- 📢 **PushManager** - Webhooks and real-time notifications
|
|
159
|
+
- 🌍 **GlobalProductManager** - Cross-border product management
|
|
160
|
+
- 🔄 **ReturnsManager** - Return and refund request handling
|
|
161
|
+
- 📊 **AdsManager** - Advertising campaign management
|
|
162
|
+
- 📈 **AccountHealthManager** - Performance metrics and analytics
|
|
163
|
+
- 🌐 **PublicManager** - Public API endpoints (no auth required)
|
|
164
|
+
- 📍 **FirstMileManager** - First mile logistics operations
|
|
165
|
+
- 🏭 **SbsManager** - Shopee Business Services warehouse inventory
|
|
166
|
+
- 📦 **FbsManager** - Fulfillment by Shopee operations
|
|
167
|
+
- 📹 **LivestreamManager** - Live streaming features
|
|
168
|
+
|
|
169
|
+
### ✨ Developer Experience First
|
|
170
|
+
- **Intuitive API design** - Clean, consistent interfaces across all managers
|
|
171
|
+
- **Automatic token refresh** - Built-in token management, never worry about expiration
|
|
172
|
+
- **Flexible storage** - File-based storage included, easy to implement custom solutions
|
|
173
|
+
- **Multi-region support** - Works seamlessly across all 12 Shopee regions
|
|
174
|
+
- **Proxy support** - Enterprise-ready HTTP/HTTPS proxy configuration
|
|
175
|
+
- **Comprehensive docs** - Detailed guides and real-world examples for every feature
|
|
176
|
+
- **Full type safety** - Complete TypeScript definitions for autocomplete and error prevention
|
|
177
|
+
|
|
178
|
+
## Real-World Use Cases
|
|
179
|
+
|
|
180
|
+
This SDK is perfect for building:
|
|
181
|
+
|
|
182
|
+
- 🏪 **Multi-channel E-commerce Platforms** - Sync inventory, orders, and products across multiple sales channels
|
|
183
|
+
- 📊 **Analytics Dashboards** - Track sales performance, customer behavior, and business metrics
|
|
184
|
+
- 🤖 **Automation Tools** - Automate order processing, inventory updates, and customer communications
|
|
185
|
+
- 🔄 **ERP Integrations** - Connect Shopee with your existing business systems
|
|
186
|
+
- 📱 **Mobile Apps** - Build native mobile experiences for shop management
|
|
187
|
+
- 🎯 **Marketing Automation** - Manage promotions, vouchers, and advertising campaigns programmatically
|
|
188
|
+
- 📦 **Inventory Management Systems** - Real-time stock tracking across warehouses
|
|
189
|
+
- 🚀 **Custom Storefronts** - Create unique shopping experiences powered by Shopee's infrastructure
|
|
190
|
+
|
|
191
|
+
## Migrating from Other SDKs?
|
|
192
|
+
|
|
193
|
+
Switching is easy! Our SDK offers:
|
|
194
|
+
- **More complete coverage** - Every endpoint is implemented, not just the basics
|
|
195
|
+
- **Better TypeScript support** - Full type safety from end to end
|
|
196
|
+
- **Simpler API** - Intuitive, well-organized manager classes
|
|
197
|
+
- **Active maintenance** - Regular updates and community support
|
|
198
|
+
- **Production-ready** - Battle-tested with comprehensive test coverage
|
|
199
|
+
|
|
200
|
+
Check our [Migration Guide](./docs/guides/setup.md) to get started.
|
|
65
201
|
|
|
66
202
|
## Contributing
|
|
67
203
|
|
package/lib/fetch.js
CHANGED
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
import fetch, { Headers } from "node-fetch";
|
|
2
2
|
import { ShopeeApiError, ShopeeSdkError } from "./errors.js";
|
|
3
3
|
import { generateSignature } from "./utils/signature.js";
|
|
4
|
+
import { readFileSync } from "fs";
|
|
5
|
+
import { fileURLToPath } from "url";
|
|
6
|
+
import { dirname, join } from "path";
|
|
7
|
+
// Read version from package.json
|
|
8
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
9
|
+
const __dirname = dirname(__filename);
|
|
10
|
+
const packageJson = JSON.parse(readFileSync(join(__dirname, "../package.json"), "utf-8"));
|
|
11
|
+
const SDK_VERSION = packageJson.version;
|
|
4
12
|
export class ShopeeFetch {
|
|
5
13
|
static async fetch(config, path, options = {}) {
|
|
6
14
|
const { method = "GET", params = {}, body } = options;
|
|
@@ -53,6 +61,7 @@ export class ShopeeFetch {
|
|
|
53
61
|
// Prepare headers
|
|
54
62
|
const headers = new Headers();
|
|
55
63
|
headers.set("Content-Type", "application/json");
|
|
64
|
+
headers.set("User-Agent", `congminh1254/shopee-sdk/v${SDK_VERSION}`);
|
|
56
65
|
if (options.headers) {
|
|
57
66
|
Object.entries(options.headers).forEach(([key, value]) => {
|
|
58
67
|
headers.set(key, value);
|
|
@@ -95,6 +104,10 @@ export class ShopeeFetch {
|
|
|
95
104
|
}
|
|
96
105
|
catch (error) {
|
|
97
106
|
if (error instanceof Error) {
|
|
107
|
+
// Re-throw our custom errors as-is
|
|
108
|
+
if (error instanceof ShopeeApiError || error instanceof ShopeeSdkError) {
|
|
109
|
+
throw error;
|
|
110
|
+
}
|
|
98
111
|
if (error.name === "FetchError") {
|
|
99
112
|
// Network error
|
|
100
113
|
throw new ShopeeSdkError(`Network error: ${error.message}`);
|
package/lib/fetch.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetch.js","sourceRoot":"","sources":["../src/fetch.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAyB,OAAO,EAAe,MAAM,YAAY,CAAC;AAGhF,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7D,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"fetch.js","sourceRoot":"","sources":["../src/fetch.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAyB,OAAO,EAAe,MAAM,YAAY,CAAC;AAGhF,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7D,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,YAAY,EAAE,MAAM,IAAI,CAAC;AAClC,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AACpC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAErC,iCAAiC;AACjC,MAAM,UAAU,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAClD,MAAM,SAAS,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;AACtC,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,IAAI,CAAC,SAAS,EAAE,iBAAiB,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC;AAC1F,MAAM,WAAW,GAAG,WAAW,CAAC,OAAO,CAAC;AAExC,MAAM,OAAO,WAAW;IACf,MAAM,CAAC,KAAK,CAAC,KAAK,CACvB,MAAoB,EACpB,IAAY,EACZ,UAAwB,EAAE;QAE1B,MAAM,EAAE,MAAM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AI,cAAc,CAAC,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;wBAC1D,CAAC;oBACH,CAAC;oBACD,MAAM,IAAI,cAAc,CAAC,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;gBAC1D,CAAC;gBAED,MAAM,IAAI,GAAG,YAAiB,CAAC;gBAC/B,OAAO,IAAI,CAAC;YACd,CAAC;YACD,MAAM,IAAI,cAAc,CAAC,0BAA0B,YAAY,KAAK,YAAY,EAAE,CAAC,CAAC;QACtF,CAAC;QAAC,OAAO,KAAc,EAAE,CAAC;YACxB,IAAI,KAAK,YAAY,KAAK,EAAE,CAAC;gBAC3B,mCAAmC;gBACnC,IAAI,KAAK,YAAY,cAAc,IAAI,KAAK,YAAY,cAAc,EAAE,CAAC;oBACvE,MAAM,KAAK,CAAC;gBACd,CAAC;gBACD,IAAI,KAAK,CAAC,IAAI,KAAK,YAAY,EAAE,CAAC;oBAChC,gBAAgB;oBAChB,MAAM,IAAI,cAAc,CAAC,kBAAkB,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;gBAC9D,CAAC;gBACD,eAAe;gBACf,MAAM,IAAI,cAAc,CAAC,qBAAqB,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;YACjE,CAAC;YACD,MAAM,IAAI,cAAc,CAAC,wBAAwB,CAAC,CAAC;QACrD,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { ShopeeConfig } from "../sdk.js";
|
|
2
|
+
import { BaseManager } from "./base.manager.js";
|
|
3
|
+
import { AddAddOnDealParams, AddAddOnDealResponse, AddAddOnDealMainItemParams, AddAddOnDealMainItemResponse, AddAddOnDealSubItemParams, AddAddOnDealSubItemResponse, DeleteAddOnDealParams, DeleteAddOnDealResponse, DeleteAddOnDealMainItemParams, DeleteAddOnDealMainItemResponse, DeleteAddOnDealSubItemParams, DeleteAddOnDealSubItemResponse, EndAddOnDealParams, EndAddOnDealResponse, GetAddOnDealParams, GetAddOnDealResponse, GetAddOnDealListParams, GetAddOnDealListResponse, GetAddOnDealMainItemParams, GetAddOnDealMainItemResponse, GetAddOnDealSubItemParams, GetAddOnDealSubItemResponse, UpdateAddOnDealParams, UpdateAddOnDealResponse, UpdateAddOnDealMainItemParams, UpdateAddOnDealMainItemResponse, UpdateAddOnDealSubItemParams, UpdateAddOnDealSubItemResponse } from "../schemas/add-on-deal.js";
|
|
4
|
+
export declare class AddOnDealManager extends BaseManager {
|
|
5
|
+
constructor(config: ShopeeConfig);
|
|
6
|
+
/**
|
|
7
|
+
* Create a new add-on deal activity
|
|
8
|
+
* @param {AddAddOnDealParams} params - Parameters for creating a new add-on deal
|
|
9
|
+
* @returns {Promise<AddAddOnDealResponse>} The response containing the created add-on deal ID
|
|
10
|
+
*
|
|
11
|
+
* Note: A maximum of 1000 add-on deals can be created.
|
|
12
|
+
* The start time must be 1 hour later than current time.
|
|
13
|
+
* The end time must be 1 hour later than start time.
|
|
14
|
+
*/
|
|
15
|
+
addAddOnDeal(params: AddAddOnDealParams): Promise<AddAddOnDealResponse>;
|
|
16
|
+
/**
|
|
17
|
+
* Add main items to an existing add-on deal activity
|
|
18
|
+
* @param {AddAddOnDealMainItemParams} params - Parameters for adding main items to an add-on deal
|
|
19
|
+
* @returns {Promise<AddAddOnDealMainItemResponse>} The response containing the list of added main items
|
|
20
|
+
*
|
|
21
|
+
* Main items are the products that customers must purchase to be eligible for the add-on deal.
|
|
22
|
+
*/
|
|
23
|
+
addAddOnDealMainItem(params: AddAddOnDealMainItemParams): Promise<AddAddOnDealMainItemResponse>;
|
|
24
|
+
/**
|
|
25
|
+
* Add sub items (discounted or gift items) to an existing add-on deal activity
|
|
26
|
+
* @param {AddAddOnDealSubItemParams} params - Parameters for adding sub items to an add-on deal
|
|
27
|
+
* @returns {Promise<AddAddOnDealSubItemResponse>} The response containing any failed sub items
|
|
28
|
+
*
|
|
29
|
+
* Sub items are the products offered at a discount or as gifts when customers purchase main items.
|
|
30
|
+
* The response includes a list of items that failed to be added with error details.
|
|
31
|
+
*/
|
|
32
|
+
addAddOnDealSubItem(params: AddAddOnDealSubItemParams): Promise<AddAddOnDealSubItemResponse>;
|
|
33
|
+
/**
|
|
34
|
+
* Delete an existing add-on deal activity
|
|
35
|
+
* @param {DeleteAddOnDealParams} params - Parameters for deleting an add-on deal
|
|
36
|
+
* @returns {Promise<DeleteAddOnDealResponse>} The response containing the deleted add-on deal ID
|
|
37
|
+
*
|
|
38
|
+
* Note: Can only delete upcoming add-on deals that haven't started yet.
|
|
39
|
+
* Will return an error if attempting to delete an add-on deal that has already started.
|
|
40
|
+
*/
|
|
41
|
+
deleteAddOnDeal(params: DeleteAddOnDealParams): Promise<DeleteAddOnDealResponse>;
|
|
42
|
+
/**
|
|
43
|
+
* Delete main items from an existing add-on deal activity
|
|
44
|
+
* @param {DeleteAddOnDealMainItemParams} params - Parameters for deleting main items from an add-on deal
|
|
45
|
+
* @returns {Promise<DeleteAddOnDealMainItemResponse>} The response containing any failed item deletions
|
|
46
|
+
*
|
|
47
|
+
* The response includes:
|
|
48
|
+
* - add_on_deal_id: The ID of the add-on deal
|
|
49
|
+
* - failed_item_id_list: List of item IDs that failed to be deleted
|
|
50
|
+
*/
|
|
51
|
+
deleteAddOnDealMainItem(params: DeleteAddOnDealMainItemParams): Promise<DeleteAddOnDealMainItemResponse>;
|
|
52
|
+
/**
|
|
53
|
+
* Delete sub items from an existing add-on deal activity
|
|
54
|
+
* @param {DeleteAddOnDealSubItemParams} params - Parameters for deleting sub items from an add-on deal
|
|
55
|
+
* @returns {Promise<DeleteAddOnDealSubItemResponse>} The response containing any failed sub item deletions
|
|
56
|
+
*
|
|
57
|
+
* The response includes a list of sub items that failed to be deleted with error details.
|
|
58
|
+
* Note: At least one sub item should remain in the add-on deal.
|
|
59
|
+
*/
|
|
60
|
+
deleteAddOnDealSubItem(params: DeleteAddOnDealSubItemParams): Promise<DeleteAddOnDealSubItemResponse>;
|
|
61
|
+
/**
|
|
62
|
+
* End an ongoing add-on deal activity immediately
|
|
63
|
+
* @param {EndAddOnDealParams} params - Parameters for ending an add-on deal
|
|
64
|
+
* @returns {Promise<EndAddOnDealResponse>} The response containing the ended add-on deal ID
|
|
65
|
+
*
|
|
66
|
+
* Note: Can only end add-on deals that are currently ongoing/active.
|
|
67
|
+
* Will return an error if attempting to end an upcoming or expired add-on deal.
|
|
68
|
+
*/
|
|
69
|
+
endAddOnDeal(params: EndAddOnDealParams): Promise<EndAddOnDealResponse>;
|
|
70
|
+
/**
|
|
71
|
+
* Get detailed information about an add-on deal activity
|
|
72
|
+
* @param {GetAddOnDealParams} params - Parameters for getting add-on deal details
|
|
73
|
+
* @returns {Promise<GetAddOnDealResponse>} The response containing comprehensive add-on deal information
|
|
74
|
+
*
|
|
75
|
+
* The response includes:
|
|
76
|
+
* - Basic add-on deal details (ID, name, start/end time, etc.)
|
|
77
|
+
* - Promotion type and configuration
|
|
78
|
+
* - Purchase limits and requirements
|
|
79
|
+
* - Sub item display priority
|
|
80
|
+
* - Source information
|
|
81
|
+
*/
|
|
82
|
+
getAddOnDeal(params: GetAddOnDealParams): Promise<GetAddOnDealResponse>;
|
|
83
|
+
/**
|
|
84
|
+
* Get a list of add-on deal activities with pagination
|
|
85
|
+
* @param {GetAddOnDealListParams} params - Parameters for retrieving add-on deal list
|
|
86
|
+
* @param {AddOnDealPromotionStatus} params.promotion_status - Filter by promotion status (all, ongoing, upcoming, expired)
|
|
87
|
+
* @param {number} [params.page_no] - Page number to retrieve (default: 1, max: 1000)
|
|
88
|
+
* @param {number} [params.page_size] - Number of items per page (default: 100, max: 100)
|
|
89
|
+
* @returns {Promise<GetAddOnDealListResponse>} The response containing a paginated list of add-on deals
|
|
90
|
+
*
|
|
91
|
+
* The response includes:
|
|
92
|
+
* - add_on_deal_list: List of add-on deals with full details
|
|
93
|
+
* - more: Boolean indicating if there are more pages
|
|
94
|
+
*/
|
|
95
|
+
getAddOnDealList(params: GetAddOnDealListParams): Promise<GetAddOnDealListResponse>;
|
|
96
|
+
/**
|
|
97
|
+
* Get main items in an add-on deal activity
|
|
98
|
+
* @param {GetAddOnDealMainItemParams} params - Parameters for getting main items
|
|
99
|
+
* @returns {Promise<GetAddOnDealMainItemResponse>} The response containing the list of main items
|
|
100
|
+
*
|
|
101
|
+
* Main items are the products that customers must purchase to be eligible for the add-on deal.
|
|
102
|
+
*/
|
|
103
|
+
getAddOnDealMainItem(params: GetAddOnDealMainItemParams): Promise<GetAddOnDealMainItemResponse>;
|
|
104
|
+
/**
|
|
105
|
+
* Get sub items (discounted or gift items) in an add-on deal activity
|
|
106
|
+
* @param {GetAddOnDealSubItemParams} params - Parameters for getting sub items
|
|
107
|
+
* @returns {Promise<GetAddOnDealSubItemResponse>} The response containing the list of sub items
|
|
108
|
+
*
|
|
109
|
+
* Sub items are the products offered at a discount or as gifts when customers purchase main items.
|
|
110
|
+
*/
|
|
111
|
+
getAddOnDealSubItem(params: GetAddOnDealSubItemParams): Promise<GetAddOnDealSubItemResponse>;
|
|
112
|
+
/**
|
|
113
|
+
* Update an existing add-on deal activity
|
|
114
|
+
* @param {UpdateAddOnDealParams} params - Parameters for updating an add-on deal
|
|
115
|
+
* @returns {Promise<UpdateAddOnDealResponse>} The response containing the updated add-on deal information
|
|
116
|
+
*
|
|
117
|
+
* Note: For ongoing add-on deals, update capabilities may be limited.
|
|
118
|
+
* Only certain fields can be modified depending on the add-on deal status.
|
|
119
|
+
* The start time of upcoming add-on deals cannot be shortened.
|
|
120
|
+
* Promotion end time can only be changed to an earlier timing.
|
|
121
|
+
*/
|
|
122
|
+
updateAddOnDeal(params: UpdateAddOnDealParams): Promise<UpdateAddOnDealResponse>;
|
|
123
|
+
/**
|
|
124
|
+
* Update main items in an existing add-on deal activity
|
|
125
|
+
* @param {UpdateAddOnDealMainItemParams} params - Parameters for updating main items
|
|
126
|
+
* @returns {Promise<UpdateAddOnDealMainItemResponse>} The response containing the updated main items
|
|
127
|
+
*
|
|
128
|
+
* Main items are the products that customers must purchase to be eligible for the add-on deal.
|
|
129
|
+
*/
|
|
130
|
+
updateAddOnDealMainItem(params: UpdateAddOnDealMainItemParams): Promise<UpdateAddOnDealMainItemResponse>;
|
|
131
|
+
/**
|
|
132
|
+
* Update sub items in an existing add-on deal activity
|
|
133
|
+
* @param {UpdateAddOnDealSubItemParams} params - Parameters for updating sub items
|
|
134
|
+
* @returns {Promise<UpdateAddOnDealSubItemResponse>} The response containing any failed sub item updates
|
|
135
|
+
*
|
|
136
|
+
* Sub items are the products offered at a discount or as gifts when customers purchase main items.
|
|
137
|
+
* The response includes a list of sub items that failed to be updated with error details.
|
|
138
|
+
*/
|
|
139
|
+
updateAddOnDealSubItem(params: UpdateAddOnDealSubItemParams): Promise<UpdateAddOnDealSubItemResponse>;
|
|
140
|
+
}
|