Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 71 additions & 0 deletions components/certifier/actions/create-group/create-group.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import certifier from "../../certifier.app.mjs";

export default {
name: "Create Group",
version: "0.0.1",
key: "certifier-create-group",
description:
"Create a group. [See the documentation](https://developers.certifier.io/reference/create-a-group)",
props: {
certifier,
name: {
propDefinition: [
certifier,
"groupName",
],
},
certificateDesignId: {
propDefinition: [
certifier,
"certificateDesignId",
],
},
badgeDesignId: {
propDefinition: [
certifier,
"badgeDesignId",
],
},
learningEventUrl: {
propDefinition: [
certifier,
"learningEventUrl",
],
},
// eslint-disable-next-line pipedream/props-label, pipedream/props-description
alert: {
type: "alert",
alertType: "warning",
content:
"At least one of `Certificate Design` and `Badge Design` fields is required.",
},
},
type: "action",
methods: {},
async run({ $ }) {
const {
certifier,
name,
certificateDesignId,
badgeDesignId,
learningEventUrl,
} = this;

const response = await certifier.createGroup({
$,
data: {
name,
certificateDesignId,
badgeDesignId,
learningEventUrl,
},
});

$.export(
"$summary",
`Successfully created group ${response.name}`,
);

return response;
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import certifier from "../../certifier.app.mjs";

export default {
name: "Issue Credential",
version: "0.0.1",
version: "0.0.2",
key: "certifier-issue-credential",
description:
"Create, issue and send a credential to a recipient. [See the documentation](https://developers.certifier.io/reference/create-issue-send-a-credential)",
Expand Down
90 changes: 90 additions & 0 deletions components/certifier/certifier.app.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ export default {
...args,
});
},
searchDesigns(args = {}) {
return this.callApi({
path: "/designs",
...args,
});
},
createCredential(args = {}) {
return this.callApi({
method: "POST",
Expand All @@ -57,6 +63,13 @@ export default {
...args,
});
},
createGroup(args = {}) {
return this.callApi({
method: "POST",
path: "/groups",
...args,
});
},
},
propDefinitions: {
groupId: {
Expand Down Expand Up @@ -121,5 +134,82 @@ export default {
"The date (in `YYYY-MM-DD` format) of your credential's expiration. If not provided, expiry date from the group settings will be used (by default this field is empty).",
optional: true,
},
groupName: {
type: "string",
label: "Group Name",
description:
"The group's name that is used as [group.name] attribute later on.",
},
certificateDesignId: {
type: "string",
label: "Certificate Design",
description: "The unique certificate design's name.",
optional: true,
async options({ prevContext } = {}) {
const response = await this.searchDesigns({
params: {
cursor: prevContext.cursor,
},
});
const designs = response.data;
const cursor = response.pagination.next;

return {
options: designs
.filter((design) => design.type === "certificate")
.map(({
id, name,
}) => ({
label: name,
value: id,
})),
context: {
cursor,
},
};
},
},
badgeDesignId: {
type: "string",
label: "Badge Design",
description: "The unique badge design's name.",
optional: true,
async options({ prevContext } = {}) {
const response = await this.searchDesigns({
params: {
cursor: prevContext.cursor,
},
});
const designs = response.data;
const cursor = response.pagination.next;

return {
options: designs
.filter((design) => design.type === "badge")
.map(({
id, name,
}) => ({
label: name,
value: id,
})),
context: {
cursor,
},
};
},
},
learningEventUrl: {
type: "string",
label: "Learning Event URL",
description:
"The learning event's URL that is shown in the digital wallet.",
optional: true,
},
credentialId: {
type: "string",
label: "Credential ID",
description:
"The credential's unique ID.",
},
},
};
2 changes: 1 addition & 1 deletion components/certifier/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pipedream/certifier",
"version": "0.1.0",
"version": "0.2.0",
"description": "Pipedream Certifier Components",
"main": "certifier.app.mjs",
"keywords": [
Expand Down
Loading