@short.io/client-node 1.1.0 → 2.0.1
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/README.md +29 -39
- package/dist/index.d.ts +2 -54
- package/dist/index.js +2 -437
- package/dist/index.js.map +1 -1
- package/dist/sdk.gen.d.ts +476 -0
- package/dist/sdk.gen.js +323 -0
- package/dist/sdk.gen.js.map +1 -0
- package/dist/types.gen.d.ts +1198 -0
- package/dist/types.gen.js +2 -0
- package/dist/types.gen.js.map +1 -0
- package/package.json +22 -10
- package/.eslintignore +0 -1
- package/.eslintrc.cjs +0 -3
- package/dist/types/common.d.ts +0 -9
- package/dist/types/common.js +0 -2
- package/dist/types/common.js.map +0 -1
- package/dist/types/domain.d.ts +0 -43
- package/dist/types/domain.js +0 -2
- package/dist/types/domain.js.map +0 -1
- package/dist/types/index.d.ts +0 -4
- package/dist/types/index.js +0 -5
- package/dist/types/index.js.map +0 -1
- package/dist/types/link.d.ts +0 -131
- package/dist/types/link.js +0 -2
- package/dist/types/link.js.map +0 -1
- package/dist/types/statistics.d.ts +0 -199
- package/dist/types/statistics.js +0 -2
- package/dist/types/statistics.js.map +0 -1
- package/dist/types.d.ts +0 -1
- package/dist/types.js +0 -2
- package/dist/types.js.map +0 -1
- package/renovate.json +0 -6
- package/src/index.ts +0 -830
- package/src/types/common.ts +0 -11
- package/src/types/domain.ts +0 -44
- package/src/types/index.ts +0 -4
- package/src/types/link.ts +0 -159
- package/src/types/statistics.ts +0 -242
- package/tsconfig.json +0 -20
package/README.md
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
# Short.io Node.js SDK
|
|
2
2
|
|
|
3
3
|
The Short.io Node.js official SDK client is a library that allows you to integrate [short.io](https://short.io) URL shortening and link management API with your Node.js application in an easy and elegant way.
|
|
4
|
+
This SDK contains methods for working with links and domains.
|
|
4
5
|
|
|
5
6
|
## API reference
|
|
6
7
|
|
|
@@ -8,7 +9,7 @@ See the [API docs](https://developers.short.io/reference) for more information.
|
|
|
8
9
|
|
|
9
10
|
## Installing
|
|
10
11
|
|
|
11
|
-
To install
|
|
12
|
+
To install the SDK, run:
|
|
12
13
|
|
|
13
14
|
```sh
|
|
14
15
|
npm i @short.io/client-node
|
|
@@ -17,59 +18,48 @@ npm i @short.io/client-node
|
|
|
17
18
|
## Getting Started
|
|
18
19
|
|
|
19
20
|
First you need to get your API key from the Short.io dashboard in the [Integrations & API](https://app.short.io/settings/integrations/api-key) section.
|
|
20
|
-
|
|
21
|
+
Then you need to set the configuration for the client:
|
|
21
22
|
|
|
22
23
|
```js
|
|
23
|
-
import {
|
|
24
|
-
```
|
|
25
|
-
|
|
26
|
-
## Usage
|
|
27
|
-
|
|
28
|
-
Then create an instance of the Shortio class, and pass your API key as the first parameter:
|
|
24
|
+
import { client } from "@short.io/client-node";
|
|
29
25
|
|
|
30
|
-
|
|
31
|
-
|
|
26
|
+
client.setConfig({
|
|
27
|
+
baseUrl: "https://api.short.io",
|
|
28
|
+
headers: {
|
|
29
|
+
Authorization: "YOUR_API_KEY",
|
|
30
|
+
},
|
|
31
|
+
});
|
|
32
32
|
```
|
|
33
33
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
```js
|
|
37
|
-
const domains = await shortio.domain.list();
|
|
38
|
-
```
|
|
34
|
+
## Usage
|
|
39
35
|
|
|
40
|
-
|
|
36
|
+
Import the needed methods from the SDK and use them in your code:
|
|
41
37
|
|
|
42
38
|
```js
|
|
43
|
-
|
|
39
|
+
import {
|
|
40
|
+
client,
|
|
41
|
+
getApiDomains,
|
|
42
|
+
getLinksExpand,
|
|
43
|
+
// and other needed methods
|
|
44
|
+
} from "@short.io/client-node";
|
|
44
45
|
```
|
|
45
46
|
|
|
46
|
-
|
|
47
|
+
Pass created client to the methods:
|
|
47
48
|
|
|
48
49
|
```js
|
|
49
|
-
const
|
|
50
|
+
const domainsResp = await getApiDomains({ client });
|
|
50
51
|
```
|
|
51
52
|
|
|
52
|
-
|
|
53
|
+
`domainsResp.data` will contain the list of domains.
|
|
53
54
|
|
|
54
55
|
```js
|
|
55
|
-
const
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
56
|
+
const linkResp = await getLinksExpand({
|
|
57
|
+
client,
|
|
58
|
+
query: {
|
|
59
|
+
domain: "your_domain.com",
|
|
60
|
+
path: "lnk_abc123_abcde12345,
|
|
61
|
+
},
|
|
59
62
|
});
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
const publicLink = await shortio.link.createPublic({
|
|
63
|
-
domain: "link.example.com",
|
|
64
|
-
originalURL: "https://example.com",
|
|
65
|
-
publicAPIKey: "PUBLIC_API_KEY",
|
|
66
|
-
});
|
|
67
|
-
console.log(publicLink.shortURL); // https://link.example.com/a83t48
|
|
63
|
+
```
|
|
68
64
|
|
|
69
|
-
|
|
70
|
-
domain: "link.example.com",
|
|
71
|
-
publicAPIKey: "PUBLIC_API_KEY",
|
|
72
|
-
originalURL: "https://example.com",
|
|
73
|
-
});
|
|
74
|
-
console.log(secureLink.shortURL); // https://link.example.com/a83t48#ta95me8
|
|
75
|
-
```
|
|
65
|
+
`linkResp.data` will contain the expanded link.
|
package/dist/index.d.ts
CHANGED
|
@@ -1,54 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import { DeleteLinkRes, GetLinkQRCodeOptions, Link, LinkBulkCreateOptions, LinkCountry, LinkCountryCreateOptions, LinkCreateOptions, LinkListOptions, LinkOpenGraphData, LinkRegion, LinkRegionCreateOptions, LinkRegionDeleteOptions, LinkUpdateOptions, LinkWithUser, LinksAndCount, UpdateLinkErrorRes } from "./types/link.js";
|
|
4
|
-
import { Column, DomainStatistics, FilterOptions, GetLastClicksOptions, GetStatisticsOptions, IncludeExcludeOptions, LastClicksRes, LinkClicks, LinkIds, LinkStatistics, PathClicks, PathDate, StartEndDate, TopByColumnOptions, TopByIntervalOptions, TopByIntervalRes, TopColumnRes } from "./types/statistics.js";
|
|
5
|
-
export declare class Shortio {
|
|
6
|
-
private readonly apiKey;
|
|
7
|
-
private readonly baseApiUrl;
|
|
8
|
-
private readonly baseStatisticsUrl;
|
|
9
|
-
constructor(apiKey: string);
|
|
10
|
-
readonly link: {
|
|
11
|
-
list: (domainId: Domain["id"], options?: LinkListOptions) => Promise<LinksAndCount | ErrorResBody>;
|
|
12
|
-
getByPath: (hostname: Domain["hostname"], path: Link["path"]) => Promise<Link | ErrorResBody>;
|
|
13
|
-
getByOriginalURL: (hostname: Domain["hostname"], originalURL: Link["originalURL"]) => Promise<Link | ErrorResBody>;
|
|
14
|
-
create: (hostname: Domain["hostname"], originalURL: Link["originalURL"], options?: LinkCreateOptions) => Promise<Link | ErrorResBody>;
|
|
15
|
-
createPublic: (hostname: Domain["hostname"], originalURL: Link["originalURL"], publicAPIKey: string, options?: LinkCreateOptions) => Promise<Link | (SuccessResBody & ErrorResBody)>;
|
|
16
|
-
createSecure: (hostname: Domain["hostname"], originalURL: Link["originalURL"], publicAPIKey: string, options?: LinkCreateOptions) => Promise<Link | ErrorResBody>;
|
|
17
|
-
bulkCreate: (hostname: Domain["hostname"], links: LinkBulkCreateOptions[], allowDuplicates?: boolean) => Promise<(Link & SuccessResBody)[] | (SuccessResBody & ErrorResBody & StatusResBody)>;
|
|
18
|
-
archive: (linkIdString: Link["idString"]) => Promise<SuccessResBody | ErrorResBody>;
|
|
19
|
-
update: (linkIdString: Link["idString"], options: LinkUpdateOptions) => Promise<LinkWithUser | UpdateLinkErrorRes>;
|
|
20
|
-
delete: (linkIdString: Link["idString"]) => Promise<DeleteLinkRes | ErrorResBody>;
|
|
21
|
-
generateQRCode: (linkIdString: Link["idString"], options?: GetLinkQRCodeOptions) => Promise<ErrorResBody | Buffer>;
|
|
22
|
-
getOpenGraph: (domainId: Domain["id"], linkIdString: Link["idString"]) => Promise<LinkOpenGraphData | ErrorResBody>;
|
|
23
|
-
updateOpenGraph: (domainId: Domain["id"], linkIdString: Link["idString"], newOpenGraphData: LinkOpenGraphData) => Promise<LinkOpenGraphData | ErrorResBody>;
|
|
24
|
-
};
|
|
25
|
-
readonly domain: {
|
|
26
|
-
list: () => Promise<Domain[] | ErrorResBody>;
|
|
27
|
-
create: (hostname: Domain["hostname"], options?: DomainCreateOptions) => Promise<Domain | ErrorResBody>;
|
|
28
|
-
};
|
|
29
|
-
readonly linkCountry: {
|
|
30
|
-
list: (linkIdString: Link["idString"]) => Promise<LinkCountry[] | ErrorResBody>;
|
|
31
|
-
create: (linkIdString: Link["idString"], options: LinkCountryCreateOptions) => Promise<LinkCountry | ErrorResBody>;
|
|
32
|
-
delete: (linkIdString: Link["idString"], country: LinkCountry["country"]) => Promise<SuccessResBody | ErrorResBody>;
|
|
33
|
-
};
|
|
34
|
-
readonly linkRegion: {
|
|
35
|
-
list: (linkIdString: Link["idString"]) => Promise<LinkRegion[] | ErrorResBody>;
|
|
36
|
-
create: (linkIdString: Link["idString"], options: LinkRegionCreateOptions) => Promise<LinkRegion | ErrorResBody>;
|
|
37
|
-
delete: (linkIdString: Link["idString"], options: LinkRegionDeleteOptions) => Promise<SuccessResBody | ErrorResBody>;
|
|
38
|
-
};
|
|
39
|
-
readonly statistics: {
|
|
40
|
-
getByLink: (linkIdString: Link["idString"], options?: GetStatisticsOptions) => Promise<LinkStatistics | ErrorResBody>;
|
|
41
|
-
getByLinkPost: (linkIdString: Link["idString"], options?: GetStatisticsOptions & {
|
|
42
|
-
include?: FilterOptions;
|
|
43
|
-
exclude?: FilterOptions;
|
|
44
|
-
}) => Promise<LinkStatistics | ErrorResBody>;
|
|
45
|
-
getByDomain: (domainId: Domain["id"], options?: GetStatisticsOptions) => Promise<DomainStatistics | ErrorResBody>;
|
|
46
|
-
getByDomainPost: (domainId: Domain["id"], options?: GetStatisticsOptions & IncludeExcludeOptions) => Promise<DomainStatistics | ErrorResBody>;
|
|
47
|
-
getLinkClicks: (domainId: Domain["id"], options: StartEndDate & LinkIds) => Promise<LinkClicks | ErrorResBody>;
|
|
48
|
-
getLinkClicksByPathDates: (domainId: Domain["id"], pathsDates: PathDate[], options?: StartEndDate) => Promise<PathClicks | ErrorResBody>;
|
|
49
|
-
getTopByColumn: (domainId: Domain["id"], column: Column, options?: TopByColumnOptions) => Promise<TopColumnRes[]>;
|
|
50
|
-
getTopByInterval: (domainId: Domain["id"], column: Column, options?: TopByIntervalOptions) => Promise<TopByIntervalRes[] | ErrorResBody>;
|
|
51
|
-
getLastClicks: (domainId: Domain["id"], options?: GetLastClicksOptions) => Promise<LastClicksRes | ErrorResBody>;
|
|
52
|
-
clear: (domainId: Domain["id"]) => Promise<SuccessResBody | ErrorResBody>;
|
|
53
|
-
};
|
|
54
|
-
}
|
|
1
|
+
export * from "./types.gen.js";
|
|
2
|
+
export * from "./sdk.gen.js";
|
package/dist/index.js
CHANGED
|
@@ -1,438 +1,3 @@
|
|
|
1
|
-
export
|
|
2
|
-
|
|
3
|
-
baseApiUrl = "https://api.short.io";
|
|
4
|
-
baseStatisticsUrl = "https://api-v2.short.cm/statistics";
|
|
5
|
-
constructor(apiKey) {
|
|
6
|
-
this.apiKey = apiKey;
|
|
7
|
-
}
|
|
8
|
-
link = {
|
|
9
|
-
list: async (domainId, options) => {
|
|
10
|
-
let queryString = `domain_id=${domainId}`;
|
|
11
|
-
if (options) {
|
|
12
|
-
for (const param in options) {
|
|
13
|
-
queryString += `&${param}=${options[param]}`;
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
const linksRes = await fetch(`${this.baseApiUrl}/api/links?${queryString}`, {
|
|
17
|
-
method: "GET",
|
|
18
|
-
headers: {
|
|
19
|
-
"Content-Type": "application/json",
|
|
20
|
-
Authorization: this.apiKey,
|
|
21
|
-
},
|
|
22
|
-
});
|
|
23
|
-
const linksData = await linksRes.json();
|
|
24
|
-
return linksData;
|
|
25
|
-
},
|
|
26
|
-
getByPath: async (hostname, path) => {
|
|
27
|
-
const queryString = `domain=${hostname}&path=${path}`;
|
|
28
|
-
const linkInfoRes = await fetch(`${this.baseApiUrl}/links/expand?${queryString}`, {
|
|
29
|
-
method: "GET",
|
|
30
|
-
headers: {
|
|
31
|
-
"Content-Type": "application/json",
|
|
32
|
-
Authorization: this.apiKey,
|
|
33
|
-
},
|
|
34
|
-
});
|
|
35
|
-
const linkInfo = await linkInfoRes.json();
|
|
36
|
-
return linkInfo;
|
|
37
|
-
},
|
|
38
|
-
getByOriginalURL: async (hostname, originalURL) => {
|
|
39
|
-
const queryString = `domain=${hostname}&originalURL=${originalURL}`;
|
|
40
|
-
const linkInfoRes = await fetch(`${this.baseApiUrl}/links/by-original-url?${queryString}`, {
|
|
41
|
-
method: "GET",
|
|
42
|
-
headers: {
|
|
43
|
-
"Content-Type": "application/json",
|
|
44
|
-
Authorization: this.apiKey,
|
|
45
|
-
},
|
|
46
|
-
});
|
|
47
|
-
const linkInfo = await linkInfoRes.json();
|
|
48
|
-
return linkInfo;
|
|
49
|
-
},
|
|
50
|
-
create: async (hostname, originalURL, options) => {
|
|
51
|
-
const linkRes = await fetch(`${this.baseApiUrl}/links`, {
|
|
52
|
-
method: "POST",
|
|
53
|
-
headers: {
|
|
54
|
-
"Content-Type": "application/json",
|
|
55
|
-
Authorization: this.apiKey,
|
|
56
|
-
},
|
|
57
|
-
body: JSON.stringify({
|
|
58
|
-
domain: hostname,
|
|
59
|
-
originalURL,
|
|
60
|
-
...options,
|
|
61
|
-
}),
|
|
62
|
-
});
|
|
63
|
-
const link = await linkRes.json();
|
|
64
|
-
return link;
|
|
65
|
-
},
|
|
66
|
-
createPublic: async (hostname, originalURL, publicAPIKey, options) => {
|
|
67
|
-
const linkRes = await fetch(`${this.baseApiUrl}/links/public`, {
|
|
68
|
-
method: "POST",
|
|
69
|
-
headers: {
|
|
70
|
-
"Content-Type": "application/json",
|
|
71
|
-
Authorization: publicAPIKey,
|
|
72
|
-
},
|
|
73
|
-
body: JSON.stringify({
|
|
74
|
-
domain: hostname,
|
|
75
|
-
originalURL,
|
|
76
|
-
...options,
|
|
77
|
-
}),
|
|
78
|
-
});
|
|
79
|
-
const link = (await linkRes.json());
|
|
80
|
-
return link;
|
|
81
|
-
},
|
|
82
|
-
createSecure: async (hostname, originalURL, publicAPIKey, options) => {
|
|
83
|
-
const cryptoKey = await crypto.subtle.generateKey({
|
|
84
|
-
name: "AES-GCM",
|
|
85
|
-
length: 128,
|
|
86
|
-
}, true, ["encrypt", "decrypt"]);
|
|
87
|
-
const iv = crypto.getRandomValues(new Uint8Array(12));
|
|
88
|
-
const urlData = new TextEncoder().encode(originalURL);
|
|
89
|
-
const encryptedUrl = await crypto.subtle.encrypt({
|
|
90
|
-
name: "AES-GCM",
|
|
91
|
-
iv,
|
|
92
|
-
}, cryptoKey, urlData);
|
|
93
|
-
const encryptedUrlBase64 = Buffer.from(encryptedUrl).toString("base64");
|
|
94
|
-
const encryptedIvBase64 = Buffer.from(iv).toString("base64");
|
|
95
|
-
const encryptedData = `shortsecure://${encryptedUrlBase64}?${encryptedIvBase64}`;
|
|
96
|
-
const link = (await this.link.createPublic(hostname, encryptedData, publicAPIKey, options));
|
|
97
|
-
if ("error" in link) {
|
|
98
|
-
return {
|
|
99
|
-
error: link.error,
|
|
100
|
-
};
|
|
101
|
-
}
|
|
102
|
-
const exportedKey = await crypto.subtle.exportKey("raw", cryptoKey);
|
|
103
|
-
const keyBase64 = Buffer.from(new Uint8Array(exportedKey)).toString("base64");
|
|
104
|
-
link.shortURL += `#${keyBase64}`;
|
|
105
|
-
link.secureShortURL += `#${keyBase64}`;
|
|
106
|
-
return link;
|
|
107
|
-
},
|
|
108
|
-
bulkCreate: async (hostname, links, allowDuplicates = false) => {
|
|
109
|
-
const linkRes = await fetch(`${this.baseApiUrl}/links/bulk`, {
|
|
110
|
-
method: "POST",
|
|
111
|
-
headers: {
|
|
112
|
-
"Content-Type": "application/json",
|
|
113
|
-
Authorization: this.apiKey,
|
|
114
|
-
},
|
|
115
|
-
body: JSON.stringify({
|
|
116
|
-
domain: hostname,
|
|
117
|
-
links,
|
|
118
|
-
allowDuplicates,
|
|
119
|
-
}),
|
|
120
|
-
});
|
|
121
|
-
const link = await linkRes.json();
|
|
122
|
-
return link;
|
|
123
|
-
},
|
|
124
|
-
archive: async (linkIdString) => {
|
|
125
|
-
const res = await fetch(`${this.baseApiUrl}/links/archive`, {
|
|
126
|
-
method: "POST",
|
|
127
|
-
headers: {
|
|
128
|
-
"Content-Type": "application/json",
|
|
129
|
-
Authorization: this.apiKey,
|
|
130
|
-
},
|
|
131
|
-
body: JSON.stringify({
|
|
132
|
-
link_id: linkIdString,
|
|
133
|
-
}),
|
|
134
|
-
});
|
|
135
|
-
const linkArchiveRes = await res.json();
|
|
136
|
-
return linkArchiveRes;
|
|
137
|
-
},
|
|
138
|
-
update: async (linkIdString, options) => {
|
|
139
|
-
const res = await fetch(`${this.baseApiUrl}/links/${linkIdString}`, {
|
|
140
|
-
method: "POST",
|
|
141
|
-
headers: {
|
|
142
|
-
"Content-Type": "application/json",
|
|
143
|
-
Authorization: this.apiKey,
|
|
144
|
-
},
|
|
145
|
-
body: JSON.stringify(options),
|
|
146
|
-
});
|
|
147
|
-
const linkUpdateRes = await res.json();
|
|
148
|
-
return linkUpdateRes;
|
|
149
|
-
},
|
|
150
|
-
delete: async (linkIdString) => {
|
|
151
|
-
const res = await fetch(`${this.baseApiUrl}/links/${linkIdString}`, {
|
|
152
|
-
method: "DELETE",
|
|
153
|
-
headers: {
|
|
154
|
-
"Content-Type": "application/json",
|
|
155
|
-
Authorization: this.apiKey,
|
|
156
|
-
},
|
|
157
|
-
});
|
|
158
|
-
const linkDeleteRes = await res.json();
|
|
159
|
-
return linkDeleteRes;
|
|
160
|
-
},
|
|
161
|
-
generateQRCode: async (linkIdString, options) => {
|
|
162
|
-
const res = await fetch(`${this.baseApiUrl}/links/qr/${linkIdString}`, {
|
|
163
|
-
method: "POST",
|
|
164
|
-
headers: {
|
|
165
|
-
"Content-Type": "application/json",
|
|
166
|
-
Authorization: this.apiKey,
|
|
167
|
-
},
|
|
168
|
-
body: JSON.stringify(options),
|
|
169
|
-
});
|
|
170
|
-
const buffer = Buffer.from(await res.arrayBuffer());
|
|
171
|
-
return buffer;
|
|
172
|
-
},
|
|
173
|
-
getOpenGraph: async (domainId, linkIdString) => {
|
|
174
|
-
const res = await fetch(`${this.baseApiUrl}/links/opengraph/${domainId}/${linkIdString}`, {
|
|
175
|
-
method: "GET",
|
|
176
|
-
headers: {
|
|
177
|
-
"Content-Type": "application/json",
|
|
178
|
-
Authorization: this.apiKey,
|
|
179
|
-
},
|
|
180
|
-
});
|
|
181
|
-
const openGraphData = await res.json();
|
|
182
|
-
return openGraphData;
|
|
183
|
-
},
|
|
184
|
-
updateOpenGraph: async (domainId, linkIdString, newOpenGraphData) => {
|
|
185
|
-
const res = await fetch(`${this.baseApiUrl}/links/opengraph/${domainId}/${linkIdString}`, {
|
|
186
|
-
method: "PUT",
|
|
187
|
-
headers: {
|
|
188
|
-
"Content-Type": "application/json",
|
|
189
|
-
Authorization: this.apiKey,
|
|
190
|
-
},
|
|
191
|
-
body: JSON.stringify(newOpenGraphData),
|
|
192
|
-
});
|
|
193
|
-
const openGraphData = await res.json();
|
|
194
|
-
return openGraphData;
|
|
195
|
-
},
|
|
196
|
-
};
|
|
197
|
-
domain = {
|
|
198
|
-
list: async () => {
|
|
199
|
-
const domainsRes = await fetch(`${this.baseApiUrl}/api/domains`, {
|
|
200
|
-
method: "GET",
|
|
201
|
-
headers: {
|
|
202
|
-
"Content-Type": "application/json",
|
|
203
|
-
Authorization: this.apiKey,
|
|
204
|
-
},
|
|
205
|
-
});
|
|
206
|
-
const domains = await domainsRes.json();
|
|
207
|
-
return domains;
|
|
208
|
-
},
|
|
209
|
-
create: async (hostname, options) => {
|
|
210
|
-
const domainsRes = await fetch(`${this.baseApiUrl}/domains`, {
|
|
211
|
-
method: "POST",
|
|
212
|
-
headers: {
|
|
213
|
-
"Content-Type": "application/json",
|
|
214
|
-
Authorization: this.apiKey,
|
|
215
|
-
},
|
|
216
|
-
body: JSON.stringify({
|
|
217
|
-
hostname,
|
|
218
|
-
...options,
|
|
219
|
-
}),
|
|
220
|
-
});
|
|
221
|
-
const domain = await domainsRes.json();
|
|
222
|
-
return domain;
|
|
223
|
-
},
|
|
224
|
-
};
|
|
225
|
-
linkCountry = {
|
|
226
|
-
list: async (linkIdString) => {
|
|
227
|
-
const res = await fetch(`${this.baseApiUrl}/link_country/${linkIdString}`, {
|
|
228
|
-
method: "GET",
|
|
229
|
-
headers: {
|
|
230
|
-
"Content-Type": "application/json",
|
|
231
|
-
Authorization: this.apiKey,
|
|
232
|
-
},
|
|
233
|
-
});
|
|
234
|
-
const linkCountries = await res.json();
|
|
235
|
-
return linkCountries;
|
|
236
|
-
},
|
|
237
|
-
create: async (linkIdString, options) => {
|
|
238
|
-
const res = await fetch(`${this.baseApiUrl}/link_country/${linkIdString}`, {
|
|
239
|
-
method: "POST",
|
|
240
|
-
headers: {
|
|
241
|
-
"Content-Type": "application/json",
|
|
242
|
-
Authorization: this.apiKey,
|
|
243
|
-
},
|
|
244
|
-
body: JSON.stringify(options),
|
|
245
|
-
});
|
|
246
|
-
const linkCountry = await res.json();
|
|
247
|
-
return linkCountry;
|
|
248
|
-
},
|
|
249
|
-
delete: async (linkIdString, country) => {
|
|
250
|
-
const res = await fetch(`${this.baseApiUrl}/link_country/${linkIdString}/${country}`, {
|
|
251
|
-
method: "DELETE",
|
|
252
|
-
headers: {
|
|
253
|
-
"Content-Type": "application/json",
|
|
254
|
-
Authorization: this.apiKey,
|
|
255
|
-
},
|
|
256
|
-
});
|
|
257
|
-
const linkCountryDeleteRes = await res.json();
|
|
258
|
-
return linkCountryDeleteRes;
|
|
259
|
-
},
|
|
260
|
-
};
|
|
261
|
-
linkRegion = {
|
|
262
|
-
list: async (linkIdString) => {
|
|
263
|
-
const res = await fetch(`${this.baseApiUrl}/link_region/${linkIdString}`, {
|
|
264
|
-
method: "GET",
|
|
265
|
-
headers: {
|
|
266
|
-
"Content-Type": "application/json",
|
|
267
|
-
Authorization: this.apiKey,
|
|
268
|
-
},
|
|
269
|
-
});
|
|
270
|
-
const linkRegions = await res.json();
|
|
271
|
-
return linkRegions;
|
|
272
|
-
},
|
|
273
|
-
create: async (linkIdString, options) => {
|
|
274
|
-
const res = await fetch(`${this.baseApiUrl}/link_region/${linkIdString}`, {
|
|
275
|
-
method: "POST",
|
|
276
|
-
headers: {
|
|
277
|
-
"Content-Type": "application/json",
|
|
278
|
-
Authorization: this.apiKey,
|
|
279
|
-
},
|
|
280
|
-
body: JSON.stringify(options),
|
|
281
|
-
});
|
|
282
|
-
const linkRegion = await res.json();
|
|
283
|
-
return linkRegion;
|
|
284
|
-
},
|
|
285
|
-
delete: async (linkIdString, options) => {
|
|
286
|
-
const res = await fetch(`${this.baseApiUrl}/link_region/${linkIdString}/${options.country}/${options.region}`, {
|
|
287
|
-
method: "DELETE",
|
|
288
|
-
headers: {
|
|
289
|
-
"Content-Type": "application/json",
|
|
290
|
-
Authorization: this.apiKey,
|
|
291
|
-
},
|
|
292
|
-
});
|
|
293
|
-
const linkRegionDeleteRes = await res.json();
|
|
294
|
-
return linkRegionDeleteRes;
|
|
295
|
-
},
|
|
296
|
-
};
|
|
297
|
-
statistics = {
|
|
298
|
-
getByLink: async (linkIdString, options) => {
|
|
299
|
-
let queryString = "";
|
|
300
|
-
if (options) {
|
|
301
|
-
for (const param in options) {
|
|
302
|
-
queryString += `&${param}=${options[param]}`;
|
|
303
|
-
}
|
|
304
|
-
}
|
|
305
|
-
const res = await fetch(`${this.baseStatisticsUrl}/link/${linkIdString}${queryString ? "?" + queryString : ""}`, {
|
|
306
|
-
method: "GET",
|
|
307
|
-
headers: {
|
|
308
|
-
"Content-Type": "application/json",
|
|
309
|
-
Authorization: this.apiKey,
|
|
310
|
-
},
|
|
311
|
-
});
|
|
312
|
-
const statistics = await res.json();
|
|
313
|
-
return statistics;
|
|
314
|
-
},
|
|
315
|
-
getByLinkPost: async (linkIdString, options) => {
|
|
316
|
-
const res = await fetch(`${this.baseStatisticsUrl}/link/${linkIdString}`, {
|
|
317
|
-
method: "POST",
|
|
318
|
-
headers: {
|
|
319
|
-
"Content-Type": "application/json",
|
|
320
|
-
Authorization: this.apiKey,
|
|
321
|
-
},
|
|
322
|
-
body: JSON.stringify(options),
|
|
323
|
-
});
|
|
324
|
-
const statistics = await res.json();
|
|
325
|
-
return statistics;
|
|
326
|
-
},
|
|
327
|
-
getByDomain: async (domainId, options) => {
|
|
328
|
-
let queryString = "";
|
|
329
|
-
if (options) {
|
|
330
|
-
for (const param in options) {
|
|
331
|
-
queryString += `&${param}=${options[param]}`;
|
|
332
|
-
}
|
|
333
|
-
}
|
|
334
|
-
const res = await fetch(`${this.baseStatisticsUrl}/domain/${domainId}${queryString ? "?" + queryString : ""}`, {
|
|
335
|
-
method: "GET",
|
|
336
|
-
headers: {
|
|
337
|
-
"Content-Type": "application/json",
|
|
338
|
-
Authorization: this.apiKey,
|
|
339
|
-
},
|
|
340
|
-
});
|
|
341
|
-
const statistics = await res.json();
|
|
342
|
-
return statistics;
|
|
343
|
-
},
|
|
344
|
-
getByDomainPost: async (domainId, options) => {
|
|
345
|
-
const res = await fetch(`${this.baseStatisticsUrl}/domain/${domainId}`, {
|
|
346
|
-
method: "POST",
|
|
347
|
-
headers: {
|
|
348
|
-
"Content-Type": "application/json",
|
|
349
|
-
Authorization: this.apiKey,
|
|
350
|
-
},
|
|
351
|
-
body: JSON.stringify(options),
|
|
352
|
-
});
|
|
353
|
-
const statistics = await res.json();
|
|
354
|
-
return statistics;
|
|
355
|
-
},
|
|
356
|
-
getLinkClicks: async (domainId, options) => {
|
|
357
|
-
let queryString = "";
|
|
358
|
-
for (const param in options) {
|
|
359
|
-
queryString += `&${param}=${options[param]}`;
|
|
360
|
-
}
|
|
361
|
-
const res = await fetch(`${this.baseStatisticsUrl}/domain/${domainId}/link_clicks${queryString ? "?" + queryString : ""}`, {
|
|
362
|
-
method: "GET",
|
|
363
|
-
headers: {
|
|
364
|
-
"Content-Type": "application/json",
|
|
365
|
-
Authorization: this.apiKey,
|
|
366
|
-
},
|
|
367
|
-
});
|
|
368
|
-
const statistics = await res.json();
|
|
369
|
-
return statistics;
|
|
370
|
-
},
|
|
371
|
-
getLinkClicksByPathDates: async (domainId, pathsDates, options) => {
|
|
372
|
-
let queryString = "";
|
|
373
|
-
if (options) {
|
|
374
|
-
for (const param in options) {
|
|
375
|
-
queryString += `&${param}=${options[param]}`;
|
|
376
|
-
}
|
|
377
|
-
}
|
|
378
|
-
const res = await fetch(`${this.baseStatisticsUrl}/domain/${domainId}/link_clicks${queryString ? "?" + queryString : ""}`, {
|
|
379
|
-
method: "POST",
|
|
380
|
-
headers: {
|
|
381
|
-
"Content-Type": "application/json",
|
|
382
|
-
Authorization: this.apiKey,
|
|
383
|
-
},
|
|
384
|
-
body: JSON.stringify({ pathsDates }),
|
|
385
|
-
});
|
|
386
|
-
const statistics = await res.json();
|
|
387
|
-
return statistics;
|
|
388
|
-
},
|
|
389
|
-
getTopByColumn: async (domainId, column, options) => {
|
|
390
|
-
const res = await fetch(`${this.baseStatisticsUrl}/domain/${domainId}/top`, {
|
|
391
|
-
method: "POST",
|
|
392
|
-
headers: {
|
|
393
|
-
"Content-Type": "application/json",
|
|
394
|
-
Authorization: this.apiKey,
|
|
395
|
-
},
|
|
396
|
-
body: JSON.stringify({ column, ...options }),
|
|
397
|
-
});
|
|
398
|
-
const statistics = await res.json();
|
|
399
|
-
return statistics;
|
|
400
|
-
},
|
|
401
|
-
getTopByInterval: async (domainId, column, options) => {
|
|
402
|
-
const res = await fetch(`${this.baseStatisticsUrl}/domain/${domainId}/top_by_interval`, {
|
|
403
|
-
method: "POST",
|
|
404
|
-
headers: {
|
|
405
|
-
"Content-Type": "application/json",
|
|
406
|
-
Authorization: this.apiKey,
|
|
407
|
-
},
|
|
408
|
-
body: JSON.stringify({ column, ...options }),
|
|
409
|
-
});
|
|
410
|
-
const statistics = await res.json();
|
|
411
|
-
return statistics;
|
|
412
|
-
},
|
|
413
|
-
getLastClicks: async (domainId, options) => {
|
|
414
|
-
const res = await fetch(`${this.baseStatisticsUrl}/domain/${domainId}/last_clicks`, {
|
|
415
|
-
method: "POST",
|
|
416
|
-
headers: {
|
|
417
|
-
"Content-Type": "application/json",
|
|
418
|
-
Authorization: this.apiKey,
|
|
419
|
-
},
|
|
420
|
-
body: JSON.stringify(options),
|
|
421
|
-
});
|
|
422
|
-
const statistics = await res.json();
|
|
423
|
-
return statistics;
|
|
424
|
-
},
|
|
425
|
-
clear: async (domainId) => {
|
|
426
|
-
const res = await fetch(`${this.baseStatisticsUrl}/domain/${domainId}/statistics`, {
|
|
427
|
-
method: "DELETE",
|
|
428
|
-
headers: {
|
|
429
|
-
"Content-Type": "application/json",
|
|
430
|
-
Authorization: this.apiKey,
|
|
431
|
-
},
|
|
432
|
-
});
|
|
433
|
-
const deleteRes = await res.json();
|
|
434
|
-
return deleteRes;
|
|
435
|
-
},
|
|
436
|
-
};
|
|
437
|
-
}
|
|
1
|
+
export * from "./types.gen.js";
|
|
2
|
+
export * from "./sdk.gen.js";
|
|
438
3
|
//# sourceMappingURL=index.js.map
|