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
70 changes: 70 additions & 0 deletions components/walletap/actions/create-pass/create-pass.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
import { parseObject } from "../../common/utils.mjs";
import walletap from "../../walletap.app.mjs";

export default {
key: "walletap-create-pass",
name: "Create Pass",
description: "Creates a mobile Wallet pass. [See the documentation](https://walletap.io/docs/api#tag/Pass/operation/createPass)",
version: "0.0.1",
type: "action",
annotations: {
destructiveHint: false,
openWorldHint: true,
readOnlyHint: false,
},
props: {
walletap,
passes: {
type: "string[]",
label: "Passes",
description: "A list of objects with the pass data. Example: `[{ \"templateId\": \"daltQAV1vidnfj6C6Vws\", \"templateFields\": { \"validUntil\": \"2025-01-15T21:38:37+01:00\" }, \"customFields\": { \"memberName\": \"John Doe\" } }]`",
optional: true,
},
email: {
type: "string",
label: "Email",
description: "The email of the user",
optional: true,
},
phone: {
type: "string",
label: "Phone",
description: "The phone of the user",
optional: true,
},
sendToEmail: {
type: "boolean",
label: "Send to Email",
description: "Whether to send pass link via email",
optional: true,
},
sendToPhone: {
type: "boolean",
label: "Send to Phone",
description: "Whether to send pass link via phone messaging",
optional: true,
},
locale: {
type: "string",
label: "Locale",
description: "[ISO 639 language code](https://en.wikipedia.org/wiki/List_of_ISO_639_language_codes) to display localized \"Add to Wallet\" badges, SMS and WhatsApp messages",
optional: true,
},
},
async run({ $ }) {
const response = await this.walletap.createPass({
$,
data: {
passes: parseObject(this.passes),
email: this.email,
phone: this.phone,
sendToEmail: this.sendToEmail,
sendToPhone: this.sendToPhone,
locale: this.locale,
},
});

$.export("$summary", `Successfully created pass with id: ${response.id}`);
return response;
},
};
33 changes: 33 additions & 0 deletions components/walletap/actions/get-pass/get-pass.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import walletap from "../../walletap.app.mjs";

export default {
key: "walletap-get-pass",
name: "Get Pass",
description: "Gets a Walletap pass by ID. [See the documentation](https://walletap.io/docs/api#tag/Pass/operation/getPass)",
version: "0.0.1",
type: "action",
annotations: {
destructiveHint: false,
openWorldHint: true,
readOnlyHint: true,
},
props: {
walletap,
passId: {
type: "string",
label: "Pass ID",
description: "Internal pass ID or External pass ID",
},
},
async run({ $ }) {
const response = await this.walletap.getPass({
$,
params: {
id: this.passId,
},
});

$.export("$summary", `Successfully retrieved pass with ID: ${response.id}`);
return response;
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import walletap from "../../walletap.app.mjs";

export default {
key: "walletap-send-notification",
name: "Send Notification",
description: "Sends a notification to all pass users. [See the documentation](https://walletap.io/docs/api#tag/Template/operation/sendNotification)",
version: "0.0.1",
type: "action",
annotations: {
destructiveHint: false,
openWorldHint: true,
readOnlyHint: false,
},
props: {
walletap,
title: {
type: "string",
label: "Title",
description: "The title of the notification",
},
content: {
type: "string",
label: "Content",
description: "The content of the notification",
},
},
async run({ $ }) {
const response = await this.walletap.sendNotification({
$,
data: {
title: this.title,
content: this.content,
},
});

$.export("$summary", "Successfully sent notification");
return response;
},
};
83 changes: 83 additions & 0 deletions components/walletap/actions/update-pass/update-pass.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
import { parseObject } from "../../common/utils.mjs";
import walletap from "../../walletap.app.mjs";

export default {
key: "walletap-update-pass",
name: "Update Pass",
description: "Updates an existing Walletap pass and pushes the updated pass to the user. [See the documentation](https://walletap.io/docs/api#tag/Pass/operation/updatePass)",
version: "0.0.1",
type: "action",
annotations: {
destructiveHint: false,
openWorldHint: true,
readOnlyHint: false,
},
props: {
walletap,
passId: {
type: "string",
label: "Pass ID",
description: "Walletap generated pass ID",
},
templateFields: {
type: "object",
label: "Template Fields",
description: "The template fields to update. Generic (object) or Loyalty (object) or Gift Card (object) or Event Ticket (object) or Offer/Coupon (object)",
optional: true,
},
memberId: {
type: "string",
label: "Member ID",
description: "The ID connecting this pass to a member in your system",
optional: true,
},
customFields: {
type: "object",
label: "Custom Fields",
description: "Custom fields defined in pass design, using field IDs as object keys",
optional: true,
},
redemptionValue: {
type: "string",
label: "Redemption Value",
description: "Value to be encoded in barcode and/or NFC payload. If not provided, it is set to `externalId`. If also not provided, it is set to Walletap generated `id`",
optional: true,
},
isValid: {
type: "boolean",
label: "Valid",
description: "If set to `false` it invalidates the pass and moves it to the \"Expired passes\" section in user Wallet",
optional: true,
},
email: {
type: "string",
label: "Email",
description: "The email of the user",
optional: true,
},
phone: {
type: "string",
label: "Phone",
description: "The phone of the user",
optional: true,
},
},
async run({ $ }) {
const response = await this.walletap.updatePass({
$,
data: {
id: this.passId,
templateFields: parseObject(this.templateFields),
memberId: this.memberId,
customFields: parseObject(this.customFields),
redemptionValue: this.redemptionValue,
isValid: this.isValid,
email: this.email,
phone: this.phone,
},
});

$.export("$summary", `Successfully updated pass with id: ${response.id}`);
return response;
},
};
24 changes: 24 additions & 0 deletions components/walletap/common/utils.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
export const parseObject = (obj) => {
if (!obj) return undefined;

if (Array.isArray(obj)) {
return obj.map((item) => {
if (typeof item === "string") {
try {
return JSON.parse(item);
} catch (e) {
return item;
}
}
return item;
});
}
if (typeof obj === "string") {
try {
return JSON.parse(obj);
} catch (e) {
return obj;
}
}
return obj;
};
7 changes: 5 additions & 2 deletions components/walletap/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pipedream/walletap",
"version": "0.0.1",
"version": "0.1.0",
"description": "Pipedream WalleTap Components",
"main": "walletap.app.mjs",
"keywords": [
Expand All @@ -11,5 +11,8 @@
"author": "Pipedream <[email protected]> (https://pipedream.com/)",
"publishConfig": {
"access": "public"
},
"dependencies": {
"@pipedream/platform": "^3.1.0"
}
}
}
48 changes: 45 additions & 3 deletions components/walletap/walletap.app.mjs
Original file line number Diff line number Diff line change
@@ -1,11 +1,53 @@
import { axios } from "@pipedream/platform";

export default {
type: "app",
app: "walletap",
propDefinitions: {},
methods: {
// this.$auth contains connected account data
authKeys() {
console.log(Object.keys(this.$auth));
_apiUrl() {
return "https://api.walletap.io";
},
_getHeaders() {
return {
"x-api-key": this.$auth.api_key,
};
},
_makeRequest({
$ = this, path, ...opts
}) {
return axios($, {
url: `${this._apiUrl()}${path}`,
headers: this._getHeaders(),
...opts,
});
},
createPass(args = {}) {
return this._makeRequest({
method: "POST",
path: "/pass",
...args,
});
},
getPass(args = {}) {
return this._makeRequest({
path: "/pass",
...args,
});
},
updatePass(args = {}) {
return this._makeRequest({
method: "PATCH",
path: "/pass",
...args,
});
},
sendNotification(args = {}) {
return this._makeRequest({
method: "POST",
path: `/template/${this.$auth.template_id}/notification`,
...args,
});
},
},
};
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