@explorins/pers-sdk-react-native 2.1.8 → 2.1.10
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.
|
@@ -1,8 +1,27 @@
|
|
|
1
|
-
import type { CampaignClaimRequestDTO, CampaignDTO, CampaignClaimDTO, CampaignTriggerDTO, PaginatedResponseDTO, CampaignClaimIncludeRelation, CampaignIncludeRelation } from '@explorins/pers-shared';
|
|
1
|
+
import type { CampaignClaimRequestDTO, CampaignDTO, CampaignClaimDTO, CampaignTriggerDTO, PaginatedResponseDTO, CampaignClaimIncludeRelation, CampaignIncludeRelation, SortOrder } from '@explorins/pers-shared';
|
|
2
2
|
import type { CampaignClaimFilters } from '@explorins/pers-sdk/campaign';
|
|
3
3
|
export type { CampaignClaimFilters } from '@explorins/pers-sdk/campaign';
|
|
4
|
+
/**
|
|
5
|
+
* Options for fetching campaigns
|
|
6
|
+
*/
|
|
7
|
+
export interface GetCampaignsOptions {
|
|
8
|
+
/** Filter by tag */
|
|
9
|
+
tag?: string;
|
|
10
|
+
/** Filter by business ID */
|
|
11
|
+
businessId?: string;
|
|
12
|
+
/** Page number (1-indexed) */
|
|
13
|
+
page?: number;
|
|
14
|
+
/** Items per page */
|
|
15
|
+
limit?: number;
|
|
16
|
+
/** Sort field */
|
|
17
|
+
sortBy?: 'name' | 'createdAt' | 'startDate';
|
|
18
|
+
/** Sort order */
|
|
19
|
+
sortOrder?: SortOrder;
|
|
20
|
+
/** Relations to include: 'triggerSources', 'businesses' */
|
|
21
|
+
include?: CampaignIncludeRelation[];
|
|
22
|
+
}
|
|
4
23
|
export declare const useCampaigns: () => {
|
|
5
|
-
getActiveCampaigns: () => Promise<PaginatedResponseDTO<CampaignDTO>>;
|
|
24
|
+
getActiveCampaigns: (options?: GetCampaignsOptions) => Promise<PaginatedResponseDTO<CampaignDTO>>;
|
|
6
25
|
getCampaignById: (campaignId: string, include?: CampaignIncludeRelation[]) => Promise<CampaignDTO | null>;
|
|
7
26
|
claimCampaign: (request: CampaignClaimRequestDTO) => Promise<CampaignClaimDTO | null>;
|
|
8
27
|
getUserClaims: (options?: {
|
|
@@ -11,7 +30,9 @@ export declare const useCampaigns: () => {
|
|
|
11
30
|
include?: CampaignClaimIncludeRelation[];
|
|
12
31
|
}) => Promise<PaginatedResponseDTO<CampaignClaimDTO>>;
|
|
13
32
|
getCampaignTriggers: () => Promise<PaginatedResponseDTO<CampaignTriggerDTO>>;
|
|
14
|
-
getAllCampaigns: (
|
|
33
|
+
getAllCampaigns: (options?: GetCampaignsOptions & {
|
|
34
|
+
active?: boolean;
|
|
35
|
+
}) => Promise<PaginatedResponseDTO<CampaignDTO>>;
|
|
15
36
|
getCampaignClaims: (filters?: CampaignClaimFilters, include?: CampaignClaimIncludeRelation[]) => Promise<PaginatedResponseDTO<CampaignClaimDTO>>;
|
|
16
37
|
getCampaignClaimsByUserId: (userId: string, include?: CampaignClaimIncludeRelation[]) => Promise<PaginatedResponseDTO<CampaignClaimDTO>>;
|
|
17
38
|
getCampaignClaimsByBusinessId: (businessId: string, include?: CampaignClaimIncludeRelation[]) => Promise<PaginatedResponseDTO<CampaignClaimDTO>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCampaigns.d.ts","sourceRoot":"","sources":["../../src/hooks/useCampaigns.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,uBAAuB,EACvB,WAAW,EACX,gBAAgB,EAChB,kBAAkB,EAClB,oBAAoB,EACpB,4BAA4B,EAC5B,uBAAuB,
|
|
1
|
+
{"version":3,"file":"useCampaigns.d.ts","sourceRoot":"","sources":["../../src/hooks/useCampaigns.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,uBAAuB,EACvB,WAAW,EACX,gBAAgB,EAChB,kBAAkB,EAClB,oBAAoB,EACpB,4BAA4B,EAC5B,uBAAuB,EACvB,SAAS,EACV,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,EAAE,oBAAoB,E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,EAAE,KACvC,QAAQ,qBAAqB,gBAAgB,CAAC,CAAC;sCA4CpC,MAAM,mBACD,MAAM,KACtB,QAAQ,WAAW,CAAC;sCA4BT,MAAM,mBACD,MAAM,KACtB,QAAQ,WAAW,CAAC;;CA+BxB,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG,UAAU,CAAC,OAAO,YAAY,CAAC,CAAC"}
|
|
@@ -2,12 +2,40 @@ import { useCallback } from 'react';
|
|
|
2
2
|
import { usePersSDK } from '../providers/PersSDKProvider';
|
|
3
3
|
export const useCampaigns = () => {
|
|
4
4
|
const { sdk, isInitialized, isAuthenticated } = usePersSDK();
|
|
5
|
-
|
|
5
|
+
/**
|
|
6
|
+
* Get active campaigns with optional filters and include relations
|
|
7
|
+
*
|
|
8
|
+
* @param options - Filter, pagination, and include options
|
|
9
|
+
* @returns Promise resolving to paginated active campaigns
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```typescript
|
|
13
|
+
* // Simple: get active campaigns with trigger sources
|
|
14
|
+
* const { data: campaigns } = await getActiveCampaigns({ include: ['triggerSources'] });
|
|
15
|
+
*
|
|
16
|
+
* // With pagination
|
|
17
|
+
* const { data, pagination } = await getActiveCampaigns({
|
|
18
|
+
* page: 1,
|
|
19
|
+
* limit: 10,
|
|
20
|
+
* include: ['triggerSources', 'businesses']
|
|
21
|
+
* });
|
|
22
|
+
*
|
|
23
|
+
* // Filter by tag
|
|
24
|
+
* const { data } = await getActiveCampaigns({ tag: 'summer-promo' });
|
|
25
|
+
*
|
|
26
|
+
* // Filter by business
|
|
27
|
+
* const { data } = await getActiveCampaigns({ businessId: 'business-123' });
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
const getActiveCampaigns = useCallback(async (options) => {
|
|
6
31
|
if (!isInitialized || !sdk) {
|
|
7
32
|
throw new Error('SDK not initialized. Call initialize() first.');
|
|
8
33
|
}
|
|
9
34
|
try {
|
|
10
|
-
const result = await sdk.campaigns.getCampaigns({
|
|
35
|
+
const result = await sdk.campaigns.getCampaigns({
|
|
36
|
+
active: true,
|
|
37
|
+
...options
|
|
38
|
+
});
|
|
11
39
|
return result;
|
|
12
40
|
}
|
|
13
41
|
catch (error) {
|
|
@@ -107,12 +135,38 @@ export const useCampaigns = () => {
|
|
|
107
135
|
}
|
|
108
136
|
}, [sdk, isInitialized]);
|
|
109
137
|
// Admin methods
|
|
110
|
-
|
|
138
|
+
/**
|
|
139
|
+
* Admin: Get all campaigns with optional filters and include relations
|
|
140
|
+
*
|
|
141
|
+
* @param options - Filter, pagination, and include options (same as getActiveCampaigns but active is optional)
|
|
142
|
+
* @returns Promise resolving to paginated campaigns
|
|
143
|
+
*
|
|
144
|
+
* @example
|
|
145
|
+
* ```typescript
|
|
146
|
+
* // Get all campaigns
|
|
147
|
+
* const { data } = await getAllCampaigns();
|
|
148
|
+
*
|
|
149
|
+
* // Get only active campaigns with trigger sources
|
|
150
|
+
* const { data } = await getAllCampaigns({ active: true, include: ['triggerSources'] });
|
|
151
|
+
*
|
|
152
|
+
* // Get inactive campaigns
|
|
153
|
+
* const { data } = await getAllCampaigns({ active: false });
|
|
154
|
+
*
|
|
155
|
+
* // With pagination and sorting
|
|
156
|
+
* const { data } = await getAllCampaigns({
|
|
157
|
+
* page: 1,
|
|
158
|
+
* limit: 20,
|
|
159
|
+
* sortBy: 'createdAt',
|
|
160
|
+
* sortOrder: 'DESC'
|
|
161
|
+
* });
|
|
162
|
+
* ```
|
|
163
|
+
*/
|
|
164
|
+
const getAllCampaigns = useCallback(async (options) => {
|
|
111
165
|
if (!isInitialized || !sdk) {
|
|
112
166
|
throw new Error('SDK not initialized. Call initialize() first.');
|
|
113
167
|
}
|
|
114
168
|
try {
|
|
115
|
-
const result = await sdk.campaigns.getCampaigns(
|
|
169
|
+
const result = await sdk.campaigns.getCampaigns(options);
|
|
116
170
|
return result;
|
|
117
171
|
}
|
|
118
172
|
catch (error) {
|
package/dist/index.js
CHANGED
|
@@ -41248,12 +41248,40 @@ const useBusiness = () => {
|
|
|
41248
41248
|
|
|
41249
41249
|
const useCampaigns = () => {
|
|
41250
41250
|
const { sdk, isInitialized, isAuthenticated } = usePersSDK();
|
|
41251
|
-
|
|
41251
|
+
/**
|
|
41252
|
+
* Get active campaigns with optional filters and include relations
|
|
41253
|
+
*
|
|
41254
|
+
* @param options - Filter, pagination, and include options
|
|
41255
|
+
* @returns Promise resolving to paginated active campaigns
|
|
41256
|
+
*
|
|
41257
|
+
* @example
|
|
41258
|
+
* ```typescript
|
|
41259
|
+
* // Simple: get active campaigns with trigger sources
|
|
41260
|
+
* const { data: campaigns } = await getActiveCampaigns({ include: ['triggerSources'] });
|
|
41261
|
+
*
|
|
41262
|
+
* // With pagination
|
|
41263
|
+
* const { data, pagination } = await getActiveCampaigns({
|
|
41264
|
+
* page: 1,
|
|
41265
|
+
* limit: 10,
|
|
41266
|
+
* include: ['triggerSources', 'businesses']
|
|
41267
|
+
* });
|
|
41268
|
+
*
|
|
41269
|
+
* // Filter by tag
|
|
41270
|
+
* const { data } = await getActiveCampaigns({ tag: 'summer-promo' });
|
|
41271
|
+
*
|
|
41272
|
+
* // Filter by business
|
|
41273
|
+
* const { data } = await getActiveCampaigns({ businessId: 'business-123' });
|
|
41274
|
+
* ```
|
|
41275
|
+
*/
|
|
41276
|
+
const getActiveCampaigns = react.useCallback(async (options) => {
|
|
41252
41277
|
if (!isInitialized || !sdk) {
|
|
41253
41278
|
throw new Error('SDK not initialized. Call initialize() first.');
|
|
41254
41279
|
}
|
|
41255
41280
|
try {
|
|
41256
|
-
const result = await sdk.campaigns.getCampaigns({
|
|
41281
|
+
const result = await sdk.campaigns.getCampaigns({
|
|
41282
|
+
active: true,
|
|
41283
|
+
...options
|
|
41284
|
+
});
|
|
41257
41285
|
return result;
|
|
41258
41286
|
}
|
|
41259
41287
|
catch (error) {
|
|
@@ -41353,12 +41381,38 @@ const useCampaigns = () => {
|
|
|
41353
41381
|
}
|
|
41354
41382
|
}, [sdk, isInitialized]);
|
|
41355
41383
|
// Admin methods
|
|
41356
|
-
|
|
41384
|
+
/**
|
|
41385
|
+
* Admin: Get all campaigns with optional filters and include relations
|
|
41386
|
+
*
|
|
41387
|
+
* @param options - Filter, pagination, and include options (same as getActiveCampaigns but active is optional)
|
|
41388
|
+
* @returns Promise resolving to paginated campaigns
|
|
41389
|
+
*
|
|
41390
|
+
* @example
|
|
41391
|
+
* ```typescript
|
|
41392
|
+
* // Get all campaigns
|
|
41393
|
+
* const { data } = await getAllCampaigns();
|
|
41394
|
+
*
|
|
41395
|
+
* // Get only active campaigns with trigger sources
|
|
41396
|
+
* const { data } = await getAllCampaigns({ active: true, include: ['triggerSources'] });
|
|
41397
|
+
*
|
|
41398
|
+
* // Get inactive campaigns
|
|
41399
|
+
* const { data } = await getAllCampaigns({ active: false });
|
|
41400
|
+
*
|
|
41401
|
+
* // With pagination and sorting
|
|
41402
|
+
* const { data } = await getAllCampaigns({
|
|
41403
|
+
* page: 1,
|
|
41404
|
+
* limit: 20,
|
|
41405
|
+
* sortBy: 'createdAt',
|
|
41406
|
+
* sortOrder: 'DESC'
|
|
41407
|
+
* });
|
|
41408
|
+
* ```
|
|
41409
|
+
*/
|
|
41410
|
+
const getAllCampaigns = react.useCallback(async (options) => {
|
|
41357
41411
|
if (!isInitialized || !sdk) {
|
|
41358
41412
|
throw new Error('SDK not initialized. Call initialize() first.');
|
|
41359
41413
|
}
|
|
41360
41414
|
try {
|
|
41361
|
-
const result = await sdk.campaigns.getCampaigns(
|
|
41415
|
+
const result = await sdk.campaigns.getCampaigns(options);
|
|
41362
41416
|
return result;
|
|
41363
41417
|
}
|
|
41364
41418
|
catch (error) {
|