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
90 changes: 90 additions & 0 deletions components/navigatr/actions/issue-badge/issue-badge.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
import app from "../../navigatr.app.mjs";

export default {
key: "navigatr-issue-badge",
name: "Issue Badge",
description: "Issue a badge to a recipient. [See the documentation](https://api.navigatr.app/docs#/Badge/issue_badge_v1_badge__badge_id__issue_put)",
version: "0.0.1",
type: "action",
props: {
app,
providerId: {
propDefinition: [
app,
"providerId",
],
},
badgeId: {
propDefinition: [
app,
"badgeId",
],
},
recipientHasAccount: {
propDefinition: [
app,
"recipientHasAccount",
],
reloadProps: true,
},
recipientId: {
propDefinition: [
app,
"recipientId",
],
},
recipientEmail: {
propDefinition: [
app,
"recipientEmail",
],
disabled: true,
hidden: true,
},
recipientFirstname: {
propDefinition: [
app,
"recipientFirstname",
],
disabled: true,
hidden: true,
},
recipientLastname: {
propDefinition: [
app,
"recipientLastname",
],
disabled: true,
hidden: true,
},
},
async additionalProps(existingProps) {
const props = {};
if (!this.recipientHasAccount) {
existingProps.recipientId.hidden = true;
existingProps.recipientId.disabled = true;
existingProps.recipientEmail.hidden = false;
existingProps.recipientEmail.disabled = false;
existingProps.recipientFirstname.hidden = false;
existingProps.recipientFirstname.disabled = false;
existingProps.recipientLastname.hidden = false;
existingProps.recipientLastname.disabled = false;
}
return props;
},
async run({ $ }) {
const response = await this.app.issueBadge({
$,
badgeId: this.badgeId,
data: {
provider_id: this.providerId,
recipient_id: this.recipientId,
recipient_email: this.recipientEmail,
recipient_firstname: this.recipientFirstname,
recipient_lastname: this.recipientLastname,
},
});
$.export("$summary", "Successfully issued badge");
return response;
},
};
89 changes: 84 additions & 5 deletions components/navigatr/navigatr.app.mjs
Original file line number Diff line number Diff line change
@@ -1,11 +1,90 @@
import { axios } from "@pipedream/platform";

export default {
type: "app",
app: "navigatr",
propDefinitions: {},
propDefinitions: {
providerId: {
type: "string",
label: "Provider ID",
description: "ID of the badge provider",
async options() {
const response = await this.getUserDetails();
const providerIds = response.providers;
return providerIds.map(({
name, id,
}) => ({
label: name,
value: id,
}));
},
},
recipientHasAccount: {
type: "boolean",
label: "Recipient Has Account",
description: "Does the recipient have an account in the system?",
},
recipientId: {
type: "string",
label: "Recipient ID",
description: "ID of the badge recipient",
},
recipientEmail: {
type: "string",
label: "Recipient Email",
description: "Email of the recipient",
},
recipientFirstname: {
type: "string",
label: "First Name",
description: "First Name of the recipient",
},
recipientLastname: {
type: "string",
label: "Last Name",
description: "Last Name of the recipient",
},
badgeId: {
type: "string",
label: "Badge ID",
description: "ID of the badge to be issued",
},
},
methods: {
// this.$auth contains connected account data
authKeys() {
console.log(Object.keys(this.$auth));
_baseUrl() {
return "https://api.navigatr.app/v1";
},
async _makeRequest(opts = {}) {
const {
$ = this,
path,
headers,
...otherOpts
} = opts;
return axios($, {
...otherOpts,
url: this._baseUrl() + path,
headers: {
Authorization: `Bearer ${this.$auth.oauth_access_token}`,
...headers,
},
});
},

async issueBadge({
badgeId, ...args
}) {
return this._makeRequest({
path: `/badge/${badgeId}/issue`,
method: "put",
...args,
});
},
async getUserDetails(args = {}) {
return this._makeRequest({
path: "/user_detail/0",
...args,
});
},
},
};
};
5 changes: 4 additions & 1 deletion components/navigatr/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pipedream/navigatr",
"version": "0.0.1",
"version": "0.1.0",
"description": "Pipedream Navigatr Components",
"main": "navigatr.app.mjs",
"keywords": [
Expand All @@ -11,5 +11,8 @@
"author": "Pipedream <support@pipedream.com> (https://pipedream.com/)",
"publishConfig": {
"access": "public"
},
"dependencies": {
"@pipedream/platform": "^3.0.3"
}
}
14 changes: 9 additions & 5 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading