@cshah18/sdk 4.11.0 → 4.13.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/cobuy-sdk.esm.js +111 -0
- package/dist/cobuy-sdk.esm.js.map +1 -1
- package/dist/cobuy-sdk.umd.js +111 -0
- package/dist/cobuy-sdk.umd.js.map +1 -1
- package/dist/types/core/api-client.d.ts +31 -1
- package/dist/types/core/cobuy.d.ts +27 -1
- package/dist/types/core/endpoints.d.ts +1 -0
- package/dist/types/core/types.d.ts +42 -0
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ApiRequestOptions, ApiResponse, ApiClientConfig, ProductRewardData, ProductPrimaryGroupData, GroupJoinResponseData, GroupInviteResponseData, AuthStrategy, ShareChannel, Contact, CheckoutValidationData, CheckoutConfirmData } from "./types";
|
|
1
|
+
import { ApiRequestOptions, ApiResponse, ApiClientConfig, ProductRewardData, ProductPrimaryGroupData, GroupJoinResponseData, GroupInviteResponseData, InviteResolveResponseData, AuthStrategy, ShareChannel, Contact, CheckoutValidationData, CheckoutConfirmData } from "./types";
|
|
2
2
|
/**
|
|
3
3
|
* HTTP client for communicating with CoBuy API
|
|
4
4
|
*
|
|
@@ -367,6 +367,36 @@ export declare class ApiClient {
|
|
|
367
367
|
* ```
|
|
368
368
|
*/
|
|
369
369
|
inviteToGroup(groupId: string, sharedVia: ShareChannel): Promise<ApiResponse<GroupInviteResponseData>>;
|
|
370
|
+
/**
|
|
371
|
+
* Resolve an invite token to get product and group information
|
|
372
|
+
*
|
|
373
|
+
* Resolves an invite link token (e.g., from https://brand.cobuyza.co.za/i/QMeHD7ew)
|
|
374
|
+
* to get the associated product, group, and invite metadata.
|
|
375
|
+
*
|
|
376
|
+
* @param {string} inviteToken - The invite token from the URL
|
|
377
|
+
* @returns {Promise<ApiResponse<InviteResolveResponseData>>} Product and group information
|
|
378
|
+
*
|
|
379
|
+
* @description
|
|
380
|
+
* Features:
|
|
381
|
+
* - Resolves invite tokens to product/group details
|
|
382
|
+
* - Tracks invite click counts
|
|
383
|
+
* - Returns invite metadata (shared_via, click_count)
|
|
384
|
+
* - Used for invite link handling in applications
|
|
385
|
+
*
|
|
386
|
+
* @example
|
|
387
|
+
* ```typescript
|
|
388
|
+
* // Resolve invite token from URL
|
|
389
|
+
* const response = await client.resolveInvite('QMeHD7ew');
|
|
390
|
+
*
|
|
391
|
+
* if (response.success) {
|
|
392
|
+
* const productId = response.data.product.id;
|
|
393
|
+
* const groupId = response.data.group.id;
|
|
394
|
+
* // Navigate to product page
|
|
395
|
+
* window.location.href = `/product/${productId}`;
|
|
396
|
+
* }
|
|
397
|
+
* ```
|
|
398
|
+
*/
|
|
399
|
+
resolveInvite(inviteToken: string): Promise<ApiResponse<InviteResolveResponseData>>;
|
|
370
400
|
/**
|
|
371
401
|
* Set or update contact information for the current session
|
|
372
402
|
*
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CoBuySDK, CoBuyInitOptions, RenderWidgetOptions, ModalOptions, Contact, CheckoutValidationData, CheckoutConfirmData } from "./types";
|
|
1
|
+
import { CoBuySDK, CoBuyInitOptions, RenderWidgetOptions, ModalOptions, Contact, CheckoutValidationData, CheckoutConfirmData, InviteResolveResponseData } from "./types";
|
|
2
2
|
import { ApiClient } from "./api-client";
|
|
3
3
|
import { AnalyticsClient } from "./analytics";
|
|
4
4
|
import { SocketManager } from "./socket";
|
|
@@ -246,6 +246,32 @@ export declare class CoBuy implements CoBuySDK {
|
|
|
246
246
|
* ```
|
|
247
247
|
*/
|
|
248
248
|
setContact(contact: Contact): Promise<void>;
|
|
249
|
+
/**
|
|
250
|
+
* Resolve an invite token to get product and group information
|
|
251
|
+
*
|
|
252
|
+
* Resolves an invite link token (e.g., from https://brand.cobuyza.co.za/i/QMeHD7ew)
|
|
253
|
+
* to get the associated product, group, and invite metadata. Use this to handle
|
|
254
|
+
* invite links in your application routing.
|
|
255
|
+
*
|
|
256
|
+
* @param inviteToken - The invite token from the URL
|
|
257
|
+
* @returns Promise with invite resolution data or null if failed
|
|
258
|
+
*
|
|
259
|
+
* @example
|
|
260
|
+
* ```typescript
|
|
261
|
+
* // Extract token from URL path like /i/QMeHD7ew
|
|
262
|
+
* const pathParts = window.location.pathname.split('/i/');
|
|
263
|
+
* if (pathParts.length > 1) {
|
|
264
|
+
* const inviteToken = pathParts[1];
|
|
265
|
+
* const inviteData = await CoBuy.resolveInvite(inviteToken);
|
|
266
|
+
*
|
|
267
|
+
* if (inviteData) {
|
|
268
|
+
* // Navigate to product page
|
|
269
|
+
* window.location.href = `/product/${inviteData.product.id}`;
|
|
270
|
+
* }
|
|
271
|
+
* }
|
|
272
|
+
* ```
|
|
273
|
+
*/
|
|
274
|
+
resolveInvite(inviteToken: string): Promise<InviteResolveResponseData | null>;
|
|
249
275
|
/**
|
|
250
276
|
* Validate checkout for a group
|
|
251
277
|
*
|
|
@@ -11,6 +11,7 @@ export declare const API_ENDPOINTS: {
|
|
|
11
11
|
readonly GROUP_CHECKOUT_PREPARE: "/v1/sdk/groups/:groupId/checkout/prepare";
|
|
12
12
|
readonly GROUP_CHECKOUT_VALIDATE: "/v1/sdk/groups/:groupId/checkout/validate";
|
|
13
13
|
readonly GROUP_CHECKOUT_CONFIRM: "/v1/sdk/groups/:groupId/checkout/confirm";
|
|
14
|
+
readonly INVITE_RESOLVE: "/v1/sdk/invite/resolve";
|
|
14
15
|
};
|
|
15
16
|
/**
|
|
16
17
|
* Build full API URL from base URL and endpoint path
|
|
@@ -582,6 +582,41 @@ export interface GroupInviteResponseData {
|
|
|
582
582
|
};
|
|
583
583
|
[key: string]: unknown;
|
|
584
584
|
}
|
|
585
|
+
/**
|
|
586
|
+
* Invite resolution response data
|
|
587
|
+
*/
|
|
588
|
+
export interface InviteResolveResponseData {
|
|
589
|
+
product: {
|
|
590
|
+
id: string;
|
|
591
|
+
name: string;
|
|
592
|
+
images: string[];
|
|
593
|
+
price: number;
|
|
594
|
+
description: string;
|
|
595
|
+
};
|
|
596
|
+
creative: {
|
|
597
|
+
id: string;
|
|
598
|
+
name: string;
|
|
599
|
+
contact_required: boolean;
|
|
600
|
+
};
|
|
601
|
+
brand: {
|
|
602
|
+
id: string;
|
|
603
|
+
name: string;
|
|
604
|
+
};
|
|
605
|
+
group: {
|
|
606
|
+
id: string;
|
|
607
|
+
group_name: string;
|
|
608
|
+
description: string;
|
|
609
|
+
current_count: number;
|
|
610
|
+
required_count: number;
|
|
611
|
+
status: string;
|
|
612
|
+
auto_created: boolean;
|
|
613
|
+
expiry_at: string;
|
|
614
|
+
};
|
|
615
|
+
invite_metadata: {
|
|
616
|
+
shared_via: string;
|
|
617
|
+
click_count: number;
|
|
618
|
+
};
|
|
619
|
+
}
|
|
585
620
|
/**
|
|
586
621
|
* Options for rendering the CoBuy widget
|
|
587
622
|
*/
|
|
@@ -672,6 +707,13 @@ export interface CoBuySDK {
|
|
|
672
707
|
* @param _contact Contact information (email or phone)
|
|
673
708
|
*/
|
|
674
709
|
setContact(_contact: Contact): Promise<void>;
|
|
710
|
+
/**
|
|
711
|
+
* Resolve an invite token to get product and group information
|
|
712
|
+
* Used to handle invite links like https://brand.cobuyza.co.za/i/{token}
|
|
713
|
+
* @param _inviteToken The invite token from the URL
|
|
714
|
+
* @returns Promise with invite resolution data including product, group, and metadata
|
|
715
|
+
*/
|
|
716
|
+
resolveInvite(_inviteToken: string): Promise<InviteResolveResponseData | null>;
|
|
675
717
|
/**
|
|
676
718
|
* Validate checkout for a group
|
|
677
719
|
* Validates the checkout reference and confirms the order can proceed
|