Skip to content

Commit 23f0225

Browse files
committed
[Components] real_id - new action components
1 parent b38f664 commit 23f0225

File tree

6 files changed

+278
-10
lines changed

6 files changed

+278
-10
lines changed
Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
import app from "../../real_id.app.mjs";
2+
3+
export default {
4+
key: "real_id-create-id-check",
5+
name: "Create ID Check",
6+
description: "Create a new ID check for a user. [See the documentation](https://getverdict.com/help/docs/api/checks#create-an-id-check).",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
app,
11+
// eslint-disable-next-line pipedream/props-label, pipedream/props-description
12+
info: {
13+
type: "alert",
14+
alertType: "info",
15+
content: "Either the **Email** or the **Phone** number is required to create an ID check.",
16+
},
17+
email: {
18+
propDefinition: [
19+
app,
20+
"email",
21+
],
22+
},
23+
phone: {
24+
propDefinition: [
25+
app,
26+
"phone",
27+
],
28+
},
29+
firstName: {
30+
type: "string",
31+
label: "First Name",
32+
description: "First name of the customer.",
33+
optional: true,
34+
},
35+
lastName: {
36+
type: "string",
37+
label: "Last Name",
38+
description: "Last name of the customer.",
39+
optional: true,
40+
},
41+
wooCommerceCustomerId: {
42+
type: "string",
43+
label: "WooCommerce Customer ID",
44+
description: "Unique identifier for the customer in WooCommerce.",
45+
optional: true,
46+
},
47+
wooCommerceOrderId: {
48+
type: "string",
49+
label: "WooCommerce Order ID",
50+
description: "Unique identifier for the order in WooCommerce.",
51+
optional: true,
52+
},
53+
shopifyAdminGraphqlId: {
54+
type: "string",
55+
label: "Shopify Admin GraphQL ID",
56+
description: "Unique identifier for the customer in Shopify.",
57+
optional: true,
58+
},
59+
shopifyAdminGraphqlOrderId: {
60+
type: "string",
61+
label: "Shopify Admin GraphQL Order ID",
62+
description: "Unique identifier for the order in Shopify.",
63+
optional: true,
64+
},
65+
shopifyAdminGraphqlOrderName: {
66+
type: "string",
67+
label: "Shopify Admin GraphQL Order Name",
68+
description: "Name of the order in Shopify.",
69+
optional: true,
70+
},
71+
additionalParameters: {
72+
type: "object",
73+
label: "Additional Parameters",
74+
description: "Additional parameters to include in the request.",
75+
optional: true,
76+
},
77+
},
78+
methods: {
79+
createIdCheck(args = {}) {
80+
return this.app.post({
81+
path: "/checks",
82+
...args,
83+
});
84+
},
85+
},
86+
async run({ $ }) {
87+
const {
88+
createIdCheck,
89+
email,
90+
phone,
91+
firstName,
92+
lastName,
93+
wooCommerceCustomerId,
94+
wooCommerceOrderId,
95+
shopifyAdminGraphqlId,
96+
shopifyAdminGraphqlOrderId,
97+
shopifyAdminGraphqlOrderName,
98+
additionalParameters,
99+
} = this;
100+
101+
const response = await createIdCheck({
102+
$,
103+
data: {
104+
customer: {
105+
first_name: firstName,
106+
last_name: lastName,
107+
email,
108+
phone,
109+
wc_id: wooCommerceCustomerId,
110+
shopify_admin_graphql_id: shopifyAdminGraphqlId,
111+
},
112+
order: {
113+
wc_id: wooCommerceOrderId,
114+
shopify_admin_graphql_id: shopifyAdminGraphqlOrderId,
115+
name: shopifyAdminGraphqlOrderName,
116+
},
117+
...additionalParameters,
118+
},
119+
});
120+
$.export("$summary", "Successfully created ID check.");
121+
return response;
122+
},
123+
};
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import app from "../../real_id.app.mjs";
2+
3+
export default {
4+
key: "real_id-delete-id-check",
5+
name: "Delete ID Check",
6+
description: "Permanently delete all data associated with a specific ID check. [See the documentation](https://getverdict.com/help/docs/api/checks#delete-id-check-data).",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
app,
11+
checkId: {
12+
propDefinition: [
13+
app,
14+
"checkId",
15+
],
16+
},
17+
},
18+
methods: {
19+
deleteIdCheck({
20+
checkId, ...args
21+
} = {}) {
22+
return this.app.delete({
23+
path: `/checks/${checkId}`,
24+
...args,
25+
});
26+
},
27+
},
28+
async run({ $ }) {
29+
const {
30+
deleteIdCheck,
31+
checkId,
32+
} = this;
33+
34+
const response = await deleteIdCheck({
35+
$,
36+
checkId,
37+
});
38+
$.export("$summary", `Successfully deleted ID check \`${response.check.id}\`.`);
39+
return response;
40+
},
41+
};
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
import app from "../../real_id.app.mjs";
2+
3+
export default {
4+
key: "real_id-get-id-check",
5+
name: "Get ID Check",
6+
description: "Retrieve an ID check. [See the documentation](https://getverdict.com/help/docs/api/checks#create-an-id-check).",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
app,
11+
checkId: {
12+
propDefinition: [
13+
app,
14+
"checkId",
15+
],
16+
},
17+
withPhotos: {
18+
type: "boolean",
19+
label: "Include Photos",
20+
description: "All photos will be provided as short lived URLs in the API response under the `photos` key.",
21+
optional: true,
22+
},
23+
},
24+
methods: {
25+
retrieveIdCheck({
26+
checkId, ...args
27+
} = {}) {
28+
return this.app._makeRequest({
29+
path: `/checks/${checkId}`,
30+
...args,
31+
});
32+
},
33+
},
34+
async run({ $ }) {
35+
const {
36+
retrieveIdCheck,
37+
checkId,
38+
withPhotos,
39+
} = this;
40+
41+
const response = await retrieveIdCheck({
42+
$,
43+
checkId,
44+
params: {
45+
withPhotos,
46+
},
47+
});
48+
49+
$.export("$summary", "Successfully retrieved ID check.");
50+
return response;
51+
},
52+
};

components/real_id/package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/real_id",
3-
"version": "0.0.1",
3+
"version": "0.1.0",
44
"description": "Pipedream Real ID Components",
55
"main": "real_id.app.mjs",
66
"keywords": [
@@ -11,5 +11,8 @@
1111
"author": "Pipedream <[email protected]> (https://pipedream.com/)",
1212
"publishConfig": {
1313
"access": "public"
14+
},
15+
"dependencies": {
16+
"@pipedream/platform": "^3.0.3"
1417
}
15-
}
18+
}

components/real_id/real_id.app.mjs

Lines changed: 52 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,58 @@
1+
import { axios } from "@pipedream/platform";
2+
13
export default {
24
type: "app",
35
app: "real_id",
4-
propDefinitions: {},
6+
propDefinitions: {
7+
email: {
8+
type: "string",
9+
label: "Email",
10+
description: "Email address for initiating the ID check.",
11+
optional: true,
12+
},
13+
phone: {
14+
type: "string",
15+
label: "Phone Number",
16+
description: "Phone number for initiating the ID check.",
17+
optional: true,
18+
},
19+
checkId: {
20+
type: "string",
21+
label: "ID Check Identifier",
22+
description: "The unique identifier for the ID check.",
23+
},
24+
},
525
methods: {
6-
// this.$auth contains connected account data
7-
authKeys() {
8-
console.log(Object.keys(this.$auth));
26+
getUrl(path) {
27+
return `https://real-id.getverdict.com/api/v1${path}`;
28+
},
29+
getHeaders(headers) {
30+
return {
31+
"Authorization": `Bearer ${this.$auth.api_key}`,
32+
"Content-Type": "application/json",
33+
...headers,
34+
};
35+
},
36+
_makeRequest({
37+
$ = this, path, headers, ...args
38+
} = {}) {
39+
return axios($, {
40+
...args,
41+
url: this.getUrl(path),
42+
headers: this.getHeaders(headers),
43+
});
44+
},
45+
post(args = {}) {
46+
return this._makeRequest({
47+
method: "POST",
48+
...args,
49+
});
50+
},
51+
delete(args = {}) {
52+
return this._makeRequest({
53+
method: "DELETE",
54+
...args,
55+
});
956
},
1057
},
11-
};
58+
};

pnpm-lock.yaml

Lines changed: 5 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)