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
5 changes: 5 additions & 0 deletions components/zylvie/common/constants.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const BASE_URL = "https://api.zylvie.com";

export default {
BASE_URL,
};
7 changes: 5 additions & 2 deletions components/zylvie/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pipedream/zylvie",
"version": "0.0.1",
"version": "0.1.0",
"description": "Pipedream Zylvie Components",
"main": "zylvie.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.0"
}
}
}
7 changes: 7 additions & 0 deletions components/zylvie/sources/common/triggers.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export default {
SALE: "sale",
LEAD: "lead",
AFFILIATE: "affiliate",
SUBSCRIPTION: "subscription",
CANCEL: "cancel",
};
67 changes: 67 additions & 0 deletions components/zylvie/sources/common/webhook.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import { ConfigurationError } from "@pipedream/platform";
import app from "../../zylvie.app.mjs";

export default {
props: {
app,
http: "$.interface.http",
},
hooks: {
async activate() {
const {
createWebhook,
getTriggerName,
http: { endpoint },
} = this;
await createWebhook({
debug: true,
data: {
trigger: getTriggerName(),
webhook_url: endpoint,
},
});
},
async deactivate() {
const {
deleteWebhook,
http: { endpoint },
} = this;
await deleteWebhook({
debug: true,
data: {
webhook_url: endpoint,
},
});
},
},
methods: {
generateMeta() {
throw new ConfigurationError("generateMeta is not implemented");
},
getTriggerName() {
throw new ConfigurationError("getTriggerName is not implemented");
},
processResource(resource) {
this.$emit(resource, this.generateMeta(resource));
},
createWebhook(args = {}) {
return this.app.post({
path: "/webhooks/subscribe",
...args,
});
},
deleteWebhook(args = {}) {
return this.app.delete({
path: "/webhooks/unsubscribe",
...args,
});
},
},
async run({ body }) {
this.http.respond({
status: 200,
});

this.processResource(body);
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import common from "../common/webhook.mjs";
import triggers from "../common/triggers.mjs";
import sampleEmit from "./test-event.mjs";

export default {
...common,
key: "zylvie-new-affiliate-sign-up-instant",
name: "New Affiliate Sign Up (Instant)",
description: "Emit new event when a visitor signs up to be an affiliate or when they accept an invitation to be an affiliate. [See the documentation](https://developers.zylvie.com/webhooks/subscribe).",
version: "0.0.1",
type: "source",
dedupe: "unique",
methods: {
...common.methods,
getTriggerName() {
return triggers.AFFILIATE;
},
generateMeta(payload) {
const { data: resource } = payload;
const ts = Date.parse(resource.accepted_at);
return {
id: resource.id,
summary: `New Affiliate: ${resource.affiliate.name || resource.affiliate.email}`,
ts,
};
},
},
sampleEmit,
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
export default {
"event": "affiliate",
"data": {
"accepted_at": "2025-03-23T03:12:35Z",
"affiliate": {
"username": "stavros.flatley",
"name": "Stavros Flatley",
"email": "stavros@greek.com"
},
"commission_percentage": 35.0,
"products": {
"allowed_for_all_products": false,
"allowed_products": [
{
"title": "The Ultimate Business Book",
"price": 0.0
}
]
}
}
};
28 changes: 28 additions & 0 deletions components/zylvie/sources/new-lead-instant/new-lead-instant.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import common from "../common/webhook.mjs";
import triggers from "../common/triggers.mjs";
import sampleEmit from "./test-event.mjs";

export default {
...common,
key: "zylvie-new-lead-instant",
name: "New Lead (Instant)",
description: "Emit new event when a user submits their name and email to receive a free product/lead magnet. [See the documentation](https://developers.zylvie.com/webhooks/subscribe).",
version: "0.0.1",
type: "source",
dedupe: "unique",
methods: {
...common.methods,
getTriggerName() {
return triggers.LEAD;
},
generateMeta(payload) {
const { data: resource } = payload;
return {
id: resource.transaction_id,
summary: `New Lead: ${resource.transaction_id}`,
ts: Date.parse(resource.created_at),
};
},
},
sampleEmit,
};
25 changes: 25 additions & 0 deletions components/zylvie/sources/new-lead-instant/test-event.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
export default {
"event": "lead",
"data": {
"transaction_id": "free_1711078342965279",
"created_at": "2025-03-23T03:12:35Z",
"buyer": {
"name": "Stavros Flatley",
"email": "stavros@greek.com",
"permission_to_send_emails": true
},
"products": [
{
"title": "The Ultimate Business Book",
"price": 0.0,
"quantity": 1
}
],
"custom_fields": [
{
"name": "Tax identification number",
"value": "TIN-5252445767"
}
]
}
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import common from "../common/webhook.mjs";
import triggers from "../common/triggers.mjs";
import sampleEmit from "./test-event.mjs";

export default {
...common,
key: "zylvie-new-subscription-instant",
name: "New Subscription (Instant)",
description: "Emit new event when a user subscribes to a subscription product, whether free trial or otherwise. [See the documentation](https://developers.zylvie.com/webhooks/subscribe).",
version: "0.0.1",
type: "source",
dedupe: "unique",
methods: {
...common.methods,
getTriggerName() {
return triggers.SUBSCRIPTION;
},
generateMeta(payload) {
const { data: resource } = payload;
return {
id: resource.subscription_id,
summary: `New Subscription: ${resource.subscription_id}`,
ts: Date.parse(resource.created_at),
};
},
},
sampleEmit,
};
51 changes: 51 additions & 0 deletions components/zylvie/sources/new-subscription-instant/test-event.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
export default {
"event": "subscription",
"data": {
"subscription_id": "sub_1OoXxPF18w81dttLN6XyvuBl",
"created_at": "2025-02-27T21:12:59Z",
"cancel_at": null,
"canceled_at": null,
"trial_end": "2025-03-22T21:12:59Z",
"trial_start": "2025-02-27T21:12:59Z",
"currency": "usd",
"amount": 99.99,
"interval": "month",
"interval_count": 1,
"stripe_price_id": "price_1OkfZsF18w81dttL2OgdOtEj",
"status": "active",
"product": {
"title": "Life Coaching (Pro Tier)"
},
"buyer": {
"name": "Stavros Flatley",
"email": "stavros@greek.com",
"permission_to_send_emails": true,
"phone": "+353850163326",
"line1": "349 Navan Road",
"line2": "Ashtown",
"postal_code": "D07 R2C3",
"city": "Dublin 7",
"state": "County Dublin",
"country": "IE",
"payment_method_type": "card",
"card_brand": "visa",
"card_last4": "0005"
},
"coupon": {
"code": "20OFF",
"type": "percentage",
"amount": 20.0
},
"referrer": {
"email": "john.cena@zlappo.com"
},
"custom_fields": [
{
"name": "Tax identification number",
"value": "TIN-5252445767"
}
],
"commission_earned": 41.99,
"commission_paid": false
}
};
36 changes: 32 additions & 4 deletions components/zylvie/zylvie.app.mjs
Original file line number Diff line number Diff line change
@@ -1,11 +1,39 @@
import { axios } from "@pipedream/platform";
import constants from "./common/constants.mjs";

export default {
type: "app",
app: "zylvie",
propDefinitions: {},
methods: {
// this.$auth contains connected account data
authKeys() {
console.log(Object.keys(this.$auth));
getUrl(path) {
return `${constants.BASE_URL}${path}`;
},
getHeaders(headers) {
return {
"Authorization": `Bearer ${this.$auth.api_key}`,
...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,
});
},
},
};
5 changes: 4 additions & 1 deletion pnpm-lock.yaml

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