perspectapi-ts-sdk 3.2.0 → 3.3.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/dist/index.d.mts +23 -4
- package/dist/index.d.ts +23 -4
- package/dist/index.js +16 -6
- package/dist/index.mjs +16 -6
- package/package.json +1 -1
- package/src/client/products-client.ts +16 -6
- package/src/types/index.ts +10 -1
package/dist/index.d.mts
CHANGED
|
@@ -355,11 +355,23 @@ interface Product {
|
|
|
355
355
|
[key: string]: any;
|
|
356
356
|
}
|
|
357
357
|
interface CreateProductRequest {
|
|
358
|
-
|
|
358
|
+
product: string;
|
|
359
|
+
name?: string;
|
|
359
360
|
description?: string;
|
|
361
|
+
excerpt?: string;
|
|
360
362
|
price: number;
|
|
363
|
+
unit_amount: number;
|
|
361
364
|
currency?: string;
|
|
362
365
|
sku?: string;
|
|
366
|
+
slug?: string;
|
|
367
|
+
slug_prefix?: string;
|
|
368
|
+
published?: boolean;
|
|
369
|
+
custom?: Record<string, any>;
|
|
370
|
+
recurring?: {
|
|
371
|
+
interval: "day" | "week" | "month" | "year";
|
|
372
|
+
interval_count?: number;
|
|
373
|
+
};
|
|
374
|
+
stock_quantity?: number | null;
|
|
363
375
|
isActive?: boolean;
|
|
364
376
|
}
|
|
365
377
|
interface ProductQueryParams extends PaginationParams {
|
|
@@ -1244,16 +1256,23 @@ declare class ProductsClient extends BaseClient {
|
|
|
1244
1256
|
}>>;
|
|
1245
1257
|
/**
|
|
1246
1258
|
* Create new product
|
|
1259
|
+
* @param siteName - The site name
|
|
1260
|
+
* @param data - Product data
|
|
1247
1261
|
*/
|
|
1248
|
-
createProduct(data: CreateProductRequest): Promise<ApiResponse<Product>>;
|
|
1262
|
+
createProduct(siteName: string, data: CreateProductRequest): Promise<ApiResponse<Product>>;
|
|
1249
1263
|
/**
|
|
1250
1264
|
* Update product
|
|
1265
|
+
* @param siteName - The site name
|
|
1266
|
+
* @param id - Product ID
|
|
1267
|
+
* @param data - Fields to update
|
|
1251
1268
|
*/
|
|
1252
|
-
updateProduct(id: number, data: Partial<CreateProductRequest>): Promise<ApiResponse<Product>>;
|
|
1269
|
+
updateProduct(siteName: string, id: number, data: Partial<CreateProductRequest>): Promise<ApiResponse<Product>>;
|
|
1253
1270
|
/**
|
|
1254
1271
|
* Delete product
|
|
1272
|
+
* @param siteName - The site name
|
|
1273
|
+
* @param id - Product ID
|
|
1255
1274
|
*/
|
|
1256
|
-
deleteProduct(id: number): Promise<ApiResponse<{
|
|
1275
|
+
deleteProduct(siteName: string, id: number): Promise<ApiResponse<{
|
|
1257
1276
|
message: string;
|
|
1258
1277
|
}>>;
|
|
1259
1278
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -355,11 +355,23 @@ interface Product {
|
|
|
355
355
|
[key: string]: any;
|
|
356
356
|
}
|
|
357
357
|
interface CreateProductRequest {
|
|
358
|
-
|
|
358
|
+
product: string;
|
|
359
|
+
name?: string;
|
|
359
360
|
description?: string;
|
|
361
|
+
excerpt?: string;
|
|
360
362
|
price: number;
|
|
363
|
+
unit_amount: number;
|
|
361
364
|
currency?: string;
|
|
362
365
|
sku?: string;
|
|
366
|
+
slug?: string;
|
|
367
|
+
slug_prefix?: string;
|
|
368
|
+
published?: boolean;
|
|
369
|
+
custom?: Record<string, any>;
|
|
370
|
+
recurring?: {
|
|
371
|
+
interval: "day" | "week" | "month" | "year";
|
|
372
|
+
interval_count?: number;
|
|
373
|
+
};
|
|
374
|
+
stock_quantity?: number | null;
|
|
363
375
|
isActive?: boolean;
|
|
364
376
|
}
|
|
365
377
|
interface ProductQueryParams extends PaginationParams {
|
|
@@ -1244,16 +1256,23 @@ declare class ProductsClient extends BaseClient {
|
|
|
1244
1256
|
}>>;
|
|
1245
1257
|
/**
|
|
1246
1258
|
* Create new product
|
|
1259
|
+
* @param siteName - The site name
|
|
1260
|
+
* @param data - Product data
|
|
1247
1261
|
*/
|
|
1248
|
-
createProduct(data: CreateProductRequest): Promise<ApiResponse<Product>>;
|
|
1262
|
+
createProduct(siteName: string, data: CreateProductRequest): Promise<ApiResponse<Product>>;
|
|
1249
1263
|
/**
|
|
1250
1264
|
* Update product
|
|
1265
|
+
* @param siteName - The site name
|
|
1266
|
+
* @param id - Product ID
|
|
1267
|
+
* @param data - Fields to update
|
|
1251
1268
|
*/
|
|
1252
|
-
updateProduct(id: number, data: Partial<CreateProductRequest>): Promise<ApiResponse<Product>>;
|
|
1269
|
+
updateProduct(siteName: string, id: number, data: Partial<CreateProductRequest>): Promise<ApiResponse<Product>>;
|
|
1253
1270
|
/**
|
|
1254
1271
|
* Delete product
|
|
1272
|
+
* @param siteName - The site name
|
|
1273
|
+
* @param id - Product ID
|
|
1255
1274
|
*/
|
|
1256
|
-
deleteProduct(id: number): Promise<ApiResponse<{
|
|
1275
|
+
deleteProduct(siteName: string, id: number): Promise<ApiResponse<{
|
|
1257
1276
|
message: string;
|
|
1258
1277
|
}>>;
|
|
1259
1278
|
/**
|
package/dist/index.js
CHANGED
|
@@ -1356,21 +1356,31 @@ var ProductsClient = class extends BaseClient {
|
|
|
1356
1356
|
}
|
|
1357
1357
|
/**
|
|
1358
1358
|
* Create new product
|
|
1359
|
+
* @param siteName - The site name
|
|
1360
|
+
* @param data - Product data
|
|
1359
1361
|
*/
|
|
1360
|
-
async createProduct(data) {
|
|
1361
|
-
|
|
1362
|
+
async createProduct(siteName, data) {
|
|
1363
|
+
const endpoint = this.siteScopedEndpoint(siteName, "/products", { includeSitesSegment: false });
|
|
1364
|
+
return this.create(endpoint, data);
|
|
1362
1365
|
}
|
|
1363
1366
|
/**
|
|
1364
1367
|
* Update product
|
|
1368
|
+
* @param siteName - The site name
|
|
1369
|
+
* @param id - Product ID
|
|
1370
|
+
* @param data - Fields to update
|
|
1365
1371
|
*/
|
|
1366
|
-
async updateProduct(id, data) {
|
|
1367
|
-
|
|
1372
|
+
async updateProduct(siteName, id, data) {
|
|
1373
|
+
const endpoint = this.siteScopedEndpoint(siteName, `/products/${id}`, { includeSitesSegment: false });
|
|
1374
|
+
return this.update(endpoint, data);
|
|
1368
1375
|
}
|
|
1369
1376
|
/**
|
|
1370
1377
|
* Delete product
|
|
1378
|
+
* @param siteName - The site name
|
|
1379
|
+
* @param id - Product ID
|
|
1371
1380
|
*/
|
|
1372
|
-
async deleteProduct(id) {
|
|
1373
|
-
|
|
1381
|
+
async deleteProduct(siteName, id) {
|
|
1382
|
+
const endpoint = this.siteScopedEndpoint(siteName, `/products/${id}`, { includeSitesSegment: false });
|
|
1383
|
+
return this.delete(endpoint);
|
|
1374
1384
|
}
|
|
1375
1385
|
/**
|
|
1376
1386
|
* Activate product
|
package/dist/index.mjs
CHANGED
|
@@ -1293,21 +1293,31 @@ var ProductsClient = class extends BaseClient {
|
|
|
1293
1293
|
}
|
|
1294
1294
|
/**
|
|
1295
1295
|
* Create new product
|
|
1296
|
+
* @param siteName - The site name
|
|
1297
|
+
* @param data - Product data
|
|
1296
1298
|
*/
|
|
1297
|
-
async createProduct(data) {
|
|
1298
|
-
|
|
1299
|
+
async createProduct(siteName, data) {
|
|
1300
|
+
const endpoint = this.siteScopedEndpoint(siteName, "/products", { includeSitesSegment: false });
|
|
1301
|
+
return this.create(endpoint, data);
|
|
1299
1302
|
}
|
|
1300
1303
|
/**
|
|
1301
1304
|
* Update product
|
|
1305
|
+
* @param siteName - The site name
|
|
1306
|
+
* @param id - Product ID
|
|
1307
|
+
* @param data - Fields to update
|
|
1302
1308
|
*/
|
|
1303
|
-
async updateProduct(id, data) {
|
|
1304
|
-
|
|
1309
|
+
async updateProduct(siteName, id, data) {
|
|
1310
|
+
const endpoint = this.siteScopedEndpoint(siteName, `/products/${id}`, { includeSitesSegment: false });
|
|
1311
|
+
return this.update(endpoint, data);
|
|
1305
1312
|
}
|
|
1306
1313
|
/**
|
|
1307
1314
|
* Delete product
|
|
1315
|
+
* @param siteName - The site name
|
|
1316
|
+
* @param id - Product ID
|
|
1308
1317
|
*/
|
|
1309
|
-
async deleteProduct(id) {
|
|
1310
|
-
|
|
1318
|
+
async deleteProduct(siteName, id) {
|
|
1319
|
+
const endpoint = this.siteScopedEndpoint(siteName, `/products/${id}`, { includeSitesSegment: false });
|
|
1320
|
+
return this.delete(endpoint);
|
|
1311
1321
|
}
|
|
1312
1322
|
/**
|
|
1313
1323
|
* Activate product
|
package/package.json
CHANGED
|
@@ -138,23 +138,33 @@ export class ProductsClient extends BaseClient {
|
|
|
138
138
|
|
|
139
139
|
/**
|
|
140
140
|
* Create new product
|
|
141
|
+
* @param siteName - The site name
|
|
142
|
+
* @param data - Product data
|
|
141
143
|
*/
|
|
142
|
-
async createProduct(data: CreateProductRequest): Promise<ApiResponse<Product>> {
|
|
143
|
-
|
|
144
|
+
async createProduct(siteName: string, data: CreateProductRequest): Promise<ApiResponse<Product>> {
|
|
145
|
+
const endpoint = this.siteScopedEndpoint(siteName, '/products', { includeSitesSegment: false });
|
|
146
|
+
return this.create<CreateProductRequest, Product>(endpoint, data);
|
|
144
147
|
}
|
|
145
148
|
|
|
146
149
|
/**
|
|
147
150
|
* Update product
|
|
151
|
+
* @param siteName - The site name
|
|
152
|
+
* @param id - Product ID
|
|
153
|
+
* @param data - Fields to update
|
|
148
154
|
*/
|
|
149
|
-
async updateProduct(id: number, data: Partial<CreateProductRequest>): Promise<ApiResponse<Product>> {
|
|
150
|
-
|
|
155
|
+
async updateProduct(siteName: string, id: number, data: Partial<CreateProductRequest>): Promise<ApiResponse<Product>> {
|
|
156
|
+
const endpoint = this.siteScopedEndpoint(siteName, `/products/${id}`, { includeSitesSegment: false });
|
|
157
|
+
return this.update<Partial<CreateProductRequest>, Product>(endpoint, data);
|
|
151
158
|
}
|
|
152
159
|
|
|
153
160
|
/**
|
|
154
161
|
* Delete product
|
|
162
|
+
* @param siteName - The site name
|
|
163
|
+
* @param id - Product ID
|
|
155
164
|
*/
|
|
156
|
-
async deleteProduct(id: number): Promise<ApiResponse<{ message: string }>> {
|
|
157
|
-
|
|
165
|
+
async deleteProduct(siteName: string, id: number): Promise<ApiResponse<{ message: string }>> {
|
|
166
|
+
const endpoint = this.siteScopedEndpoint(siteName, `/products/${id}`, { includeSitesSegment: false });
|
|
167
|
+
return this.delete<{ message: string }>(endpoint);
|
|
158
168
|
}
|
|
159
169
|
|
|
160
170
|
/**
|
package/src/types/index.ts
CHANGED
|
@@ -314,11 +314,20 @@ export interface Product {
|
|
|
314
314
|
}
|
|
315
315
|
|
|
316
316
|
export interface CreateProductRequest {
|
|
317
|
-
|
|
317
|
+
product: string;
|
|
318
|
+
name?: string;
|
|
318
319
|
description?: string;
|
|
320
|
+
excerpt?: string;
|
|
319
321
|
price: number;
|
|
322
|
+
unit_amount: number;
|
|
320
323
|
currency?: string;
|
|
321
324
|
sku?: string;
|
|
325
|
+
slug?: string;
|
|
326
|
+
slug_prefix?: string;
|
|
327
|
+
published?: boolean;
|
|
328
|
+
custom?: Record<string, any>;
|
|
329
|
+
recurring?: { interval: "day" | "week" | "month" | "year"; interval_count?: number };
|
|
330
|
+
stock_quantity?: number | null;
|
|
322
331
|
isActive?: boolean;
|
|
323
332
|
}
|
|
324
333
|
|