polyv-live-api-sdk 1.0.5 → 1.0.9

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 ADDED
@@ -0,0 +1,186 @@
1
+ # PolyV Live API SDK
2
+
3
+ TypeScript/Node.js SDK for PolyV Live Streaming API.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install polyv-live-api-sdk
9
+ # or
10
+ pnpm add polyv-live-api-sdk
11
+ # or
12
+ yarn add polyv-live-api-sdk
13
+ ```
14
+
15
+ ## Quick Start
16
+
17
+ ```typescript
18
+ import { PolyVClient } from 'polyv-live-api-sdk';
19
+
20
+ const client = new PolyVClient({
21
+ appId: 'your-app-id',
22
+ appSecret: 'your-app-secret'
23
+ });
24
+
25
+ // List channels
26
+ const channels = await client.channel.listChannels({ pageNumber: 1, pageSize: 10 });
27
+
28
+ // Get channel details
29
+ const channel = await client.channel.getChannel({ channelId: 'your-channel-id' });
30
+ ```
31
+
32
+ ## Features
33
+
34
+ - Full TypeScript support with type definitions
35
+ - Automatic API signature generation
36
+ - Promise-based API
37
+ - Comprehensive error handling
38
+ - Support for both V3 and V4 APIs
39
+
40
+ ## Services
41
+
42
+ ### V3 Services
43
+
44
+ | Service | Description |
45
+ |---------|-------------|
46
+ | `channel` | Channel management (CRUD, settings, streams) |
47
+ | `chat` | Chat operations (messages, bans, kicks) |
48
+ | `account` | Account operations |
49
+ | `group` | Group management |
50
+ | `platform` | Platform operations |
51
+ | `finance` | Financial operations |
52
+ | `web` | Web settings |
53
+ | `player` | Player configuration |
54
+ | `liveInteraction` | Live interactions (check-in, lottery, Q&A) |
55
+ | `statistics` | Statistics and reports |
56
+
57
+ ### V4 Services
58
+
59
+ | Service | Description |
60
+ |---------|-------------|
61
+ | `v4Platform` | Coupon management |
62
+ | `v4Channel` | V4 channel APIs |
63
+ | `v4Chat` | V4 chat APIs |
64
+ | `v4User` | User management |
65
+ | `v4Group` | V4 group APIs |
66
+ | `v4AI` | AI features |
67
+ | `v4Robot` | Robot features |
68
+ | `v4Material` | Materials management |
69
+ | `v4Statistics` | V4 statistics |
70
+ | `v4WebApp` | WebApp settings |
71
+ | `v4Global` | Global settings |
72
+
73
+ ## Usage Examples
74
+
75
+ ### Channel Management
76
+
77
+ ```typescript
78
+ // Create a channel
79
+ const newChannel = await client.channel.createChannel({
80
+ name: 'My Live Channel',
81
+ channelPass: 'password123'
82
+ });
83
+
84
+ // List channels with pagination
85
+ const result = await client.channel.listChannels({
86
+ pageNumber: 1,
87
+ pageSize: 20
88
+ });
89
+
90
+ // Update channel
91
+ await client.channel.updateChannel({
92
+ channelId: 'xxx',
93
+ name: 'Updated Name'
94
+ });
95
+ ```
96
+
97
+ ### Coupon Operations (V4)
98
+
99
+ ```typescript
100
+ // Create a coupon
101
+ const couponId = await client.v4Platform.createCoupon({
102
+ name: 'Discount Coupon',
103
+ discount: 100,
104
+ total: 1000
105
+ });
106
+
107
+ // Search coupons
108
+ const coupons = await client.v4Platform.searchCoupons({
109
+ pageNumber: 1,
110
+ pageSize: 10
111
+ });
112
+ ```
113
+
114
+ ### Product Management
115
+
116
+ ```typescript
117
+ // Get product list
118
+ const products = await client.channel.getProductList({
119
+ channelId: 'your-channel-id'
120
+ });
121
+
122
+ // Add product
123
+ const product = await client.channel.addProduct({
124
+ channelId: 'your-channel-id',
125
+ name: 'Product Name',
126
+ price: '99.00'
127
+ });
128
+ ```
129
+
130
+ ### Statistics
131
+
132
+ ```typescript
133
+ // Get channel statistics
134
+ const stats = await client.statistics.getChannelStats({
135
+ channelId: 'your-channel-id',
136
+ startDate: '2024-01-01',
137
+ endDate: '2024-01-31'
138
+ });
139
+ ```
140
+
141
+ ### Error Handling
142
+
143
+ ```typescript
144
+ import { PolyVAPIError, PolyVErrorCode } from 'polyv-live-api-sdk';
145
+
146
+ try {
147
+ await client.channel.getChannel({ channelId: 'invalid-id' });
148
+ } catch (error) {
149
+ if (error instanceof PolyVAPIError) {
150
+ console.log('Error code:', error.code);
151
+ console.log('Error message:', error.message);
152
+ }
153
+ }
154
+ ```
155
+
156
+ ## Pagination Utilities
157
+
158
+ ```typescript
159
+ import { paginate, collectAll } from 'polyv-live-api-sdk';
160
+
161
+ // Auto-paginate through all results
162
+ const allChannels = await collectAll(
163
+ (page) => client.channel.listChannels({ pageNumber: page, pageSize: 100 }),
164
+ (response) => response.contents
165
+ );
166
+ ```
167
+
168
+ ## Configuration Options
169
+
170
+ ```typescript
171
+ const client = new PolyVClient({
172
+ appId: 'your-app-id',
173
+ appSecret: 'your-app-secret',
174
+ userId: 'your-user-id', // Optional
175
+ timeout: 30000, // Request timeout in ms (default: 30000)
176
+ baseURL: 'https://api.polyv.net' // Custom base URL (optional)
177
+ });
178
+ ```
179
+
180
+ ## Requirements
181
+
182
+ - Node.js >= 18.0.0
183
+
184
+ ## License
185
+
186
+ MIT
package/dist/index.cjs CHANGED
@@ -4356,6 +4356,74 @@ var ChannelService = class {
4356
4356
  );
4357
4357
  return response;
4358
4358
  }
4359
+ /**
4360
+ * Update channel product library enabled status
4361
+ *
4362
+ * Toggles the channel product library on or off.
4363
+ * All params (channelId, enabled, appId, timestamp) participate in signature.
4364
+ *
4365
+ * @param params - Parameters including channelId and enabled (Y/N)
4366
+ * @returns true if update was successful
4367
+ * @throws PolyVValidationError if required parameters are missing
4368
+ *
4369
+ * @example
4370
+ * ```typescript
4371
+ * await channelService.updateChannelProductEnabled({
4372
+ * channelId: 'ch123456',
4373
+ * enabled: 'Y',
4374
+ * });
4375
+ * ```
4376
+ */
4377
+ async updateChannelProductEnabled(params) {
4378
+ if (!params.channelId || params.channelId.trim() === "") {
4379
+ throw PolyVValidationError.required("channelId");
4380
+ }
4381
+ if (!params.enabled || params.enabled !== "Y" && params.enabled !== "N") {
4382
+ throw PolyVValidationError.required("enabled");
4383
+ }
4384
+ const response = await this.client.httpClient.post(
4385
+ "/live/v3/channel/product/update-enabled",
4386
+ null,
4387
+ { params: { channelId: params.channelId, enabled: params.enabled } }
4388
+ );
4389
+ return response;
4390
+ }
4391
+ /**
4392
+ * Update channel configuration
4393
+ *
4394
+ * Updates a channel config key-value pair via /v3/channel/config/update.
4395
+ * Common keys include: couponEnabled, productEnabled, etc.
4396
+ *
4397
+ * @param params - Parameters including channelId, key, and value
4398
+ * @returns true if update was successful
4399
+ * @throws PolyVValidationError if required parameters are missing
4400
+ *
4401
+ * @example
4402
+ * ```typescript
4403
+ * await channelService.updateChannelConfig({
4404
+ * channelId: 'ch123456',
4405
+ * key: 'couponEnabled',
4406
+ * value: 'Y',
4407
+ * });
4408
+ * ```
4409
+ */
4410
+ async updateChannelConfig(params) {
4411
+ if (!params.channelId || params.channelId.trim() === "") {
4412
+ throw PolyVValidationError.required("channelId");
4413
+ }
4414
+ if (!params.key || params.key.trim() === "") {
4415
+ throw PolyVValidationError.required("key");
4416
+ }
4417
+ if (!params.value || params.value.trim() === "") {
4418
+ throw PolyVValidationError.required("value");
4419
+ }
4420
+ const response = await this.client.httpClient.post(
4421
+ "/live/v3/channel/config/update",
4422
+ null,
4423
+ { params: { channelId: params.channelId, key: params.key, value: params.value } }
4424
+ );
4425
+ return response;
4426
+ }
4359
4427
  };
4360
4428
 
4361
4429
  // src/services/chat.service.ts
@@ -5292,6 +5360,9 @@ var LiveInteractionService = class {
5292
5360
  * ```
5293
5361
  */
5294
5362
  async getCheckinList(params) {
5363
+ if (!params.channelId) {
5364
+ throw new Error("channelId is required");
5365
+ }
5295
5366
  const response = await this.client.httpClient.get(
5296
5367
  "/live/v2/chat/getCheckinList",
5297
5368
  { params }