@pear-protocol/core-sdk 1.12.2 → 1.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/core/index.d.ts +12 -1
- package/dist/core/index.js +25 -0
- package/dist/utils.d.ts +1 -1
- package/dist/utils.js +8 -1
- package/package.json +1 -1
package/dist/core/index.d.ts
CHANGED
|
@@ -187,7 +187,7 @@ declare class Core {
|
|
|
187
187
|
get: (query?: HttpTypes.QuoteFeeParamsInput, headers?: ClientHeaders) => Promise<{
|
|
188
188
|
baseBps: string;
|
|
189
189
|
discounts: {
|
|
190
|
-
scope: "
|
|
190
|
+
scope: "user" | "connector" | "all" | "client_id";
|
|
191
191
|
rate: string;
|
|
192
192
|
}[];
|
|
193
193
|
finalBps: string;
|
|
@@ -2610,6 +2610,17 @@ declare class Core {
|
|
|
2610
2610
|
nextCursor?: string | undefined;
|
|
2611
2611
|
}>;
|
|
2612
2612
|
};
|
|
2613
|
+
referrals: {
|
|
2614
|
+
/** Issue an immutable referral code to the authenticated user. */
|
|
2615
|
+
create: (body: HttpTypes.CreateReferralCode, headers?: ClientHeaders) => Promise<void>;
|
|
2616
|
+
/** Permanently bind the authenticated user to an existing referral code. */
|
|
2617
|
+
bind: (body: HttpTypes.BindReferralCode, headers?: ClientHeaders) => Promise<void>;
|
|
2618
|
+
/** Return referral codes owned by the authenticated user and their referrer. */
|
|
2619
|
+
status: (headers?: ClientHeaders) => Promise<{
|
|
2620
|
+
ownedCodes: string[];
|
|
2621
|
+
referrerUserId?: string | undefined;
|
|
2622
|
+
}>;
|
|
2623
|
+
};
|
|
2613
2624
|
savedBaskets: {
|
|
2614
2625
|
list: (headers?: ClientHeaders) => Promise<{
|
|
2615
2626
|
baskets: {
|
package/dist/core/index.js
CHANGED
|
@@ -352,6 +352,31 @@ class Core {
|
|
|
352
352
|
});
|
|
353
353
|
}
|
|
354
354
|
};
|
|
355
|
+
referrals = {
|
|
356
|
+
/** Issue an immutable referral code to the authenticated user. */
|
|
357
|
+
create: async (body, headers) => {
|
|
358
|
+
return await this.client.fetch(`/referrals/create`, {
|
|
359
|
+
method: "POST",
|
|
360
|
+
headers,
|
|
361
|
+
body
|
|
362
|
+
});
|
|
363
|
+
},
|
|
364
|
+
/** Permanently bind the authenticated user to an existing referral code. */
|
|
365
|
+
bind: async (body, headers) => {
|
|
366
|
+
return await this.client.fetch(`/referrals/bind`, {
|
|
367
|
+
method: "POST",
|
|
368
|
+
headers,
|
|
369
|
+
body
|
|
370
|
+
});
|
|
371
|
+
},
|
|
372
|
+
/** Return referral codes owned by the authenticated user and their referrer. */
|
|
373
|
+
status: async (headers) => {
|
|
374
|
+
return await this.client.fetch(`/referrals/status`, {
|
|
375
|
+
method: "GET",
|
|
376
|
+
headers
|
|
377
|
+
});
|
|
378
|
+
}
|
|
379
|
+
};
|
|
355
380
|
savedBaskets = {
|
|
356
381
|
list: async (headers) => {
|
|
357
382
|
return await this.client.fetch(`/saved-baskets`, {
|
package/dist/utils.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import '@pear-protocol/utils';
|
|
|
4
4
|
|
|
5
5
|
declare function getBaseUrl(passedBaseUrl: string): string;
|
|
6
6
|
declare function normalizeRequest(init: FetchArgs | undefined, headers: Headers, authMode: AuthMode): RequestInit | undefined;
|
|
7
|
-
declare function normalizeResponseData(resp: Response, reqHeaders: Headers): Promise<
|
|
7
|
+
declare function normalizeResponseData(resp: Response, reqHeaders: Headers): Promise<unknown>;
|
|
8
8
|
declare class FetchError extends Error {
|
|
9
9
|
status: number | undefined;
|
|
10
10
|
statusText: string | undefined;
|
package/dist/utils.js
CHANGED
|
@@ -33,7 +33,14 @@ async function normalizeResponseData(resp, reqHeaders) {
|
|
|
33
33
|
return null;
|
|
34
34
|
}
|
|
35
35
|
const isJsonRequest = reqHeaders.get("accept")?.includes("application/json");
|
|
36
|
-
|
|
36
|
+
if (!isJsonRequest) {
|
|
37
|
+
return resp;
|
|
38
|
+
}
|
|
39
|
+
const responseText = await resp.text();
|
|
40
|
+
if (responseText.length === 0) {
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
return JSON.parse(responseText);
|
|
37
44
|
}
|
|
38
45
|
class FetchError extends Error {
|
|
39
46
|
status;
|