Skip to content

17080 components leaddyno #17099

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 17, 2025
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
78 changes: 78 additions & 0 deletions components/leaddyno/actions/create-affiliate/create-affiliate.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
import leaddyno from "../../leaddyno.app.mjs";

export default {
key: "leaddyno-create-affiliate",
name: "Create Affiliate",
description: "Creates a new affiliate in LeadDyno. [See the documentation](https://app.theneo.io/leaddyno/leaddyno-rest-api/affiliates/post-affiliates)",
version: "0.0.1",
type: "action",
props: {
leaddyno,
email: {
type: "string",
label: "Email",
description: "The email address of the affiliate",
},
firstName: {
type: "string",
label: "First Name",
description: "The first name of the affiliate",
optional: true,
},
lastName: {
type: "string",
label: "Last Name",
description: "The last name of the affiliate",
optional: true,
},
affiliateCode: {
type: "string",
label: "Affiliate Code",
description: "A custom affiliate code for the new affiliate",
optional: true,
},
paypalEmail: {
type: "string",
label: "PayPal Email",
description: "The PayPal email address for affiliate payouts",
optional: true,
},
unsubscribed: {
type: "boolean",
label: "Unsubscribed",
description: "Indicates whether the affiliate is unsubscribed from communications",
optional: true,
},
affiliateType: {
type: "string",
label: "Affiliate Type",
description: "The code for the affiliate's group",
optional: true,
},
overrideApproval: {
type: "boolean",
label: "Override Approval",
description: "If set to true, the affiliate will not require approval",
optional: true,
},
},
async run({ $ }) {
const response = await this.leaddyno.createAffiliate({
$,
data: {
email: this.email,
first_name: this.firstName,
last_name: this.lastName,
affiliate_code: this.affiliateCode,
paypal_email: this.paypalEmail,
unsubscribed: this.unsubscribed,
affiliate_type: this.affiliateType,
override_approval: this.overrideApproval,
},
});

$.export("$summary", `Successfully created affiliate with ID ${response.id}`);

return response;
},
};
108 changes: 108 additions & 0 deletions components/leaddyno/actions/create-lead/create-lead.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
import leaddyno from "../../leaddyno.app.mjs";

export default {
key: "leaddyno-create-lead",
name: "Create Lead",
description: "Creates a new lead in LeadDyno. [See the documentation](https://app.theneo.io/leaddyno/leaddyno-rest-api/leaddyno-api#POSTCreate-a-lead)",
version: "0.0.1",
type: "action",
props: {
leaddyno,
email: {
type: "string",
label: "Email",
description: "The email address of the lead",
},
firstName: {
type: "string",
label: "First Name",
description: "The first name of the lead",
optional: true,
},
lastName: {
type: "string",
label: "Last Name",
description: "The last name of the lead",
optional: true,
},
address1: {
type: "string",
label: "Address 1",
description: "The first line of the address of the lead",
optional: true,
},
address2: {
type: "string",
label: "Address 2",
description: "The second line of the address of the lead",
optional: true,
},
city: {
type: "string",
label: "City",
description: "The city of the lead",
optional: true,
},
state: {
type: "string",
label: "State",
description: "The state of the lead",
optional: true,
},
zipcode: {
type: "string",
label: "Zipcode",
description: "The zipcode of the lead",
optional: true,
},
country: {
type: "string",
label: "Country",
description: "The country of the lead",
optional: true,
},
phone: {
type: "string",
label: "Phone",
description: "The phone number of the lead",
optional: true,
},
affiliate: {
propDefinition: [
leaddyno,
"affiliate",
],
optional: true,
},
customStatus: {
type: "string",
label: "Custom Status",
description: "The custom status of the lead",
optional: true,
},
},
async run({ $ }) {

const response = await this.leaddyno.createLead({
$,
data: {
email: this.email,
first_name: this.firstName,
last_name: this.lastName,
address1: this.address1,
address2: this.address2,
city: this.city,
state: this.state,
zipcode: this.zipcode,
country: this.country,
phone: this.phone,
affiliate: this.affiliate,
custom_status: this.customStatus,
},
});

$.export("$summary", `Successfully created lead with email ${this.email}`);

return response;
},
};
88 changes: 88 additions & 0 deletions components/leaddyno/actions/create-purchase/create-purchase.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
import { parseObject } from "../../common/utils.mjs";
import leaddyno from "../../leaddyno.app.mjs";

export default {
key: "leaddyno-create-purchase",
name: "Create Purchase",
description: "Creates a new purchase in LeadDyno. [See the documentation](https://app.theneo.io/leaddyno/leaddyno-rest-api/purchases/post-purchases)",
version: "0.0.1",
type: "action",
props: {
leaddyno,
email: {
propDefinition: [
leaddyno,
"leadEmail",
],
},
purchaseCode: {
type: "string",
label: "Purchase Code",
description: "A unique identifier for this purchase. If not provided, a unique ID will be generated",
optional: true,
},
purchaseAmount: {
type: "string",
label: "Purchase Amount",
description: "The total amount of the purchase, used for percentage commission calculations",
optional: true,
},
planCode: {
type: "string",
label: "Plan Code",
description: "The code of the reward structure used for calculating affiliate commissions",
optional: true,
},
affiliateCode: {
propDefinition: [
leaddyno,
"affiliateCode",
],
optional: true,
},
commissionAmount: {
type: "string",
label: "Commission Amount Override",
description: "An overriding commission amount that will replace any predefined plan and provide an immediate fixed-amount commission. This value should be a decimal",
optional: true,
},
description: {
type: "string",
label: "Description",
description: "Text description of the purchase",
optional: true,
},
reassignAffiliate: {
type: "boolean",
label: "Reassign Affiliate",
description: "If set to false, the original affiliate of the lead will be retained.",
optional: true,
},
lineItems: {
type: "string[]",
label: "Line Items",
description: "A list of JSON object containing the line items associated with the purchase. **Format: [{\"sku\": \"string\", \"description\": \"string\", \"quantity\": \"string\", \"amount\": \"string\"}]**",
optional: true,
},
},
async run({ $ }) {
const response = await this.leaddyno.createPurchase({
$,
data: {
email: this.email,
purchase_code: this.purchaseCode,
purchase_amount: this.purchaseAmount && parseFloat(this.purchaseAmount),
plan_code: this.planCode,
code: this.affiliateCode,
commission_amount_override: this.commissionAmount && parseFloat(this.commissionAmount),
description: this.description,
reassign_affiliate: this.reassignAffiliate,
line_items: parseObject(this.lineItems),
},
});

$.export("$summary", `Successfully created purchase with ID ${response.id}`);

return response;
},
};
28 changes: 28 additions & 0 deletions components/leaddyno/actions/retrieve-lead/retrieve-lead.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import leaddyno from "../../leaddyno.app.mjs";

export default {
key: "leaddyno-retrieve-lead",
name: "Retrieve Lead",
description: "Retrieves information about a lead from LeadDyno. [See the documentation](https://app.theneo.io/leaddyno/leaddyno-rest-api/leads/retrieve-a-lead-by-id)",
version: "0.0.1",
type: "action",
props: {
leaddyno,
leadId: {
propDefinition: [
leaddyno,
"leadId",
],
description: "The ID of the lead to retrieve",
},
},
async run({ $ }) {
const response = await this.leaddyno.getLead({
$,
leadId: this.leadId,
});

$.export("$summary", `Successfully retrieved lead with ID ${this.leadId}`);
return response;
},
};
24 changes: 24 additions & 0 deletions components/leaddyno/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;
};
Loading
Loading