@vigneshreddy/cms-sdk 1.0.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/LICENSE +21 -0
- package/README.md +217 -0
- package/dist/src/client.d.ts +46 -0
- package/dist/src/client.js +109 -0
- package/dist/src/errors/base.d.ts +21 -0
- package/dist/src/errors/base.js +19 -0
- package/dist/src/errors/index.d.ts +3 -0
- package/dist/src/errors/index.js +22 -0
- package/dist/src/errors/specific.d.ts +43 -0
- package/dist/src/errors/specific.js +118 -0
- package/dist/src/errors.d.ts +8 -0
- package/dist/src/errors.js +60 -0
- package/dist/src/funcs/index.d.ts +2 -0
- package/dist/src/funcs/index.js +7 -0
- package/dist/src/funcs/trackLead.d.ts +36 -0
- package/dist/src/funcs/trackLead.js +47 -0
- package/dist/src/funcs/trackSale.d.ts +38 -0
- package/dist/src/funcs/trackSale.js +49 -0
- package/dist/src/generated/api.d.ts +131 -0
- package/dist/src/generated/api.js +244 -0
- package/dist/src/generated/base.d.ts +57 -0
- package/dist/src/generated/base.js +52 -0
- package/dist/src/generated/common.d.ts +31 -0
- package/dist/src/generated/common.js +116 -0
- package/dist/src/generated/configuration.d.ts +98 -0
- package/dist/src/generated/configuration.js +49 -0
- package/dist/src/generated/index.d.ts +4 -0
- package/dist/src/generated/index.js +20 -0
- package/dist/src/index.d.ts +6 -0
- package/dist/src/index.js +34 -0
- package/dist/src/types/result.d.ts +22 -0
- package/dist/src/types/result.js +16 -0
- package/package.json +66 -0
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createSpecificError = exports.GatewayTimeoutError = exports.ServiceUnavailableError = exports.BadGatewayError = exports.InternalServerError = exports.RateLimitError = exports.UnprocessableEntityError = exports.ConflictError = exports.NotFoundError = exports.ForbiddenError = exports.UnauthorizedError = exports.BadRequestError = exports.CMSAPIError = void 0;
|
|
4
|
+
exports.handleApiError = handleApiError;
|
|
5
|
+
// src/errors.ts
|
|
6
|
+
const base_1 = require("./errors/base");
|
|
7
|
+
Object.defineProperty(exports, "CMSAPIError", { enumerable: true, get: function () { return base_1.CMSAPIError; } });
|
|
8
|
+
// Re-export specific error types
|
|
9
|
+
var index_1 = require("./errors/index");
|
|
10
|
+
Object.defineProperty(exports, "BadRequestError", { enumerable: true, get: function () { return index_1.BadRequestError; } });
|
|
11
|
+
Object.defineProperty(exports, "UnauthorizedError", { enumerable: true, get: function () { return index_1.UnauthorizedError; } });
|
|
12
|
+
Object.defineProperty(exports, "ForbiddenError", { enumerable: true, get: function () { return index_1.ForbiddenError; } });
|
|
13
|
+
Object.defineProperty(exports, "NotFoundError", { enumerable: true, get: function () { return index_1.NotFoundError; } });
|
|
14
|
+
Object.defineProperty(exports, "ConflictError", { enumerable: true, get: function () { return index_1.ConflictError; } });
|
|
15
|
+
Object.defineProperty(exports, "UnprocessableEntityError", { enumerable: true, get: function () { return index_1.UnprocessableEntityError; } });
|
|
16
|
+
Object.defineProperty(exports, "RateLimitError", { enumerable: true, get: function () { return index_1.RateLimitError; } });
|
|
17
|
+
Object.defineProperty(exports, "InternalServerError", { enumerable: true, get: function () { return index_1.InternalServerError; } });
|
|
18
|
+
Object.defineProperty(exports, "BadGatewayError", { enumerable: true, get: function () { return index_1.BadGatewayError; } });
|
|
19
|
+
Object.defineProperty(exports, "ServiceUnavailableError", { enumerable: true, get: function () { return index_1.ServiceUnavailableError; } });
|
|
20
|
+
Object.defineProperty(exports, "GatewayTimeoutError", { enumerable: true, get: function () { return index_1.GatewayTimeoutError; } });
|
|
21
|
+
Object.defineProperty(exports, "createSpecificError", { enumerable: true, get: function () { return index_1.createSpecificError; } });
|
|
22
|
+
/**
|
|
23
|
+
* Parses fetch/network errors into a clean CMSAPIError
|
|
24
|
+
* Uses specific error types when possible for better type safety
|
|
25
|
+
*/
|
|
26
|
+
function handleApiError(error, request, response) {
|
|
27
|
+
var _a, _b, _c;
|
|
28
|
+
// Error with response from server
|
|
29
|
+
if ((error === null || error === void 0 ? void 0 : error.response) || response) {
|
|
30
|
+
const res = (error === null || error === void 0 ? void 0 : error.response) || response;
|
|
31
|
+
const statusCode = res.status || res.statusCode || 500;
|
|
32
|
+
const message = ((_a = res.data) === null || _a === void 0 ? void 0 : _a.message) ||
|
|
33
|
+
res.statusText ||
|
|
34
|
+
"Unknown API Error";
|
|
35
|
+
// Create error with request/response metadata
|
|
36
|
+
const apiError = new base_1.CMSAPIError(`CMS API Error: ${statusCode} - ${message}`, statusCode, ((_b = res.data) === null || _b === void 0 ? void 0 : _b.type) || "api_error", (_c = res.data) !== null && _c !== void 0 ? _c : error, request || (error === null || error === void 0 ? void 0 : error.request), {
|
|
37
|
+
status: statusCode,
|
|
38
|
+
statusText: res.statusText || "",
|
|
39
|
+
data: res.data,
|
|
40
|
+
headers: res.headers,
|
|
41
|
+
});
|
|
42
|
+
throw apiError;
|
|
43
|
+
}
|
|
44
|
+
// Error where request was made but no response received
|
|
45
|
+
if ((error === null || error === void 0 ? void 0 : error.request) || request) {
|
|
46
|
+
const req = (error === null || error === void 0 ? void 0 : error.request) || request;
|
|
47
|
+
const isTimeout = error.code === "ECONNABORTED" ||
|
|
48
|
+
typeof error.message === "string" &&
|
|
49
|
+
error.message.toLowerCase().includes("timeout");
|
|
50
|
+
if (isTimeout) {
|
|
51
|
+
throw new base_1.CMSAPIError("Timeout Error: CMS API did not respond in time.", 0, "timeout_error", error, req);
|
|
52
|
+
}
|
|
53
|
+
throw new base_1.CMSAPIError("Network Error: No response received from CMS API. Please check your internet connection.", 0, "network_error", error, req);
|
|
54
|
+
}
|
|
55
|
+
// Fallback: unexpected or non-network error
|
|
56
|
+
const message = (error === null || error === void 0 ? void 0 : error.message) && typeof error.message === "string"
|
|
57
|
+
? error.message
|
|
58
|
+
: "Unexpected client error while calling CMS API.";
|
|
59
|
+
throw new base_1.CMSAPIError(`Client Error: ${message}`, -1, "client_error", error);
|
|
60
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.trackSale = exports.trackLead = void 0;
|
|
4
|
+
var trackLead_1 = require("./trackLead");
|
|
5
|
+
Object.defineProperty(exports, "trackLead", { enumerable: true, get: function () { return trackLead_1.trackLead; } });
|
|
6
|
+
var trackSale_1 = require("./trackSale");
|
|
7
|
+
Object.defineProperty(exports, "trackSale", { enumerable: true, get: function () { return trackSale_1.trackSale; } });
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { CMS } from "../client";
|
|
2
|
+
import type { TrackLeadRequest, TrackResponse } from "../generated/api";
|
|
3
|
+
import { Result } from "../types/result";
|
|
4
|
+
import { CMSAPIError, BadRequestError, UnauthorizedError, ForbiddenError, NotFoundError, ConflictError, UnprocessableEntityError, RateLimitError, InternalServerError, BadGatewayError, ServiceUnavailableError, GatewayTimeoutError } from "../errors";
|
|
5
|
+
export type TrackLeadError = BadRequestError | UnauthorizedError | ForbiddenError | NotFoundError | ConflictError | UnprocessableEntityError | RateLimitError | InternalServerError | BadGatewayError | ServiceUnavailableError | GatewayTimeoutError | CMSAPIError;
|
|
6
|
+
/**
|
|
7
|
+
* Track a lead for a short link.
|
|
8
|
+
*
|
|
9
|
+
* Functional helper that returns a Result instead of throwing.
|
|
10
|
+
* This allows for explicit error handling without try/catch.
|
|
11
|
+
*
|
|
12
|
+
* @param client - The CMSSDK instance
|
|
13
|
+
* @param request - The track lead request payload
|
|
14
|
+
* @returns A Result containing either the TrackResponse or an error
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```ts
|
|
18
|
+
* import { CMS } from "cms/client";
|
|
19
|
+
* import { trackLead } from "cms/funcs/trackLead";
|
|
20
|
+
*
|
|
21
|
+
* const sdk = new CMS({ apiKey: "sk_test_123" });
|
|
22
|
+
*
|
|
23
|
+
* const res = await trackLead(sdk, {
|
|
24
|
+
* clickId: "dub_123",
|
|
25
|
+
* eventName: "signup_started",
|
|
26
|
+
* customerId: "user_42",
|
|
27
|
+
* });
|
|
28
|
+
*
|
|
29
|
+
* if (res.ok) {
|
|
30
|
+
* console.log("Success:", res.value);
|
|
31
|
+
* } else {
|
|
32
|
+
* console.error("Error:", res.error);
|
|
33
|
+
* }
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
export declare function trackLead(client: CMS, request: TrackLeadRequest): Promise<Result<TrackResponse, TrackLeadError>>;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.trackLead = trackLead;
|
|
4
|
+
const result_1 = require("../types/result");
|
|
5
|
+
const errors_1 = require("../errors");
|
|
6
|
+
/**
|
|
7
|
+
* Track a lead for a short link.
|
|
8
|
+
*
|
|
9
|
+
* Functional helper that returns a Result instead of throwing.
|
|
10
|
+
* This allows for explicit error handling without try/catch.
|
|
11
|
+
*
|
|
12
|
+
* @param client - The CMSSDK instance
|
|
13
|
+
* @param request - The track lead request payload
|
|
14
|
+
* @returns A Result containing either the TrackResponse or an error
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```ts
|
|
18
|
+
* import { CMS } from "cms/client";
|
|
19
|
+
* import { trackLead } from "cms/funcs/trackLead";
|
|
20
|
+
*
|
|
21
|
+
* const sdk = new CMS({ apiKey: "sk_test_123" });
|
|
22
|
+
*
|
|
23
|
+
* const res = await trackLead(sdk, {
|
|
24
|
+
* clickId: "dub_123",
|
|
25
|
+
* eventName: "signup_started",
|
|
26
|
+
* customerId: "user_42",
|
|
27
|
+
* });
|
|
28
|
+
*
|
|
29
|
+
* if (res.ok) {
|
|
30
|
+
* console.log("Success:", res.value);
|
|
31
|
+
* } else {
|
|
32
|
+
* console.error("Error:", res.error);
|
|
33
|
+
* }
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
async function trackLead(client, request) {
|
|
37
|
+
try {
|
|
38
|
+
const value = await client.trackLead(request);
|
|
39
|
+
return (0, result_1.ok)(value);
|
|
40
|
+
}
|
|
41
|
+
catch (error) {
|
|
42
|
+
if (error instanceof errors_1.CMSAPIError) {
|
|
43
|
+
return (0, result_1.err)(error);
|
|
44
|
+
}
|
|
45
|
+
return (0, result_1.err)(new errors_1.CMSAPIError(error instanceof Error ? error.message : "Unknown error", -1, "client_error", error));
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { CMS } from "../client";
|
|
2
|
+
import type { TrackSaleRequest, TrackResponse } from "../generated/api";
|
|
3
|
+
import { Result } from "../types/result";
|
|
4
|
+
import { CMSAPIError, BadRequestError, UnauthorizedError, ForbiddenError, NotFoundError, ConflictError, UnprocessableEntityError, RateLimitError, InternalServerError, BadGatewayError, ServiceUnavailableError, GatewayTimeoutError } from "../errors";
|
|
5
|
+
export type TrackSaleError = BadRequestError | UnauthorizedError | ForbiddenError | NotFoundError | ConflictError | UnprocessableEntityError | RateLimitError | InternalServerError | BadGatewayError | ServiceUnavailableError | GatewayTimeoutError | CMSAPIError;
|
|
6
|
+
/**
|
|
7
|
+
* Track a sale for a short link.
|
|
8
|
+
*
|
|
9
|
+
* Functional helper that returns a Result instead of throwing.
|
|
10
|
+
* This allows for explicit error handling without try/catch.
|
|
11
|
+
*
|
|
12
|
+
* @param client - The CMSSDK instance
|
|
13
|
+
* @param request - The track sale request payload
|
|
14
|
+
* @returns A Result containing either the TrackResponse or an error
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```ts
|
|
18
|
+
* import { CMS } from "cms/client";
|
|
19
|
+
* import { trackSale } from "cms/funcs/trackSale";
|
|
20
|
+
*
|
|
21
|
+
* const sdk = new CMS({ apiKey: "sk_test_123" });
|
|
22
|
+
*
|
|
23
|
+
* const res = await trackSale(sdk, {
|
|
24
|
+
* clickId: "dub_123",
|
|
25
|
+
* eventName: "purchase_completed",
|
|
26
|
+
* invoiceId: "inv_987",
|
|
27
|
+
* amount: 4999,
|
|
28
|
+
* currency: "USD",
|
|
29
|
+
* });
|
|
30
|
+
*
|
|
31
|
+
* if (res.ok) {
|
|
32
|
+
* console.log("Success:", res.value);
|
|
33
|
+
* } else {
|
|
34
|
+
* console.error("Error:", res.error);
|
|
35
|
+
* }
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
export declare function trackSale(client: CMS, request: TrackSaleRequest): Promise<Result<TrackResponse, TrackSaleError>>;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.trackSale = trackSale;
|
|
4
|
+
const result_1 = require("../types/result");
|
|
5
|
+
const errors_1 = require("../errors");
|
|
6
|
+
/**
|
|
7
|
+
* Track a sale for a short link.
|
|
8
|
+
*
|
|
9
|
+
* Functional helper that returns a Result instead of throwing.
|
|
10
|
+
* This allows for explicit error handling without try/catch.
|
|
11
|
+
*
|
|
12
|
+
* @param client - The CMSSDK instance
|
|
13
|
+
* @param request - The track sale request payload
|
|
14
|
+
* @returns A Result containing either the TrackResponse or an error
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```ts
|
|
18
|
+
* import { CMS } from "cms/client";
|
|
19
|
+
* import { trackSale } from "cms/funcs/trackSale";
|
|
20
|
+
*
|
|
21
|
+
* const sdk = new CMS({ apiKey: "sk_test_123" });
|
|
22
|
+
*
|
|
23
|
+
* const res = await trackSale(sdk, {
|
|
24
|
+
* clickId: "dub_123",
|
|
25
|
+
* eventName: "purchase_completed",
|
|
26
|
+
* invoiceId: "inv_987",
|
|
27
|
+
* amount: 4999,
|
|
28
|
+
* currency: "USD",
|
|
29
|
+
* });
|
|
30
|
+
*
|
|
31
|
+
* if (res.ok) {
|
|
32
|
+
* console.log("Success:", res.value);
|
|
33
|
+
* } else {
|
|
34
|
+
* console.error("Error:", res.error);
|
|
35
|
+
* }
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
async function trackSale(client, request) {
|
|
39
|
+
try {
|
|
40
|
+
const value = await client.trackSale(request);
|
|
41
|
+
return (0, result_1.ok)(value);
|
|
42
|
+
}
|
|
43
|
+
catch (error) {
|
|
44
|
+
if (error instanceof errors_1.CMSAPIError) {
|
|
45
|
+
return (0, result_1.err)(error);
|
|
46
|
+
}
|
|
47
|
+
return (0, result_1.err)(new errors_1.CMSAPIError(error instanceof Error ? error.message : "Unknown error", -1, "client_error", error));
|
|
48
|
+
}
|
|
49
|
+
}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CMS API
|
|
3
|
+
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
|
|
4
|
+
*
|
|
5
|
+
* The version of the OpenAPI document: 1.0.0
|
|
6
|
+
*
|
|
7
|
+
*
|
|
8
|
+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
9
|
+
* https://openapi-generator.tech
|
|
10
|
+
* Do not edit the class manually.
|
|
11
|
+
*/
|
|
12
|
+
import type { Configuration } from './configuration';
|
|
13
|
+
import type { RequestArgs, RequestOptions } from './base';
|
|
14
|
+
import { BaseAPI } from './base';
|
|
15
|
+
export interface TrackLeadRequest {
|
|
16
|
+
/**
|
|
17
|
+
* The `dub_id` from the cookie.
|
|
18
|
+
*/
|
|
19
|
+
'clickId': string;
|
|
20
|
+
'eventName': string;
|
|
21
|
+
/**
|
|
22
|
+
* Unique User ID. [cite_start]Used for deduplication (User cannot signup twice)[cite: 212].
|
|
23
|
+
*/
|
|
24
|
+
'customerId': string;
|
|
25
|
+
}
|
|
26
|
+
export interface TrackResponse {
|
|
27
|
+
'status'?: string;
|
|
28
|
+
}
|
|
29
|
+
export interface TrackSaleRequest {
|
|
30
|
+
/**
|
|
31
|
+
* The `dub_id` from the cookie.
|
|
32
|
+
*/
|
|
33
|
+
'clickId': string;
|
|
34
|
+
'eventName': string;
|
|
35
|
+
/**
|
|
36
|
+
* Unique Transaction ID. [cite_start]Used for deduplication (Charge cannot happen twice)[cite: 214].
|
|
37
|
+
*/
|
|
38
|
+
'invoiceId': string;
|
|
39
|
+
/**
|
|
40
|
+
* The value of the sale in cents.
|
|
41
|
+
*/
|
|
42
|
+
'amount': number;
|
|
43
|
+
/**
|
|
44
|
+
* Three-letter currency code.
|
|
45
|
+
*/
|
|
46
|
+
'currency': string;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* EventsApi - axios parameter creator
|
|
50
|
+
*/
|
|
51
|
+
export declare const EventsApiAxiosParamCreator: (configuration?: Configuration) => {
|
|
52
|
+
/**
|
|
53
|
+
*
|
|
54
|
+
* @summary Track a Lead
|
|
55
|
+
* @param {TrackLeadRequest} trackLeadRequest
|
|
56
|
+
* @param {*} [options] Override http request option.
|
|
57
|
+
* @throws {RequiredError}
|
|
58
|
+
*/
|
|
59
|
+
trackLead: (trackLeadRequest: TrackLeadRequest, options?: RequestOptions) => Promise<RequestArgs>;
|
|
60
|
+
/**
|
|
61
|
+
*
|
|
62
|
+
* @summary Track a Sale
|
|
63
|
+
* @param {TrackSaleRequest} trackSaleRequest
|
|
64
|
+
* @param {*} [options] Override http request option.
|
|
65
|
+
* @throws {RequiredError}
|
|
66
|
+
*/
|
|
67
|
+
trackSale: (trackSaleRequest: TrackSaleRequest, options?: RequestOptions) => Promise<RequestArgs>;
|
|
68
|
+
};
|
|
69
|
+
/**
|
|
70
|
+
* EventsApi - functional programming interface
|
|
71
|
+
*/
|
|
72
|
+
export declare const EventsApiFp: (configuration?: Configuration) => {
|
|
73
|
+
/**
|
|
74
|
+
*
|
|
75
|
+
* @summary Track a Lead
|
|
76
|
+
* @param {TrackLeadRequest} trackLeadRequest
|
|
77
|
+
* @param {*} [options] Override http request option.
|
|
78
|
+
* @throws {RequiredError}
|
|
79
|
+
*/
|
|
80
|
+
trackLead(trackLeadRequest: TrackLeadRequest, options?: RequestOptions, basePathOverride?: string): Promise<TrackResponse>;
|
|
81
|
+
/**
|
|
82
|
+
*
|
|
83
|
+
* @summary Track a Sale
|
|
84
|
+
* @param {TrackSaleRequest} trackSaleRequest
|
|
85
|
+
* @param {*} [options] Override http request option.
|
|
86
|
+
* @throws {RequiredError}
|
|
87
|
+
*/
|
|
88
|
+
trackSale(trackSaleRequest: TrackSaleRequest, options?: RequestOptions, basePathOverride?: string): Promise<TrackResponse>;
|
|
89
|
+
};
|
|
90
|
+
/**
|
|
91
|
+
* EventsApi - factory interface
|
|
92
|
+
*/
|
|
93
|
+
export declare const EventsApiFactory: (configuration?: Configuration, basePath?: string) => {
|
|
94
|
+
/**
|
|
95
|
+
*
|
|
96
|
+
* @summary Track a Lead
|
|
97
|
+
* @param {TrackLeadRequest} trackLeadRequest
|
|
98
|
+
* @param {*} [options] Override http request option.
|
|
99
|
+
* @throws {RequiredError}
|
|
100
|
+
*/
|
|
101
|
+
trackLead(trackLeadRequest: TrackLeadRequest, options?: RequestOptions): Promise<TrackResponse>;
|
|
102
|
+
/**
|
|
103
|
+
*
|
|
104
|
+
* @summary Track a Sale
|
|
105
|
+
* @param {TrackSaleRequest} trackSaleRequest
|
|
106
|
+
* @param {*} [options] Override http request option.
|
|
107
|
+
* @throws {RequiredError}
|
|
108
|
+
*/
|
|
109
|
+
trackSale(trackSaleRequest: TrackSaleRequest, options?: RequestOptions): Promise<TrackResponse>;
|
|
110
|
+
};
|
|
111
|
+
/**
|
|
112
|
+
* EventsApi - object-oriented interface
|
|
113
|
+
*/
|
|
114
|
+
export declare class EventsApi extends BaseAPI {
|
|
115
|
+
/**
|
|
116
|
+
*
|
|
117
|
+
* @summary Track a Lead
|
|
118
|
+
* @param {TrackLeadRequest} trackLeadRequest
|
|
119
|
+
* @param {*} [options] Override http request option.
|
|
120
|
+
* @throws {RequiredError}
|
|
121
|
+
*/
|
|
122
|
+
trackLead(trackLeadRequest: TrackLeadRequest, options?: RequestOptions): Promise<TrackResponse>;
|
|
123
|
+
/**
|
|
124
|
+
*
|
|
125
|
+
* @summary Track a Sale
|
|
126
|
+
* @param {TrackSaleRequest} trackSaleRequest
|
|
127
|
+
* @param {*} [options] Override http request option.
|
|
128
|
+
* @throws {RequiredError}
|
|
129
|
+
*/
|
|
130
|
+
trackSale(trackSaleRequest: TrackSaleRequest, options?: RequestOptions): Promise<TrackResponse>;
|
|
131
|
+
}
|
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* tslint:disable */
|
|
3
|
+
/* eslint-disable */
|
|
4
|
+
/**
|
|
5
|
+
* CMS API
|
|
6
|
+
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
|
|
7
|
+
*
|
|
8
|
+
* The version of the OpenAPI document: 1.0.0
|
|
9
|
+
*
|
|
10
|
+
*
|
|
11
|
+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
12
|
+
* https://openapi-generator.tech
|
|
13
|
+
* Do not edit the class manually.
|
|
14
|
+
*/
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.EventsApi = exports.EventsApiFactory = exports.EventsApiFp = exports.EventsApiAxiosParamCreator = void 0;
|
|
17
|
+
// Some imports not used depending on template conditions
|
|
18
|
+
// @ts-ignore
|
|
19
|
+
const common_1 = require("./common");
|
|
20
|
+
// @ts-ignore
|
|
21
|
+
const base_1 = require("./base");
|
|
22
|
+
/**
|
|
23
|
+
* EventsApi - axios parameter creator
|
|
24
|
+
*/
|
|
25
|
+
const EventsApiAxiosParamCreator = function (configuration) {
|
|
26
|
+
return {
|
|
27
|
+
/**
|
|
28
|
+
*
|
|
29
|
+
* @summary Track a Lead
|
|
30
|
+
* @param {TrackLeadRequest} trackLeadRequest
|
|
31
|
+
* @param {*} [options] Override http request option.
|
|
32
|
+
* @throws {RequiredError}
|
|
33
|
+
*/
|
|
34
|
+
trackLead: async (trackLeadRequest, options = {}) => {
|
|
35
|
+
// verify required parameter 'trackLeadRequest' is not null or undefined
|
|
36
|
+
(0, common_1.assertParamExists)('trackLead', 'trackLeadRequest', trackLeadRequest);
|
|
37
|
+
const localVarPath = `/track/lead`;
|
|
38
|
+
// use dummy base URL string because the URL constructor only accepts absolute URLs.
|
|
39
|
+
const localVarUrlObj = new URL(localVarPath, common_1.DUMMY_BASE_URL);
|
|
40
|
+
let baseOptions;
|
|
41
|
+
if (configuration) {
|
|
42
|
+
baseOptions = configuration.baseOptions;
|
|
43
|
+
}
|
|
44
|
+
const localVarRequestOptions = { method: 'POST', ...baseOptions, ...options };
|
|
45
|
+
const localVarHeaderParameter = {};
|
|
46
|
+
const localVarQueryParameter = {};
|
|
47
|
+
// authentication bearerAuth required
|
|
48
|
+
// http bearer authentication required
|
|
49
|
+
await (0, common_1.setBearerAuthToObject)(localVarHeaderParameter, configuration);
|
|
50
|
+
localVarHeaderParameter['Content-Type'] = 'application/json';
|
|
51
|
+
localVarHeaderParameter['Accept'] = 'application/json';
|
|
52
|
+
(0, common_1.setSearchParams)(localVarUrlObj, localVarQueryParameter);
|
|
53
|
+
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
|
|
54
|
+
localVarRequestOptions.headers = { ...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers };
|
|
55
|
+
localVarRequestOptions.data = (0, common_1.serializeDataIfNeeded)(trackLeadRequest, localVarRequestOptions, configuration);
|
|
56
|
+
return {
|
|
57
|
+
url: (0, common_1.toPathString)(localVarUrlObj),
|
|
58
|
+
options: localVarRequestOptions,
|
|
59
|
+
};
|
|
60
|
+
},
|
|
61
|
+
/**
|
|
62
|
+
*
|
|
63
|
+
* @summary Track a Sale
|
|
64
|
+
* @param {TrackSaleRequest} trackSaleRequest
|
|
65
|
+
* @param {*} [options] Override http request option.
|
|
66
|
+
* @throws {RequiredError}
|
|
67
|
+
*/
|
|
68
|
+
trackSale: async (trackSaleRequest, options = {}) => {
|
|
69
|
+
// verify required parameter 'trackSaleRequest' is not null or undefined
|
|
70
|
+
(0, common_1.assertParamExists)('trackSale', 'trackSaleRequest', trackSaleRequest);
|
|
71
|
+
const localVarPath = `/track/sale`;
|
|
72
|
+
// use dummy base URL string because the URL constructor only accepts absolute URLs.
|
|
73
|
+
const localVarUrlObj = new URL(localVarPath, common_1.DUMMY_BASE_URL);
|
|
74
|
+
let baseOptions;
|
|
75
|
+
if (configuration) {
|
|
76
|
+
baseOptions = configuration.baseOptions;
|
|
77
|
+
}
|
|
78
|
+
const localVarRequestOptions = { method: 'POST', ...baseOptions, ...options };
|
|
79
|
+
const localVarHeaderParameter = {};
|
|
80
|
+
const localVarQueryParameter = {};
|
|
81
|
+
// authentication bearerAuth required
|
|
82
|
+
// http bearer authentication required
|
|
83
|
+
await (0, common_1.setBearerAuthToObject)(localVarHeaderParameter, configuration);
|
|
84
|
+
localVarHeaderParameter['Content-Type'] = 'application/json';
|
|
85
|
+
localVarHeaderParameter['Accept'] = 'application/json';
|
|
86
|
+
(0, common_1.setSearchParams)(localVarUrlObj, localVarQueryParameter);
|
|
87
|
+
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
|
|
88
|
+
localVarRequestOptions.headers = { ...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers };
|
|
89
|
+
localVarRequestOptions.data = (0, common_1.serializeDataIfNeeded)(trackSaleRequest, localVarRequestOptions, configuration);
|
|
90
|
+
return {
|
|
91
|
+
url: (0, common_1.toPathString)(localVarUrlObj),
|
|
92
|
+
options: localVarRequestOptions,
|
|
93
|
+
};
|
|
94
|
+
},
|
|
95
|
+
};
|
|
96
|
+
};
|
|
97
|
+
exports.EventsApiAxiosParamCreator = EventsApiAxiosParamCreator;
|
|
98
|
+
/**
|
|
99
|
+
* EventsApi - functional programming interface
|
|
100
|
+
*/
|
|
101
|
+
const EventsApiFp = function (configuration) {
|
|
102
|
+
const localVarAxiosParamCreator = (0, exports.EventsApiAxiosParamCreator)(configuration);
|
|
103
|
+
return {
|
|
104
|
+
/**
|
|
105
|
+
*
|
|
106
|
+
* @summary Track a Lead
|
|
107
|
+
* @param {TrackLeadRequest} trackLeadRequest
|
|
108
|
+
* @param {*} [options] Override http request option.
|
|
109
|
+
* @throws {RequiredError}
|
|
110
|
+
*/
|
|
111
|
+
async trackLead(trackLeadRequest, options, basePathOverride) {
|
|
112
|
+
var _a, _b, _c, _d, _e;
|
|
113
|
+
const localVarAxiosArgs = await localVarAxiosParamCreator.trackLead(trackLeadRequest, options !== null && options !== void 0 ? options : {});
|
|
114
|
+
const localVarOperationServerIndex = (_a = configuration === null || configuration === void 0 ? void 0 : configuration.serverIndex) !== null && _a !== void 0 ? _a : 0;
|
|
115
|
+
const localVarOperationServerBasePath = (_c = (_b = base_1.operationServerMap['EventsApi.trackLead']) === null || _b === void 0 ? void 0 : _b[localVarOperationServerIndex]) === null || _c === void 0 ? void 0 : _c.url;
|
|
116
|
+
const basePath = (_e = (_d = basePathOverride !== null && basePathOverride !== void 0 ? basePathOverride : localVarOperationServerBasePath) !== null && _d !== void 0 ? _d : configuration === null || configuration === void 0 ? void 0 : configuration.basePath) !== null && _e !== void 0 ? _e : base_1.BASE_PATH;
|
|
117
|
+
return performFetchRequest(localVarAxiosArgs, basePath);
|
|
118
|
+
},
|
|
119
|
+
/**
|
|
120
|
+
*
|
|
121
|
+
* @summary Track a Sale
|
|
122
|
+
* @param {TrackSaleRequest} trackSaleRequest
|
|
123
|
+
* @param {*} [options] Override http request option.
|
|
124
|
+
* @throws {RequiredError}
|
|
125
|
+
*/
|
|
126
|
+
async trackSale(trackSaleRequest, options, basePathOverride) {
|
|
127
|
+
var _a, _b, _c, _d, _e;
|
|
128
|
+
const localVarAxiosArgs = await localVarAxiosParamCreator.trackSale(trackSaleRequest, options !== null && options !== void 0 ? options : {});
|
|
129
|
+
const localVarOperationServerIndex = (_a = configuration === null || configuration === void 0 ? void 0 : configuration.serverIndex) !== null && _a !== void 0 ? _a : 0;
|
|
130
|
+
const localVarOperationServerBasePath = (_c = (_b = base_1.operationServerMap['EventsApi.trackSale']) === null || _b === void 0 ? void 0 : _b[localVarOperationServerIndex]) === null || _c === void 0 ? void 0 : _c.url;
|
|
131
|
+
const basePath = (_e = (_d = basePathOverride !== null && basePathOverride !== void 0 ? basePathOverride : localVarOperationServerBasePath) !== null && _d !== void 0 ? _d : configuration === null || configuration === void 0 ? void 0 : configuration.basePath) !== null && _e !== void 0 ? _e : base_1.BASE_PATH;
|
|
132
|
+
return performFetchRequest(localVarAxiosArgs, basePath);
|
|
133
|
+
},
|
|
134
|
+
};
|
|
135
|
+
};
|
|
136
|
+
exports.EventsApiFp = EventsApiFp;
|
|
137
|
+
/**
|
|
138
|
+
* EventsApi - factory interface
|
|
139
|
+
*/
|
|
140
|
+
const EventsApiFactory = function (configuration, basePath) {
|
|
141
|
+
const localVarFp = (0, exports.EventsApiFp)(configuration);
|
|
142
|
+
return {
|
|
143
|
+
/**
|
|
144
|
+
*
|
|
145
|
+
* @summary Track a Lead
|
|
146
|
+
* @param {TrackLeadRequest} trackLeadRequest
|
|
147
|
+
* @param {*} [options] Override http request option.
|
|
148
|
+
* @throws {RequiredError}
|
|
149
|
+
*/
|
|
150
|
+
trackLead(trackLeadRequest, options) {
|
|
151
|
+
return localVarFp.trackLead(trackLeadRequest, options, basePath);
|
|
152
|
+
},
|
|
153
|
+
/**
|
|
154
|
+
*
|
|
155
|
+
* @summary Track a Sale
|
|
156
|
+
* @param {TrackSaleRequest} trackSaleRequest
|
|
157
|
+
* @param {*} [options] Override http request option.
|
|
158
|
+
* @throws {RequiredError}
|
|
159
|
+
*/
|
|
160
|
+
trackSale(trackSaleRequest, options) {
|
|
161
|
+
return localVarFp.trackSale(trackSaleRequest, options, basePath);
|
|
162
|
+
},
|
|
163
|
+
};
|
|
164
|
+
};
|
|
165
|
+
exports.EventsApiFactory = EventsApiFactory;
|
|
166
|
+
/**
|
|
167
|
+
* EventsApi - object-oriented interface
|
|
168
|
+
*/
|
|
169
|
+
class EventsApi extends base_1.BaseAPI {
|
|
170
|
+
/**
|
|
171
|
+
*
|
|
172
|
+
* @summary Track a Lead
|
|
173
|
+
* @param {TrackLeadRequest} trackLeadRequest
|
|
174
|
+
* @param {*} [options] Override http request option.
|
|
175
|
+
* @throws {RequiredError}
|
|
176
|
+
*/
|
|
177
|
+
trackLead(trackLeadRequest, options) {
|
|
178
|
+
return (0, exports.EventsApiFp)(this.configuration).trackLead(trackLeadRequest, options, this.basePath);
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
*
|
|
182
|
+
* @summary Track a Sale
|
|
183
|
+
* @param {TrackSaleRequest} trackSaleRequest
|
|
184
|
+
* @param {*} [options] Override http request option.
|
|
185
|
+
* @throws {RequiredError}
|
|
186
|
+
*/
|
|
187
|
+
trackSale(trackSaleRequest, options) {
|
|
188
|
+
return (0, exports.EventsApiFp)(this.configuration).trackSale(trackSaleRequest, options, this.basePath);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
exports.EventsApi = EventsApi;
|
|
192
|
+
/**
|
|
193
|
+
* Internal helper that performs a fetch request based on the generated
|
|
194
|
+
* `RequestArgs` and normalizes errors into an Axios-like shape so the
|
|
195
|
+
* existing error handling and retry logic in the SDK can continue to
|
|
196
|
+
* operate without changes.
|
|
197
|
+
*/
|
|
198
|
+
async function performFetchRequest(requestArgs, basePath) {
|
|
199
|
+
const url = (basePath !== null && basePath !== void 0 ? basePath : base_1.BASE_PATH).replace(/\/+$/, "") + requestArgs.url;
|
|
200
|
+
const { timeout, ...restOptions } = requestArgs.options;
|
|
201
|
+
if (typeof fetch !== "function") {
|
|
202
|
+
throw new Error("Global fetch API is not available. Please provide a fetch polyfill in this environment.");
|
|
203
|
+
}
|
|
204
|
+
const controller = typeof AbortController !== "undefined" ? new AbortController() : undefined;
|
|
205
|
+
const signal = controller === null || controller === void 0 ? void 0 : controller.signal;
|
|
206
|
+
let timeoutId;
|
|
207
|
+
if (controller && typeof timeout === "number" && timeout > 0) {
|
|
208
|
+
timeoutId = setTimeout(() => controller.abort(), timeout);
|
|
209
|
+
}
|
|
210
|
+
try {
|
|
211
|
+
const response = await fetch(url, { ...restOptions, signal });
|
|
212
|
+
const contentType = response.headers.get("content-type") || "";
|
|
213
|
+
const isJson = contentType.toLowerCase().includes("application/json");
|
|
214
|
+
const data = isJson ? await response.json() : await response.text();
|
|
215
|
+
if (!response.ok) {
|
|
216
|
+
const error = new Error(`Request failed with status code ${response.status}`);
|
|
217
|
+
error.response = {
|
|
218
|
+
status: response.status,
|
|
219
|
+
statusText: response.statusText,
|
|
220
|
+
data,
|
|
221
|
+
};
|
|
222
|
+
throw error;
|
|
223
|
+
}
|
|
224
|
+
return data;
|
|
225
|
+
}
|
|
226
|
+
catch (err) {
|
|
227
|
+
// Normalize fetch/AbortError/network errors into an Axios-style shape
|
|
228
|
+
if ((err === null || err === void 0 ? void 0 : err.name) === "AbortError") {
|
|
229
|
+
err.code = "ECONNABORTED";
|
|
230
|
+
}
|
|
231
|
+
if (!err.response) {
|
|
232
|
+
err.request = {
|
|
233
|
+
url,
|
|
234
|
+
options: requestArgs.options,
|
|
235
|
+
};
|
|
236
|
+
}
|
|
237
|
+
throw err;
|
|
238
|
+
}
|
|
239
|
+
finally {
|
|
240
|
+
if (timeoutId) {
|
|
241
|
+
clearTimeout(timeoutId);
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CMS API
|
|
3
|
+
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
|
|
4
|
+
*
|
|
5
|
+
* The version of the OpenAPI document: 1.0.0
|
|
6
|
+
*
|
|
7
|
+
*
|
|
8
|
+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
9
|
+
* https://openapi-generator.tech
|
|
10
|
+
* Do not edit the class manually.
|
|
11
|
+
*/
|
|
12
|
+
import type { Configuration } from './configuration';
|
|
13
|
+
export type RequestOptions = RequestInit & {
|
|
14
|
+
/**
|
|
15
|
+
* Optional request timeout in milliseconds.
|
|
16
|
+
* When provided, the client will abort the request after this duration.
|
|
17
|
+
*/
|
|
18
|
+
timeout?: number;
|
|
19
|
+
/**
|
|
20
|
+
* Optional headers bag. This stays loosely typed to be compatible with
|
|
21
|
+
* any existing code that spreads arbitrary objects into headers.
|
|
22
|
+
*/
|
|
23
|
+
headers?: Record<string, any>;
|
|
24
|
+
};
|
|
25
|
+
export declare const BASE_PATH: string;
|
|
26
|
+
export declare const COLLECTION_FORMATS: {
|
|
27
|
+
csv: string;
|
|
28
|
+
ssv: string;
|
|
29
|
+
tsv: string;
|
|
30
|
+
pipes: string;
|
|
31
|
+
};
|
|
32
|
+
export interface RequestArgs {
|
|
33
|
+
url: string;
|
|
34
|
+
options: RequestOptions;
|
|
35
|
+
}
|
|
36
|
+
export declare class BaseAPI {
|
|
37
|
+
protected configuration: Configuration | undefined;
|
|
38
|
+
protected basePath: string;
|
|
39
|
+
/**
|
|
40
|
+
* Minimal base class that stores configuration and basePath.
|
|
41
|
+
* Concrete API classes are responsible for performing requests using
|
|
42
|
+
* the global `fetch` (or any polyfill provided by the consumer).
|
|
43
|
+
*/
|
|
44
|
+
constructor(configuration?: Configuration, basePath?: string);
|
|
45
|
+
}
|
|
46
|
+
export declare class RequiredError extends Error {
|
|
47
|
+
field: string;
|
|
48
|
+
constructor(field: string, msg?: string);
|
|
49
|
+
}
|
|
50
|
+
interface ServerMap {
|
|
51
|
+
[key: string]: {
|
|
52
|
+
url: string;
|
|
53
|
+
description: string;
|
|
54
|
+
}[];
|
|
55
|
+
}
|
|
56
|
+
export declare const operationServerMap: ServerMap;
|
|
57
|
+
export {};
|