Skip to content

Commit 4e2289f

Browse files
committed
updates
1 parent bab0c98 commit 4e2289f

File tree

7 files changed

+122
-40
lines changed

7 files changed

+122
-40
lines changed

components/codeqr/actions/create-link/create-link.mjs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export default {
44
key: "codeqr-create-link",
55
name: "Create a CodeQR Link",
66
description:
7-
"Creates a short link in CodeQR using the CodeQR API. [See the docs here](https://codeqr.mintlify.app/api-reference/endpoint/create-a-link)",
7+
"Creates a short link in CodeQR using the CodeQR API. [See the documentation](https://codeqr.mintlify.app/api-reference/endpoint/create-a-link)",
88
version: "0.0.1",
99
type: "action",
1010
props: {
@@ -191,12 +191,15 @@ export default {
191191
comments,
192192
expiresAt,
193193
expiredUrl,
194-
geo,
195194
publicStats,
196195
tagIds,
197196
tagNames,
198197
} = this;
199198

199+
const geo = typeof this.geo === "string"
200+
? JSON.parse(this.geo)
201+
: this.geo;
202+
200203
const payload = {
201204
url,
202205
};
@@ -226,7 +229,10 @@ export default {
226229
if (tagIds?.length) payload.tagIds = tagIds;
227230
if (tagNames?.length) payload.tagNames = tagNames;
228231

229-
const response = await this.codeqr.createLink(payload);
232+
const response = await this.codeqr.createLink({
233+
$,
234+
data: payload,
235+
});
230236
response && $.export("$summary", "Link created successfully");
231237
return response;
232238
},

components/codeqr/actions/create-qrcode/create-qrcode.mjs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import codeqr from "../../codeqr.app.mjs";
33
export default {
44
key: "codeqr-create-qrcode",
55
name: "Create a QR Code",
6-
description: "Creates a new QR Code in CodeQR using the QR Codes API. [See the docs here](https://codeqr.mintlify.app/api-reference/endpoint/create-a-qrcode)",
6+
description: "Creates a new QR Code in CodeQR using the QR Codes API. [See the documentation](https://codeqr.mintlify.app/api-reference/endpoint/create-a-qrcode)",
77
version: "0.0.1",
88
type: "action",
99
props: {
@@ -114,7 +114,6 @@ export default {
114114
"static",
115115
"text",
116116
"url",
117-
"email",
118117
"phone",
119118
"expiresAt",
120119
"trackConversion",
@@ -129,7 +128,17 @@ export default {
129128
]) {
130129
if (this[key] != null) payload[key] = this[key];
131130
}
132-
const response = await this.codeqr.createQrcode(payload);
131+
132+
if (this.email) {
133+
payload.email = typeof this.email === "string"
134+
? JSON.parse(this.email)
135+
: this.email;
136+
}
137+
138+
const response = await this.codeqr.createQrcode({
139+
$,
140+
data: payload,
141+
});
133142
$.export("$summary", "QR Code created successfully.");
134143
return response;
135144
},

components/codeqr/actions/delete-link/delete-link.mjs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,16 @@ import codeqr from "../../codeqr.app.mjs";
44
export default {
55
key: "codeqr-delete-link",
66
name: "Delete a Link",
7-
description: "Deletes a short link in CodeQR by linkId or externalId. [See the docs here](https://codeqr.mintlify.app/api-reference/endpoint/delete-a-link)",
7+
description: "Deletes a short link in CodeQR by linkId or externalId. [See the documentation](https://codeqr.mintlify.app/api-reference/endpoint/delete-a-link)",
88
version: "0.0.1",
99
type: "action",
1010
props: {
1111
codeqr,
1212
linkId: {
13-
type: "string",
14-
label: "Link ID",
13+
propDefinition: [
14+
codeqr,
15+
"linkId",
16+
],
1517
description: "The unique ID of the link to delete.",
1618
optional: true,
1719
},
@@ -37,7 +39,10 @@ export default {
3739
const identifier = linkId || externalId;
3840

3941
// Perform DELETE request to /links/{identifier}
40-
await this.codeqr.deleteLink(identifier);
42+
await this.codeqr.deleteLink({
43+
$,
44+
identifier,
45+
});
4146
$.export("$summary", `Link deleted successfully (${identifier}).`);
4247
return {
4348
success: true,

components/codeqr/actions/delete-qrcode/delete-qrcode.mjs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,16 @@ export default {
55
key: "codeqr-delete-qrcode",
66
name: "Delete a QR Code",
77
description:
8-
"Deletes a QR Code in CodeQR by qrcodeId or externalId. [See the docs here](https://codeqr.mintlify.app/api-reference/endpoint/delete-a-qrcode)",
8+
"Deletes a QR Code in CodeQR by qrcodeId or externalId. [See the documentation](https://codeqr.mintlify.app/api-reference/endpoint/delete-a-qrcode)",
99
version: "0.0.1",
1010
type: "action",
1111
props: {
1212
codeqr,
1313
qrcodeId: {
14-
type: "string",
15-
label: "QR Code ID",
14+
propDefinition: [
15+
codeqr,
16+
"qrcodeId",
17+
],
1618
description: "The unique ID of the QR Code to delete.",
1719
optional: true,
1820
},
@@ -34,7 +36,10 @@ export default {
3436
);
3537
}
3638
const identifier = qrcodeId || externalId;
37-
await this.codeqr.deleteQrcode(identifier);
39+
await this.codeqr.deleteQrcode({
40+
$,
41+
identifier,
42+
});
3843
$.export("$summary", `QR Code deleted successfully (${identifier}).`);
3944
return {
4045
success: true,

components/codeqr/actions/get-link-info/get-link-info.mjs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,16 @@ export default {
55
key: "codeqr-get-link-info",
66
name: "Get a Link Info",
77
description:
8-
"Retrieves a short link from CodeQR by linkId, externalId, or domain/key via query string parameters. [See the docs here](https://codeqr.mintlify.app/api-reference/endpoint/retrieve-a-link)",
9-
version: "0.0.2",
8+
"Retrieves a short link from CodeQR by linkId, externalId, or domain/key via query string parameters. [See the documentation](https://codeqr.mintlify.app/api-reference/endpoint/retrieve-a-link)",
9+
version: "0.0.1",
1010
type: "action",
1111
props: {
1212
codeqr,
1313
linkId: {
14-
type: "string",
15-
label: "Link ID",
14+
propDefinition: [
15+
codeqr,
16+
"linkId",
17+
],
1618
description: "The unique ID of the short link.",
1719
optional: true,
1820
},
@@ -56,7 +58,10 @@ export default {
5658
key && (params.key = key);
5759

5860
// Make GET request to /links/info with query string
59-
const response = await this.codeqr.getLinkInfo(params);
61+
const response = await this.codeqr.getLinkInfo({
62+
$,
63+
params,
64+
});
6065
$.export(
6166
"$summary",
6267
`Link retrieved successfully${

components/codeqr/actions/get-qrcode-info/get-qrcode-info.mjs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,16 @@ export default {
55
key: "codeqr-get-qrcode-info",
66
name: "Get QR Code Info",
77
description:
8-
"Retrieves QR Code info by qrcodeId, externalId, domain, or key via query string. [See the docs here](https://codeqr.mintlify.app/api-reference/endpoint/retrieve-a-qrcode)",
8+
"Retrieves QR Code info by qrcodeId, externalId, domain, or key via query string. [See the documentation](https://codeqr.mintlify.app/api-reference/endpoint/retrieve-a-qrcode)",
99
version: "0.0.1",
1010
type: "action",
1111
props: {
1212
codeqr,
1313
qrcodeId: {
14-
type: "string",
15-
label: "QR Code ID",
14+
propDefinition: [
15+
codeqr,
16+
"qrcodeId",
17+
],
1618
description: "The unique ID of the QR Code.",
1719
optional: true,
1820
},
@@ -50,7 +52,10 @@ export default {
5052
externalId && (params.externalId = externalId);
5153
domain && (params.domain = domain);
5254
key && (params.key = key);
53-
const response = await this.codeqr.getQrcodeInfo(params);
55+
const response = await this.codeqr.getQrcodeInfo({
56+
$,
57+
params,
58+
});
5459
$.export(
5560
"$summary",
5661
`QR Code info retrieved successfully${

components/codeqr/codeqr.app.mjs

Lines changed: 64 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,40 @@ import constants from "./common/constants.mjs";
44
export default {
55
type: "app",
66
app: "codeqr",
7-
propDefinitions: {},
7+
propDefinitions: {
8+
linkId: {
9+
type: "string",
10+
label: "Link ID",
11+
description: "The unique ID of a link",
12+
async options({ page }) {
13+
const links = await this.listLinks({
14+
params: {
15+
page: page + 1,
16+
},
17+
});
18+
return links?.map((link) => ({
19+
label: link.url,
20+
value: link.id,
21+
}));
22+
},
23+
},
24+
qrcodeId: {
25+
type: "string",
26+
label: "QR Code ID",
27+
description: "The unique ID of a QR Code",
28+
async options({ page }) {
29+
const qrCodes = await this.listQrCodes({
30+
params: {
31+
page: page + 1,
32+
},
33+
});
34+
return qrCodes?.map((qrCode) => ({
35+
label: qrCode.url,
36+
value: qrCode.id,
37+
}));
38+
},
39+
},
40+
},
841
methods: {
942
getHeader() {
1043
return {
@@ -16,58 +49,72 @@ export default {
1649
const { BASE_URL } = constants;
1750
return `${BASE_URL}${path}`;
1851
},
19-
authKeys() {
20-
console.log(Object.keys(this.$auth));
21-
},
2252
async makeRequest(args = {}) {
2353
const {
24-
$ = this, method = "get", path, params, data,
54+
$ = this, method = "get", path, ...opts
2555
} = args;
2656
const config = {
2757
method,
2858
url: this.getUrl(path),
2959
headers: this.getHeader(),
30-
params,
31-
data,
60+
...opts,
3261
};
3362
return axios($, config);
3463
},
35-
async createLink(data) {
64+
async listLinks(opts = {}) {
65+
return this.makeRequest({
66+
path: "/links",
67+
...opts,
68+
});
69+
},
70+
async listQrCodes(opts = {}) {
71+
return this.makeRequest({
72+
path: "/qrcodes",
73+
...opts,
74+
});
75+
},
76+
async createLink(opts = {}) {
3677
return this.makeRequest({
3778
method: "post",
3879
path: "/links",
39-
data,
80+
...opts,
4081
});
4182
},
42-
async getLinkInfo(params) {
83+
async getLinkInfo(opts = {}) {
4384
return this.makeRequest({
4485
path: "/links/info",
45-
params,
86+
...opts,
4687
});
4788
},
48-
async deleteLink(identifier) {
89+
async deleteLink({
90+
identifier, ...opts
91+
}) {
4992
return this.makeRequest({
5093
method: "delete",
5194
path: `/links/${identifier}`,
95+
...opts,
5296
});
5397
},
54-
async createQrcode(data) {
98+
async createQrcode(opts = {}) {
5599
return this.makeRequest({
56100
method: "post",
57101
path: "/qrcodes",
58-
data,
102+
...opts,
59103
});
60104
},
61-
async getQrcodeInfo(params) {
105+
async getQrcodeInfo(opts = {}) {
62106
return this.makeRequest({
63107
path: "/qrcodes/info",
64-
params,
108+
...opts,
65109
});
66110
},
67-
async deleteQRCode(identifier) {
111+
async deleteQrcode({
112+
identifier, ...opts
113+
}) {
68114
return this.makeRequest({
69115
method: "delete",
70116
path: `/qrcodes/${identifier}`,
117+
...opts,
71118
});
72119
},
73120
},

0 commit comments

Comments
 (0)