@fuul/sdk 0.11.2 → 0.11.3
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/lib/cjs/index.js +6 -8
- package/lib/cjs/infrastructure/campaigns/campaignsService.js +2 -13
- package/lib/cjs/infrastructure/http/HttpClient.js +8 -4
- package/lib/cjs/types/index.d.ts +1 -1
- package/lib/cjs/types/index.d.ts.map +1 -1
- package/lib/cjs/types/infrastructure/campaigns/campaignsService.d.ts +1 -1
- package/lib/cjs/types/infrastructure/campaigns/campaignsService.d.ts.map +1 -1
- package/lib/cjs/types/infrastructure/http/HttpClient.d.ts +2 -0
- package/lib/cjs/types/infrastructure/http/HttpClient.d.ts.map +1 -1
- package/lib/cjs/types/types/types.d.ts +3 -1
- package/lib/cjs/types/types/types.d.ts.map +1 -1
- package/lib/cjs/types/utils/queryParams.d.ts +2 -0
- package/lib/cjs/types/utils/queryParams.d.ts.map +1 -0
- package/lib/cjs/utils/queryParams.js +14 -0
- package/lib/esm/index.mjs +6 -8
- package/lib/esm/infrastructure/campaigns/campaignsService.js +2 -13
- package/lib/esm/infrastructure/http/HttpClient.js +8 -4
- package/lib/esm/types/index.d.ts +1 -1
- package/lib/esm/types/index.d.ts.map +1 -1
- package/lib/esm/types/infrastructure/campaigns/campaignsService.d.ts +1 -1
- package/lib/esm/types/infrastructure/campaigns/campaignsService.d.ts.map +1 -1
- package/lib/esm/types/infrastructure/http/HttpClient.d.ts +2 -0
- package/lib/esm/types/infrastructure/http/HttpClient.d.ts.map +1 -1
- package/lib/esm/types/types/types.d.ts +3 -1
- package/lib/esm/types/types/types.d.ts.map +1 -1
- package/lib/esm/types/utils/queryParams.d.ts +2 -0
- package/lib/esm/types/utils/queryParams.d.ts.map +1 -0
- package/lib/esm/utils/queryParams.js +10 -0
- package/package.json +1 -1
package/lib/cjs/index.js
CHANGED
|
@@ -69,14 +69,15 @@ class Fuul {
|
|
|
69
69
|
constructor(apiKey, settings = {}) {
|
|
70
70
|
this.BASE_API_URL = "https://api.fuul.xyz/api/v1/";
|
|
71
71
|
this.apiKey = apiKey;
|
|
72
|
-
this.checkApiKey();
|
|
73
72
|
this.settings = settings;
|
|
73
|
+
this.checkApiKey();
|
|
74
74
|
saveSessionId();
|
|
75
75
|
saveTrackingId();
|
|
76
76
|
this.httpClient = new HttpClient_js_1.HttpClient({
|
|
77
77
|
baseURL: this.BASE_API_URL,
|
|
78
78
|
timeout: 10000,
|
|
79
79
|
apiKey: this.apiKey,
|
|
80
|
+
queryParams: this.settings.defaultQueryParams,
|
|
80
81
|
});
|
|
81
82
|
this.campaignsService = new campaignsService_js_1.CampaignsService(this.httpClient);
|
|
82
83
|
this.init();
|
|
@@ -84,7 +85,7 @@ class Fuul {
|
|
|
84
85
|
init() {
|
|
85
86
|
return __awaiter(this, void 0, void 0, function* () {
|
|
86
87
|
globalThis.Fuul = this;
|
|
87
|
-
if (typeof window !== "undefined"
|
|
88
|
+
if (typeof window !== "undefined") {
|
|
88
89
|
yield this.sendEvent("pageview");
|
|
89
90
|
}
|
|
90
91
|
});
|
|
@@ -141,10 +142,7 @@ class Fuul {
|
|
|
141
142
|
if (isEventAlreadySentAndInValidTimestamp(name, params))
|
|
142
143
|
return;
|
|
143
144
|
try {
|
|
144
|
-
|
|
145
|
-
? `events?project_id=${args.project_id}`
|
|
146
|
-
: "events";
|
|
147
|
-
yield this.httpClient.post(PATH, reqBody);
|
|
145
|
+
yield this.httpClient.post("events", reqBody);
|
|
148
146
|
saveSentEvent(name, params);
|
|
149
147
|
}
|
|
150
148
|
catch (error) {
|
|
@@ -167,9 +165,9 @@ class Fuul {
|
|
|
167
165
|
generateTrackingLink({ address, pid, baseUrl, }) {
|
|
168
166
|
return `${baseUrl !== null && baseUrl !== void 0 ? baseUrl : window.location.href}?${buildTrackingLinkQueryParams(address, pid)}`;
|
|
169
167
|
}
|
|
170
|
-
getAllCampaigns(
|
|
168
|
+
getAllCampaigns() {
|
|
171
169
|
return __awaiter(this, void 0, void 0, function* () {
|
|
172
|
-
return this.campaignsService.getAllCampaignsByProjectId(
|
|
170
|
+
return this.campaignsService.getAllCampaignsByProjectId();
|
|
173
171
|
});
|
|
174
172
|
}
|
|
175
173
|
}
|
|
@@ -10,24 +10,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.CampaignsService = void 0;
|
|
13
|
-
const buildQueryParams = (args) => {
|
|
14
|
-
let queryParams = "";
|
|
15
|
-
Object.keys(args).forEach((key) => {
|
|
16
|
-
queryParams =
|
|
17
|
-
queryParams === ""
|
|
18
|
-
? queryParams + `${key}=${args[key]}`
|
|
19
|
-
: queryParams + "&" + `${key}=${args[key]}`;
|
|
20
|
-
});
|
|
21
|
-
return queryParams;
|
|
22
|
-
};
|
|
23
13
|
class CampaignsService {
|
|
24
14
|
constructor(httpClient) {
|
|
25
15
|
this.httpClient = httpClient;
|
|
26
16
|
}
|
|
27
|
-
getAllCampaignsByProjectId(
|
|
17
|
+
getAllCampaignsByProjectId() {
|
|
28
18
|
return __awaiter(this, void 0, void 0, function* () {
|
|
29
|
-
const
|
|
30
|
-
const { data } = yield this.httpClient.get(PATH);
|
|
19
|
+
const { data } = yield this.httpClient.get("campaigns");
|
|
31
20
|
return data;
|
|
32
21
|
});
|
|
33
22
|
}
|
|
@@ -14,28 +14,32 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.HttpClient = void 0;
|
|
16
16
|
const axios_1 = __importDefault(require("axios"));
|
|
17
|
+
const queryParams_js_1 = require("../../utils/queryParams.js");
|
|
17
18
|
class HttpClient {
|
|
18
19
|
constructor(options) {
|
|
19
20
|
this.client = axios_1.default.create(Object.assign(Object.assign({}, options), { headers: options.apiKey ? this._getHeaders(options.apiKey) : {} }));
|
|
21
|
+
this.queryParams = options.queryParams
|
|
22
|
+
? (0, queryParams_js_1.buildQueryParams)(options.queryParams)
|
|
23
|
+
: "";
|
|
20
24
|
}
|
|
21
25
|
get(path, params) {
|
|
22
26
|
return __awaiter(this, void 0, void 0, function* () {
|
|
23
|
-
return this.client.get(path, { params });
|
|
27
|
+
return this.client.get(path + this.queryParams, { params });
|
|
24
28
|
});
|
|
25
29
|
}
|
|
26
30
|
post(path, data) {
|
|
27
31
|
return __awaiter(this, void 0, void 0, function* () {
|
|
28
|
-
return this.client.post(path, data);
|
|
32
|
+
return this.client.post(path + this.queryParams, data);
|
|
29
33
|
});
|
|
30
34
|
}
|
|
31
35
|
put(path, data) {
|
|
32
36
|
return __awaiter(this, void 0, void 0, function* () {
|
|
33
|
-
return this.client.put(path, data);
|
|
37
|
+
return this.client.put(path + this.queryParams, data);
|
|
34
38
|
});
|
|
35
39
|
}
|
|
36
40
|
delete(path) {
|
|
37
41
|
return __awaiter(this, void 0, void 0, function* () {
|
|
38
|
-
return this.client.delete(path);
|
|
42
|
+
return this.client.delete(path + this.queryParams);
|
|
39
43
|
});
|
|
40
44
|
}
|
|
41
45
|
_getHeaders(apiKey) {
|
package/lib/cjs/types/index.d.ts
CHANGED
|
@@ -35,7 +35,7 @@ export declare class Fuul {
|
|
|
35
35
|
* @returns {string} tracking link
|
|
36
36
|
*/
|
|
37
37
|
generateTrackingLink({ address, pid, baseUrl, }: IGenerateTrackingLink): string;
|
|
38
|
-
getAllCampaigns(
|
|
38
|
+
getAllCampaigns(): Promise<CampaignDTO[]>;
|
|
39
39
|
}
|
|
40
40
|
declare const _default: {
|
|
41
41
|
Fuul: typeof Fuul;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAgBA,OAAO,EACL,aAAa,EACb,SAAS,EACT,YAAY,EACZ,qBAAqB,EAEtB,MAAM,kBAAkB,CAAC;AAI1B,OAAO,EAAE,WAAW,EAAE,MAAM,oCAAoC,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAgBA,OAAO,EACL,aAAa,EACb,SAAS,EACT,YAAY,EACZ,qBAAqB,EAEtB,MAAM,kBAAkB,CAAC;AAI1B,OAAO,EAAE,WAAW,EAAE,MAAM,oCAAoC,CAAC;AA2EjE,qBAAa,IAAI;IACf,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAChC,OAAO,CAAC,QAAQ,CAAC,YAAY,CAA0C;IACvE,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAa;IACxC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAe;IACxC,OAAO,CAAC,gBAAgB,CAAmB;gBAE/B,MAAM,EAAE,MAAM,EAAE,QAAQ,GAAE,YAAiB;IAoBjD,IAAI;IAQV,WAAW,IAAI,IAAI;IAMnB;;;;;;;;;;;;;;;OAeG;IACG,SAAS,CAAC,IAAI,EAAE,SAAS,EAAE,IAAI,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,GAAG,CAAC;IAqDpE,gBAAgB,IAAI,IAAI;IAMxB;;;;;;OAMG;IACH,oBAAoB,CAAC,EACnB,OAAO,EACP,GAAG,EACH,OAAO,GACR,EAAE,qBAAqB,GAAG,MAAM;IAO3B,eAAe,IAAI,OAAO,CAAC,WAAW,EAAE,CAAC;CAGhD;;;;AAMD,wBAEE"}
|
|
@@ -3,6 +3,6 @@ import { CampaignDTO } from "./dtos.js";
|
|
|
3
3
|
export declare class CampaignsService {
|
|
4
4
|
private httpClient;
|
|
5
5
|
constructor(httpClient: HttpClient);
|
|
6
|
-
getAllCampaignsByProjectId(
|
|
6
|
+
getAllCampaignsByProjectId(): Promise<CampaignDTO[]>;
|
|
7
7
|
}
|
|
8
8
|
//# sourceMappingURL=campaignsService.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"campaignsService.d.ts","sourceRoot":"","sources":["../../../../../src/infrastructure/campaigns/campaignsService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"campaignsService.d.ts","sourceRoot":"","sources":["../../../../../src/infrastructure/campaigns/campaignsService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAExC,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,UAAU,CAAa;gBAEnB,UAAU,EAAE,UAAU;IAI5B,0BAA0B,IAAI,OAAO,CAAC,WAAW,EAAE,CAAC;CAK3D"}
|
|
@@ -3,6 +3,7 @@ interface HttpClientOptions {
|
|
|
3
3
|
baseURL: string;
|
|
4
4
|
timeout: number;
|
|
5
5
|
apiKey?: string;
|
|
6
|
+
queryParams?: Record<string, string>;
|
|
6
7
|
}
|
|
7
8
|
export interface HttpError {
|
|
8
9
|
message: string;
|
|
@@ -10,6 +11,7 @@ export interface HttpError {
|
|
|
10
11
|
}
|
|
11
12
|
export declare class HttpClient {
|
|
12
13
|
private readonly client;
|
|
14
|
+
private readonly queryParams;
|
|
13
15
|
constructor(options: HttpClientOptions);
|
|
14
16
|
get<T>(path: string, params?: any): Promise<AxiosResponse<T>>;
|
|
15
17
|
post<T>(path: string, data: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HttpClient.d.ts","sourceRoot":"","sources":["../../../../../src/infrastructure/http/HttpClient.ts"],"names":[],"mappings":"AAAA,OAAc,EAEZ,aAAa,EACb,sBAAsB,EACvB,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"HttpClient.d.ts","sourceRoot":"","sources":["../../../../../src/infrastructure/http/HttpClient.ts"],"names":[],"mappings":"AAAA,OAAc,EAEZ,aAAa,EACb,sBAAsB,EACvB,MAAM,OAAO,CAAC;AAGf,UAAU,iBAAiB;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACtC;AAED,MAAM,WAAW,SAAS;IACxB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,qBAAa,UAAU;IACrB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAgB;IACvC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAS;gBAEzB,OAAO,EAAE,iBAAiB;IAUhC,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,GAAG,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC;IAI7D,IAAI,CAAC,CAAC,EACV,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE;QACJ,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;KACpB,GACA,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC;IAItB,GAAG,CAAC,CAAC,EACT,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE;QACJ,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;KACpB,GACA,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC;IAItB,MAAM,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC;IAIxD,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,sBAAsB;CAOpD"}
|
|
@@ -6,7 +6,9 @@ export type EventArgsType = {
|
|
|
6
6
|
[key: string]: string;
|
|
7
7
|
};
|
|
8
8
|
export type FuulSettings = {
|
|
9
|
-
[key: string]: string
|
|
9
|
+
[key: string]: string;
|
|
10
|
+
} & {
|
|
11
|
+
[key: string]: Record<string, string>;
|
|
10
12
|
};
|
|
11
13
|
export type EventType = "connect_wallet" | "pageview";
|
|
12
14
|
export interface SentEventParams {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/types/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,SAAS,CAAC;IAChB,IAAI,CAAC,EAAE,aAAa,CAAC;CACtB;AAED,MAAM,MAAM,aAAa,GAAG;IAC1B,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC;CACvB,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IACzB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/types/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,SAAS,CAAC;IAChB,IAAI,CAAC,EAAE,aAAa,CAAC;CACtB;AAED,MAAM,MAAM,aAAa,GAAG;IAC1B,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC;CACvB,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IACzB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC;CACvB,GAAG;IACF,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACvC,CAAC;AAEF,MAAM,MAAM,SAAS,GAAG,gBAAgB,GAAG,UAAU,CAAC;AAEtD,MAAM,WAAW,eAAe;IAC9B,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,qBAAqB;IACpC,OAAO,EAAE,MAAM,CAAC;IAChB,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"queryParams.d.ts","sourceRoot":"","sources":["../../../../src/utils/queryParams.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,gBAAgB,SAAU,OAAO,MAAM,EAAE,MAAM,CAAC,WAW5D,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.buildQueryParams = void 0;
|
|
4
|
+
const buildQueryParams = (args) => {
|
|
5
|
+
let queryParams = "";
|
|
6
|
+
Object.keys(args).forEach((key) => {
|
|
7
|
+
queryParams =
|
|
8
|
+
queryParams === ""
|
|
9
|
+
? queryParams + `?${key}=${args[key]}`
|
|
10
|
+
: queryParams + "&" + `${key}=${args[key]}`;
|
|
11
|
+
});
|
|
12
|
+
return queryParams;
|
|
13
|
+
};
|
|
14
|
+
exports.buildQueryParams = buildQueryParams;
|
package/lib/esm/index.mjs
CHANGED
|
@@ -66,14 +66,15 @@ export class Fuul {
|
|
|
66
66
|
constructor(apiKey, settings = {}) {
|
|
67
67
|
this.BASE_API_URL = "https://api.fuul.xyz/api/v1/";
|
|
68
68
|
this.apiKey = apiKey;
|
|
69
|
-
this.checkApiKey();
|
|
70
69
|
this.settings = settings;
|
|
70
|
+
this.checkApiKey();
|
|
71
71
|
saveSessionId();
|
|
72
72
|
saveTrackingId();
|
|
73
73
|
this.httpClient = new HttpClient({
|
|
74
74
|
baseURL: this.BASE_API_URL,
|
|
75
75
|
timeout: 10000,
|
|
76
76
|
apiKey: this.apiKey,
|
|
77
|
+
queryParams: this.settings.defaultQueryParams,
|
|
77
78
|
});
|
|
78
79
|
this.campaignsService = new CampaignsService(this.httpClient);
|
|
79
80
|
this.init();
|
|
@@ -81,7 +82,7 @@ export class Fuul {
|
|
|
81
82
|
init() {
|
|
82
83
|
return __awaiter(this, void 0, void 0, function* () {
|
|
83
84
|
globalThis.Fuul = this;
|
|
84
|
-
if (typeof window !== "undefined"
|
|
85
|
+
if (typeof window !== "undefined") {
|
|
85
86
|
yield this.sendEvent("pageview");
|
|
86
87
|
}
|
|
87
88
|
});
|
|
@@ -138,10 +139,7 @@ export class Fuul {
|
|
|
138
139
|
if (isEventAlreadySentAndInValidTimestamp(name, params))
|
|
139
140
|
return;
|
|
140
141
|
try {
|
|
141
|
-
|
|
142
|
-
? `events?project_id=${args.project_id}`
|
|
143
|
-
: "events";
|
|
144
|
-
yield this.httpClient.post(PATH, reqBody);
|
|
142
|
+
yield this.httpClient.post("events", reqBody);
|
|
145
143
|
saveSentEvent(name, params);
|
|
146
144
|
}
|
|
147
145
|
catch (error) {
|
|
@@ -164,9 +162,9 @@ export class Fuul {
|
|
|
164
162
|
generateTrackingLink({ address, pid, baseUrl, }) {
|
|
165
163
|
return `${baseUrl !== null && baseUrl !== void 0 ? baseUrl : window.location.href}?${buildTrackingLinkQueryParams(address, pid)}`;
|
|
166
164
|
}
|
|
167
|
-
getAllCampaigns(
|
|
165
|
+
getAllCampaigns() {
|
|
168
166
|
return __awaiter(this, void 0, void 0, function* () {
|
|
169
|
-
return this.campaignsService.getAllCampaignsByProjectId(
|
|
167
|
+
return this.campaignsService.getAllCampaignsByProjectId();
|
|
170
168
|
});
|
|
171
169
|
}
|
|
172
170
|
}
|
|
@@ -7,24 +7,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
7
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
|
-
const buildQueryParams = (args) => {
|
|
11
|
-
let queryParams = "";
|
|
12
|
-
Object.keys(args).forEach((key) => {
|
|
13
|
-
queryParams =
|
|
14
|
-
queryParams === ""
|
|
15
|
-
? queryParams + `${key}=${args[key]}`
|
|
16
|
-
: queryParams + "&" + `${key}=${args[key]}`;
|
|
17
|
-
});
|
|
18
|
-
return queryParams;
|
|
19
|
-
};
|
|
20
10
|
export class CampaignsService {
|
|
21
11
|
constructor(httpClient) {
|
|
22
12
|
this.httpClient = httpClient;
|
|
23
13
|
}
|
|
24
|
-
getAllCampaignsByProjectId(
|
|
14
|
+
getAllCampaignsByProjectId() {
|
|
25
15
|
return __awaiter(this, void 0, void 0, function* () {
|
|
26
|
-
const
|
|
27
|
-
const { data } = yield this.httpClient.get(PATH);
|
|
16
|
+
const { data } = yield this.httpClient.get("campaigns");
|
|
28
17
|
return data;
|
|
29
18
|
});
|
|
30
19
|
}
|
|
@@ -8,28 +8,32 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
10
|
import axios from "axios";
|
|
11
|
+
import { buildQueryParams } from "../../utils/queryParams.js";
|
|
11
12
|
export class HttpClient {
|
|
12
13
|
constructor(options) {
|
|
13
14
|
this.client = axios.create(Object.assign(Object.assign({}, options), { headers: options.apiKey ? this._getHeaders(options.apiKey) : {} }));
|
|
15
|
+
this.queryParams = options.queryParams
|
|
16
|
+
? buildQueryParams(options.queryParams)
|
|
17
|
+
: "";
|
|
14
18
|
}
|
|
15
19
|
get(path, params) {
|
|
16
20
|
return __awaiter(this, void 0, void 0, function* () {
|
|
17
|
-
return this.client.get(path, { params });
|
|
21
|
+
return this.client.get(path + this.queryParams, { params });
|
|
18
22
|
});
|
|
19
23
|
}
|
|
20
24
|
post(path, data) {
|
|
21
25
|
return __awaiter(this, void 0, void 0, function* () {
|
|
22
|
-
return this.client.post(path, data);
|
|
26
|
+
return this.client.post(path + this.queryParams, data);
|
|
23
27
|
});
|
|
24
28
|
}
|
|
25
29
|
put(path, data) {
|
|
26
30
|
return __awaiter(this, void 0, void 0, function* () {
|
|
27
|
-
return this.client.put(path, data);
|
|
31
|
+
return this.client.put(path + this.queryParams, data);
|
|
28
32
|
});
|
|
29
33
|
}
|
|
30
34
|
delete(path) {
|
|
31
35
|
return __awaiter(this, void 0, void 0, function* () {
|
|
32
|
-
return this.client.delete(path);
|
|
36
|
+
return this.client.delete(path + this.queryParams);
|
|
33
37
|
});
|
|
34
38
|
}
|
|
35
39
|
_getHeaders(apiKey) {
|
package/lib/esm/types/index.d.ts
CHANGED
|
@@ -35,7 +35,7 @@ export declare class Fuul {
|
|
|
35
35
|
* @returns {string} tracking link
|
|
36
36
|
*/
|
|
37
37
|
generateTrackingLink({ address, pid, baseUrl, }: IGenerateTrackingLink): string;
|
|
38
|
-
getAllCampaigns(
|
|
38
|
+
getAllCampaigns(): Promise<CampaignDTO[]>;
|
|
39
39
|
}
|
|
40
40
|
declare const _default: {
|
|
41
41
|
Fuul: typeof Fuul;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAgBA,OAAO,EACL,aAAa,EACb,SAAS,EACT,YAAY,EACZ,qBAAqB,EAEtB,MAAM,kBAAkB,CAAC;AAI1B,OAAO,EAAE,WAAW,EAAE,MAAM,oCAAoC,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAgBA,OAAO,EACL,aAAa,EACb,SAAS,EACT,YAAY,EACZ,qBAAqB,EAEtB,MAAM,kBAAkB,CAAC;AAI1B,OAAO,EAAE,WAAW,EAAE,MAAM,oCAAoC,CAAC;AA2EjE,qBAAa,IAAI;IACf,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAChC,OAAO,CAAC,QAAQ,CAAC,YAAY,CAA0C;IACvE,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAa;IACxC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAe;IACxC,OAAO,CAAC,gBAAgB,CAAmB;gBAE/B,MAAM,EAAE,MAAM,EAAE,QAAQ,GAAE,YAAiB;IAoBjD,IAAI;IAQV,WAAW,IAAI,IAAI;IAMnB;;;;;;;;;;;;;;;OAeG;IACG,SAAS,CAAC,IAAI,EAAE,SAAS,EAAE,IAAI,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,GAAG,CAAC;IAqDpE,gBAAgB,IAAI,IAAI;IAMxB;;;;;;OAMG;IACH,oBAAoB,CAAC,EACnB,OAAO,EACP,GAAG,EACH,OAAO,GACR,EAAE,qBAAqB,GAAG,MAAM;IAO3B,eAAe,IAAI,OAAO,CAAC,WAAW,EAAE,CAAC;CAGhD;;;;AAMD,wBAEE"}
|
|
@@ -3,6 +3,6 @@ import { CampaignDTO } from "./dtos.js";
|
|
|
3
3
|
export declare class CampaignsService {
|
|
4
4
|
private httpClient;
|
|
5
5
|
constructor(httpClient: HttpClient);
|
|
6
|
-
getAllCampaignsByProjectId(
|
|
6
|
+
getAllCampaignsByProjectId(): Promise<CampaignDTO[]>;
|
|
7
7
|
}
|
|
8
8
|
//# sourceMappingURL=campaignsService.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"campaignsService.d.ts","sourceRoot":"","sources":["../../../../../src/infrastructure/campaigns/campaignsService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"campaignsService.d.ts","sourceRoot":"","sources":["../../../../../src/infrastructure/campaigns/campaignsService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAExC,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,UAAU,CAAa;gBAEnB,UAAU,EAAE,UAAU;IAI5B,0BAA0B,IAAI,OAAO,CAAC,WAAW,EAAE,CAAC;CAK3D"}
|
|
@@ -3,6 +3,7 @@ interface HttpClientOptions {
|
|
|
3
3
|
baseURL: string;
|
|
4
4
|
timeout: number;
|
|
5
5
|
apiKey?: string;
|
|
6
|
+
queryParams?: Record<string, string>;
|
|
6
7
|
}
|
|
7
8
|
export interface HttpError {
|
|
8
9
|
message: string;
|
|
@@ -10,6 +11,7 @@ export interface HttpError {
|
|
|
10
11
|
}
|
|
11
12
|
export declare class HttpClient {
|
|
12
13
|
private readonly client;
|
|
14
|
+
private readonly queryParams;
|
|
13
15
|
constructor(options: HttpClientOptions);
|
|
14
16
|
get<T>(path: string, params?: any): Promise<AxiosResponse<T>>;
|
|
15
17
|
post<T>(path: string, data: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HttpClient.d.ts","sourceRoot":"","sources":["../../../../../src/infrastructure/http/HttpClient.ts"],"names":[],"mappings":"AAAA,OAAc,EAEZ,aAAa,EACb,sBAAsB,EACvB,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"HttpClient.d.ts","sourceRoot":"","sources":["../../../../../src/infrastructure/http/HttpClient.ts"],"names":[],"mappings":"AAAA,OAAc,EAEZ,aAAa,EACb,sBAAsB,EACvB,MAAM,OAAO,CAAC;AAGf,UAAU,iBAAiB;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACtC;AAED,MAAM,WAAW,SAAS;IACxB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,qBAAa,UAAU;IACrB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAgB;IACvC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAS;gBAEzB,OAAO,EAAE,iBAAiB;IAUhC,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,GAAG,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC;IAI7D,IAAI,CAAC,CAAC,EACV,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE;QACJ,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;KACpB,GACA,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC;IAItB,GAAG,CAAC,CAAC,EACT,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE;QACJ,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;KACpB,GACA,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC;IAItB,MAAM,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC;IAIxD,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,sBAAsB;CAOpD"}
|
|
@@ -6,7 +6,9 @@ export type EventArgsType = {
|
|
|
6
6
|
[key: string]: string;
|
|
7
7
|
};
|
|
8
8
|
export type FuulSettings = {
|
|
9
|
-
[key: string]: string
|
|
9
|
+
[key: string]: string;
|
|
10
|
+
} & {
|
|
11
|
+
[key: string]: Record<string, string>;
|
|
10
12
|
};
|
|
11
13
|
export type EventType = "connect_wallet" | "pageview";
|
|
12
14
|
export interface SentEventParams {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/types/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,SAAS,CAAC;IAChB,IAAI,CAAC,EAAE,aAAa,CAAC;CACtB;AAED,MAAM,MAAM,aAAa,GAAG;IAC1B,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC;CACvB,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IACzB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/types/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,SAAS,CAAC;IAChB,IAAI,CAAC,EAAE,aAAa,CAAC;CACtB;AAED,MAAM,MAAM,aAAa,GAAG;IAC1B,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC;CACvB,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IACzB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC;CACvB,GAAG;IACF,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACvC,CAAC;AAEF,MAAM,MAAM,SAAS,GAAG,gBAAgB,GAAG,UAAU,CAAC;AAEtD,MAAM,WAAW,eAAe;IAC9B,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,qBAAqB;IACpC,OAAO,EAAE,MAAM,CAAC;IAChB,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"queryParams.d.ts","sourceRoot":"","sources":["../../../../src/utils/queryParams.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,gBAAgB,SAAU,OAAO,MAAM,EAAE,MAAM,CAAC,WAW5D,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export const buildQueryParams = (args) => {
|
|
2
|
+
let queryParams = "";
|
|
3
|
+
Object.keys(args).forEach((key) => {
|
|
4
|
+
queryParams =
|
|
5
|
+
queryParams === ""
|
|
6
|
+
? queryParams + `?${key}=${args[key]}`
|
|
7
|
+
: queryParams + "&" + `${key}=${args[key]}`;
|
|
8
|
+
});
|
|
9
|
+
return queryParams;
|
|
10
|
+
};
|