-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Components] real_id - new action components (#15662)
- Loading branch information
Showing
6 changed files
with
276 additions
and
8 deletions.
There are no files selected for viewing
123 changes: 123 additions & 0 deletions
123
components/real_id/actions/create-id-check/create-id-check.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
import app from "../../real_id.app.mjs"; | ||
|
||
export default { | ||
key: "real_id-create-id-check", | ||
name: "Create ID Check", | ||
description: "Create a new ID check for a user. [See the documentation](https://getverdict.com/help/docs/api/checks#create-an-id-check).", | ||
version: "0.0.1", | ||
type: "action", | ||
props: { | ||
app, | ||
// eslint-disable-next-line pipedream/props-label, pipedream/props-description | ||
info: { | ||
type: "alert", | ||
alertType: "info", | ||
content: "Either the **Email** or the **Phone** number is required to create an ID check.", | ||
}, | ||
email: { | ||
propDefinition: [ | ||
app, | ||
"email", | ||
], | ||
}, | ||
phone: { | ||
propDefinition: [ | ||
app, | ||
"phone", | ||
], | ||
}, | ||
firstName: { | ||
type: "string", | ||
label: "First Name", | ||
description: "First name of the customer", | ||
optional: true, | ||
}, | ||
lastName: { | ||
type: "string", | ||
label: "Last Name", | ||
description: "Last name of the customer", | ||
optional: true, | ||
}, | ||
wooCommerceCustomerId: { | ||
type: "string", | ||
label: "WooCommerce Customer ID", | ||
description: "Unique identifier for the customer in WooCommerce", | ||
optional: true, | ||
}, | ||
wooCommerceOrderId: { | ||
type: "string", | ||
label: "WooCommerce Order ID", | ||
description: "Unique identifier for the order in WooCommerce", | ||
optional: true, | ||
}, | ||
shopifyAdminGraphqlId: { | ||
type: "string", | ||
label: "Shopify Admin GraphQL ID", | ||
description: "Unique identifier for the customer in Shopify", | ||
optional: true, | ||
}, | ||
shopifyAdminGraphqlOrderId: { | ||
type: "string", | ||
label: "Shopify Admin GraphQL Order ID", | ||
description: "Unique identifier for the order in Shopify", | ||
optional: true, | ||
}, | ||
shopifyAdminGraphqlOrderName: { | ||
type: "string", | ||
label: "Shopify Admin GraphQL Order Name", | ||
description: "Name of the order in Shopify", | ||
optional: true, | ||
}, | ||
additionalParameters: { | ||
type: "object", | ||
label: "Additional Parameters", | ||
description: "Additional parameters to include in the request", | ||
optional: true, | ||
}, | ||
}, | ||
methods: { | ||
createIdCheck(args = {}) { | ||
return this.app.post({ | ||
path: "/checks", | ||
...args, | ||
}); | ||
}, | ||
}, | ||
async run({ $ }) { | ||
const { | ||
createIdCheck, | ||
email, | ||
phone, | ||
firstName, | ||
lastName, | ||
wooCommerceCustomerId, | ||
wooCommerceOrderId, | ||
shopifyAdminGraphqlId, | ||
shopifyAdminGraphqlOrderId, | ||
shopifyAdminGraphqlOrderName, | ||
additionalParameters, | ||
} = this; | ||
|
||
const response = await createIdCheck({ | ||
$, | ||
data: { | ||
customer: { | ||
first_name: firstName, | ||
last_name: lastName, | ||
email, | ||
phone, | ||
wc_id: wooCommerceCustomerId, | ||
shopify_admin_graphql_id: shopifyAdminGraphqlId, | ||
}, | ||
order: { | ||
wc_id: wooCommerceOrderId, | ||
shopify_admin_graphql_id: shopifyAdminGraphqlOrderId, | ||
name: shopifyAdminGraphqlOrderName, | ||
}, | ||
...additionalParameters, | ||
}, | ||
}); | ||
$.export("$summary", "Successfully created ID check."); | ||
return response; | ||
}, | ||
}; |
41 changes: 41 additions & 0 deletions
41
components/real_id/actions/delete-id-check/delete-id-check.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import app from "../../real_id.app.mjs"; | ||
|
||
export default { | ||
key: "real_id-delete-id-check", | ||
name: "Delete ID Check", | ||
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).", | ||
version: "0.0.1", | ||
type: "action", | ||
props: { | ||
app, | ||
checkId: { | ||
propDefinition: [ | ||
app, | ||
"checkId", | ||
], | ||
}, | ||
}, | ||
methods: { | ||
deleteIdCheck({ | ||
checkId, ...args | ||
} = {}) { | ||
return this.app.delete({ | ||
path: `/checks/${checkId}`, | ||
...args, | ||
}); | ||
}, | ||
}, | ||
async run({ $ }) { | ||
const { | ||
deleteIdCheck, | ||
checkId, | ||
} = this; | ||
|
||
const response = await deleteIdCheck({ | ||
$, | ||
checkId, | ||
}); | ||
$.export("$summary", `Successfully deleted ID check \`${response.check.id}\`.`); | ||
return response; | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import app from "../../real_id.app.mjs"; | ||
|
||
export default { | ||
key: "real_id-get-id-check", | ||
name: "Get ID Check", | ||
description: "Retrieve an ID check. [See the documentation](https://getverdict.com/help/docs/api/checks#retrieve-an-id-check).", | ||
version: "0.0.1", | ||
type: "action", | ||
props: { | ||
app, | ||
checkId: { | ||
propDefinition: [ | ||
app, | ||
"checkId", | ||
], | ||
}, | ||
withPhotos: { | ||
type: "boolean", | ||
label: "Include Photos", | ||
description: "All photos will be provided as short lived URLs in the API response under the `photos` key.", | ||
optional: true, | ||
}, | ||
}, | ||
methods: { | ||
retrieveIdCheck({ | ||
checkId, ...args | ||
} = {}) { | ||
return this.app._makeRequest({ | ||
path: `/checks/${checkId}`, | ||
...args, | ||
}); | ||
}, | ||
}, | ||
async run({ $ }) { | ||
const { | ||
retrieveIdCheck, | ||
checkId, | ||
withPhotos, | ||
} = this; | ||
|
||
const response = await retrieveIdCheck({ | ||
$, | ||
checkId, | ||
params: { | ||
withPhotos, | ||
}, | ||
}); | ||
|
||
$.export("$summary", "Successfully retrieved ID check."); | ||
return response; | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,58 @@ | ||
import { axios } from "@pipedream/platform"; | ||
|
||
export default { | ||
type: "app", | ||
app: "real_id", | ||
propDefinitions: {}, | ||
propDefinitions: { | ||
email: { | ||
type: "string", | ||
label: "Email", | ||
description: "Email address for initiating the ID check", | ||
optional: true, | ||
}, | ||
phone: { | ||
type: "string", | ||
label: "Phone Number", | ||
description: "Phone number for initiating the ID check", | ||
optional: true, | ||
}, | ||
checkId: { | ||
type: "string", | ||
label: "ID Check Identifier", | ||
description: "The unique identifier for the ID check", | ||
}, | ||
}, | ||
methods: { | ||
// this.$auth contains connected account data | ||
authKeys() { | ||
console.log(Object.keys(this.$auth)); | ||
getUrl(path) { | ||
return `https://real-id.getverdict.com/api/v1${path}`; | ||
}, | ||
getHeaders(headers) { | ||
return { | ||
"Authorization": `Bearer ${this.$auth.api_key}`, | ||
"Content-Type": "application/json", | ||
...headers, | ||
}; | ||
}, | ||
_makeRequest({ | ||
$ = this, path, headers, ...args | ||
} = {}) { | ||
return axios($, { | ||
...args, | ||
url: this.getUrl(path), | ||
headers: this.getHeaders(headers), | ||
}); | ||
}, | ||
post(args = {}) { | ||
return this._makeRequest({ | ||
method: "POST", | ||
...args, | ||
}); | ||
}, | ||
delete(args = {}) { | ||
return this._makeRequest({ | ||
method: "DELETE", | ||
...args, | ||
}); | ||
}, | ||
}, | ||
}; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.