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
83 changes: 83 additions & 0 deletions components/givebutter/actions/create-contact/create-contact.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
// x-pd-ai: optimized
import givebutter from "../../givebutter.app.mjs";

export default {
key: "givebutter-create-contact",
name: "Create Contact",
description: "Create a new contact/donor in Givebutter, returning the created contact with its assigned `id`. For an individual contact, provide `firstName` and `lastName`; the `email` value is submitted as the API `primary_email` field. [See the documentation](https://docs.givebutter.com/api-reference/contacts/create-a-contact)",
version: "0.0.1",
type: "action",
annotations: {
readOnlyHint: false,
destructiveHint: false,
openWorldHint: true,
},
props: {
givebutter,
firstName: {
propDefinition: [
givebutter,
"firstName",
],
description: "Contact's first name (max 255 chars). For an individual contact without email or phone, provide both first and last names. Maps to the API `first_name` field.",
},
lastName: {
propDefinition: [
givebutter,
"lastName",
],
description: "Contact's last name (max 255 chars). Maps to the API `last_name` field.",
},
Comment thread
Priyadharshan-Pdm marked this conversation as resolved.
email: {
propDefinition: [
givebutter,
"email",
],
description: "Contact's primary email address. Submitted to Givebutter as the `primary_email` field. Example: `jane@example.com`.",
},
phone: {
propDefinition: [
givebutter,
"phone",
],
description: "Contact's primary phone number. Maps to the API `primary_phone` field. Example: `+15555550100`.",
},
type: {
propDefinition: [
givebutter,
"contactType",
],
description: "Type of contact to create. For `company`, provide **Company Name** instead of first/last name.",
},
companyName: {
propDefinition: [
givebutter,
"companyName",
],
description: "Company name (max 255 chars). Required when **Type** is `company`. Maps to the API `company_name` field.",
},
tags: {
propDefinition: [
givebutter,
"tags",
],
description: "Optional list of tag strings to attach to the contact (max 64 tags). Example: `[\"vip\", \"newsletter\"]`.",
},
},
async run({ $ }) {
const contact = await this.givebutter.createContact({
$,
data: {
first_name: this.firstName,
last_name: this.lastName,
primary_email: this.email,
primary_phone: this.phone,
type: this.type,
company_name: this.companyName,
tags: this.tags,
},
});
$.export("$summary", `Created contact ${contact?.id} - ${contact?.first_name ?? ""} ${contact?.last_name ?? ""}`.trim());
return contact;
},
};
31 changes: 31 additions & 0 deletions components/givebutter/actions/get-transaction/get-transaction.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// x-pd-ai: optimized
import givebutter from "../../givebutter.app.mjs";

export default {
key: "givebutter-get-transaction",
name: "Get Transaction",
description: "Retrieve a single transaction from Givebutter by its transaction ID. Returns the transaction object (includes `id`, `amount`, `fee`, `captured`, `refunded`, and `line_items`). [See the documentation](https://docs.givebutter.com/api-reference/transactions/get-a-transaction)",
version: "0.0.1",
type: "action",
annotations: {
readOnlyHint: true,
destructiveHint: false,
openWorldHint: true,
},
props: {
givebutter,
transactionId: {
type: "string",
label: "Transaction ID",
description: "The transaction ID (the Givebutter transaction `tid`, a string, e.g. `AbCd1234`). Obtain it from a transaction event or from your Givebutter dashboard; there is no list-transactions action in this set.",
},
},
async run({ $ }) {
const transaction = await this.givebutter.getTransaction({
$,
transactionId: this.transactionId,
});
$.export("$summary", `Retrieved transaction ${transaction?.id ?? this.transactionId}`);
return transaction;
},
};
45 changes: 45 additions & 0 deletions components/givebutter/actions/list-campaigns/list-campaigns.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// x-pd-ai: optimized
import givebutter from "../../givebutter.app.mjs";

export default {
key: "givebutter-list-campaigns",
name: "List Campaigns",
description: "List campaigns from the authenticated Givebutter account. Returns a paginated array of campaign objects (each includes at minimum `id`, `code`, and `title`). Use this to discover campaign IDs before referencing a campaign in other tools. [See the documentation](https://docs.givebutter.com/api-reference/campaigns/list-all-campaigns)",
version: "0.0.1",
type: "action",
annotations: {
readOnlyHint: true,
destructiveHint: false,
openWorldHint: true,
},
props: {
givebutter,
page: {
propDefinition: [
givebutter,
"page",
],
},
limit: {
propDefinition: [
givebutter,
"limit",
],
},
},
async run({ $ }) {
const response = await this.givebutter.listCampaigns({
$,
params: {
page: this.page,
per_page: this.limit,
},
});
const campaigns = response?.data ?? response;
const count = Array.isArray(campaigns)
? campaigns.length
: "unknown number of";
$.export("$summary", `Retrieved ${count} campaign(s)`);
return response;
},
};
77 changes: 77 additions & 0 deletions components/givebutter/actions/list-contacts/list-contacts.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
// x-pd-ai: optimized
import givebutter from "../../givebutter.app.mjs";

export default {
key: "givebutter-list-contacts",
name: "List Contacts",
description: "List contacts/donors from the authenticated Givebutter account. Returns a paginated array of contact objects (each includes at minimum `id`, `primary_email`, `first_name`, and `last_name`). Note that the API returns only `individual` contacts unless **Type** is set to `company`. Use this to discover contact IDs before calling **Update Contact**. [See the documentation](https://docs.givebutter.com/api-reference/contacts/list-all-contacts)",
version: "0.0.1",
type: "action",
annotations: {
readOnlyHint: true,
destructiveHint: false,
openWorldHint: true,
},
props: {
givebutter,
type: {
propDefinition: [
givebutter,
"contactType",
],
description: "Contact type to list. The Givebutter API defaults to `individual`, so company contacts are omitted unless this is explicitly set to `company`.",
},
email: {
propDefinition: [
givebutter,
"email",
],
description: "Optional exact email to filter contacts by (maps to the API `email` query param). Example: `jane@example.com`.",
},
sortBy: {
type: "string",
label: "Sort By",
description: "Optional field to sort by.",
options: [
"name_or_company",
"primary_email",
"point_of_contact",
"created_at",
"total_contributions",
"recurring_contributions",
"last_donation_amount",
],
optional: true,
},
page: {
propDefinition: [
givebutter,
"page",
],
},
limit: {
propDefinition: [
givebutter,
"limit",
],
},
},
async run({ $ }) {
const response = await this.givebutter.listContacts({
$,
params: {
type: this.type,
email: this.email,
sortBy: this.sortBy,
page: this.page,
per_page: this.limit,
},
Comment thread
coderabbitai[bot] marked this conversation as resolved.
});
const contacts = response?.data ?? response;
const count = Array.isArray(contacts)
? contacts.length
: "unknown number of";
$.export("$summary", `Retrieved ${count} contact(s)`);
return response;
},
};
137 changes: 137 additions & 0 deletions components/givebutter/actions/update-contact/update-contact.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
// x-pd-ai: optimized
import { ConfigurationError } from "@pipedream/platform";
import givebutter from "../../givebutter.app.mjs";

export default {
key: "givebutter-update-contact",
name: "Update Contact",
description: "Update an existing Givebutter contact, returning the updated contact object. Set only the fields you want to change. Use **List Contacts** first to find the contact ID. Note that Givebutter validates this as a full update — individual contacts require `first_name` and `last_name`, and company contacts require `company_name`, even when those values are not changing — so this action reads the contact first and re-sends its existing name and company values automatically. [See the documentation](https://docs.givebutter.com/api-reference/contacts/update-a-contact)",
Comment thread
Priyadharshan-Pdm marked this conversation as resolved.
version: "0.0.1",
type: "action",
annotations: {
readOnlyHint: false,
destructiveHint: false,
openWorldHint: true,
},
props: {
givebutter,
contactId: {
type: "string",
label: "Contact ID",
description: "The ID of the contact to update (an integer identifier, e.g. `12345`). Run **List Contacts** to find valid contact IDs.",
},
firstName: {
propDefinition: [
givebutter,
"firstName",
],
},
lastName: {
propDefinition: [
givebutter,
"lastName",
],
},
email: {
propDefinition: [
givebutter,
"email",
],
description: "Email address to set on the contact, submitted in the API `emails` array. Example: `jane.updated@example.com`. Becomes the contact's primary email unless `Email Is Primary` is set to `false`.",
},
emailIsPrimary: {
type: "boolean",
label: "Email Is Primary",
description: "Whether `Email` becomes the contact's primary email address (the API `is_primary` flag). Defaults to `true`; set to `false` to add it as a secondary address, leaving the existing primary in place. Ignored when `Email` is not set.",
default: true,
optional: true,
},
phone: {
propDefinition: [
givebutter,
"phone",
],
description: "Phone number to set on the contact, submitted in the API `phones` array. Example: `+15555550100`. Becomes the contact's primary phone unless `Phone Is Primary` is set to `false`.",
},
phoneIsPrimary: {
type: "boolean",
label: "Phone Is Primary",
description: "Whether `Phone` becomes the contact's primary phone number (the API `is_primary` flag). Defaults to `true`; set to `false` to add it as a secondary number, leaving the existing primary in place. Ignored when `Phone` is not set.",
default: true,
optional: true,
},
companyName: {
propDefinition: [
givebutter,
"companyName",
],
},
note: {
type: "string",
label: "Note",
description: "Optional note to set on the contact.",
optional: true,
},
tags: {
propDefinition: [
givebutter,
"tags",
],
description: "Optional list of tag strings to set on the contact (max 64 tags), replacing the contact's existing tags. Example: `[\"vip\", \"newsletter\"]`.",
},
},
async run({ $ }) {
if (this.email?.trim() === "" || this.phone?.trim() === "") {
throw new ConfigurationError("Email and Phone cannot be blank. Omit the prop entirely to leave the contact's existing value unchanged.");
}

const updates = [
this.firstName,
this.lastName,
this.email,
this.phone,
this.companyName,
this.note,
this.tags,
];
if (updates.every((value) => value === undefined || value === null)) {
Comment thread
Priyadharshan-Pdm marked this conversation as resolved.
throw new ConfigurationError("Set at least one field to update.");
}

const existing = await this.givebutter.getContact({
$,
contactId: this.contactId,
});
const current = existing?.data ?? existing;

const contact = await this.givebutter.updateContact({
$,
contactId: this.contactId,
data: {
first_name: this.firstName ?? current?.first_name,
last_name: this.lastName ?? current?.last_name,
company_name: this.companyName ?? current?.company_name,
...(this.email && {
emails: [
{
value: this.email,
is_primary: this.emailIsPrimary ?? true,
},
],
}),
...(this.phone && {
phones: [
{
value: this.phone,
is_primary: this.phoneIsPrimary ?? true,
},
],
}),
note: this.note,
tags: this.tags,
},
Comment thread
coderabbitai[bot] marked this conversation as resolved.
});
$.export("$summary", `Updated contact ${contact?.id ?? this.contactId}`);
return contact;
},
};
2 changes: 2 additions & 0 deletions components/givebutter/common/constants.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export const DEFAULT_PER_PAGE = 20;
export const MAX_PER_PAGE = 100;
Loading
Loading