Skip to content

Commit

Permalink
Add missing membership details (#195)
Browse files Browse the repository at this point in the history
- Added `phone`, `address` and `plan` fields
  • Loading branch information
wetterkrank authored Dec 18, 2024
1 parent f184116 commit 99f4d1e
Show file tree
Hide file tree
Showing 10 changed files with 152 additions and 12 deletions.
16 changes: 9 additions & 7 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,26 @@ Minor changes to associated `membership` to the invoice on trigger/created_invoi

## 2.2.4

Added associated `contact` to the invoice on trigger/created_invoice.

- Added associated `contact` to the invoice on trigger/created_invoice.
- Added `contact email` and `contact name` fields to the Invoice creation trigger.

## 2.3.0

Added trigger/cancelled_membership
- Added trigger/cancelled_membership

## 2.3.1

Added `canceled_to` field to trigger on trigger/cancelled_membership which gives the date of cancellation
- Added `canceled_to` field to trigger on trigger/cancelled_membership which gives the date of cancellation

## 2.4.0

Added trigger/membership_cancellation_date_reached

- Added trigger/membership_cancellation_date_reached
- This trigger fires on the day a membership cancellation applies

## 2.4.1

Added `accounting_code` field to trigger/created_booking
- Added `accounting_code` field to trigger/created_booking

## 2.4.2

- Added membership `phone`, `address`, and `plan` fields
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cobot-zapier",
"version": "2.4.1",
"version": "2.4.2",
"description": "",
"main": "index.js",
"scripts": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,23 @@ const membershipResponse: MembershipApiResponse = {
address: {
company: "Acme inc",
name: "Sam Duncan",
full_address: "982 Ruguw Terrace",
full_address: "982 Ruguw Terrace\n55112 Bellona",
address: "982 Ruguw Terrace",
city: "Bellona",
post_code: "55112",
state: "AK",
country: "US",
},
payment_method: {
name: "Credit Card",
},
plan: {
name: "Full Time",
description: "Enjoy the stability of a Full Time membership",
total_price_per_cycle: "100.0",
currency: "USD",
cycle_duration: 1,
cancellation_period: 14,
},
customer_number: "123",
confirmed_at: "2012/04/12 12:00:00 +0000",
Expand All @@ -40,9 +50,25 @@ const membershipOutput: MembershipOutput = {
id: "003b37a3-f205-5d9e-9caf-c4ca612075d4",
name: "Sam Duncan",
company: "Acme inc",
address: {
full_address: "982 Ruguw Terrace\n55112 Bellona",
address: "982 Ruguw Terrace",
city: "Bellona",
post_code: "55112",
state: "AK",
country: "US",
},
email: "[email protected]",
phone: null,
customer_number: "123",
plan_name: "Full Time",
plan: {
description: "Enjoy the stability of a Full Time membership",
total_price_per_cycle: "100.0",
currency: "USD",
cycle_duration: 1,
cancellation_period: 14,
},
payment_method_name: "Credit Card",
confirmed_at: "2012-04-12",
canceled_to: "2012-04-14",
Expand Down
28 changes: 27 additions & 1 deletion src/test/triggers/triggerMembershipCancelled.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,23 @@ const membershipResponse: MembershipApiResponse = {
address: {
company: "Acme inc",
name: "Sam Duncan",
full_address: "982 Ruguw Terrace",
full_address: "982 Ruguw Terrace\n55112 Bellona",
address: "982 Ruguw Terrace",
city: "Bellona",
post_code: "55112",
state: "AK",
country: "US",
},
payment_method: {
name: "Credit Card",
},
plan: {
name: "Full Time",
description: "Enjoy the stability of a Full Time membership",
total_price_per_cycle: "100.0",
currency: "USD",
cycle_duration: 1,
cancellation_period: 14,
},
customer_number: "123",
confirmed_at: "2012/04/12 12:00:00 +0000",
Expand All @@ -40,9 +50,25 @@ const membershipOutput: MembershipOutput = {
id: "003b37a3-f205-5d9e-9caf-c4ca612075d4",
name: "Sam Duncan",
company: "Acme inc",
address: {
full_address: "982 Ruguw Terrace\n55112 Bellona",
address: "982 Ruguw Terrace",
city: "Bellona",
post_code: "55112",
state: "AK",
country: "US",
},
email: "[email protected]",
phone: null,
customer_number: "123",
plan_name: "Full Time",
plan: {
description: "Enjoy the stability of a Full Time membership",
total_price_per_cycle: "100.0",
currency: "USD",
cycle_duration: 1,
cancellation_period: 14,
},
payment_method_name: "Credit Card",
confirmed_at: "2012-04-12",
canceled_to: "2012-04-14",
Expand Down
30 changes: 28 additions & 2 deletions src/test/triggers/triggerMembershipConfirmed.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,27 @@ const membershipResponse: MembershipApiResponse = {
id: "003b37a3-f205-5d9e-9caf-c4ca612075d4",
name: "Sam Duncan",
email: "[email protected]",
phone: null,
phone: "+1 555 683 4463",
address: {
company: "Acme inc",
name: "Sam Duncan",
full_address: "982 Ruguw Terrace",
full_address: "982 Ruguw Terrace\n55112 Bellona",
address: "982 Ruguw Terrace",
city: "Bellona",
post_code: "55112",
state: "AK",
country: "US",
},
payment_method: {
name: "Credit Card",
},
plan: {
name: "Full Time",
description: "Enjoy the stability of a Full Time membership",
total_price_per_cycle: "100.0",
currency: "USD",
cycle_duration: 1,
cancellation_period: 14,
},
customer_number: "123",
confirmed_at: "2012/04/12 12:00:00 +0000",
Expand All @@ -38,9 +48,25 @@ const membershipOutput: MembershipOutput = {
id: "003b37a3-f205-5d9e-9caf-c4ca612075d4",
name: "Sam Duncan",
company: "Acme inc",
address: {
full_address: "982 Ruguw Terrace\n55112 Bellona",
address: "982 Ruguw Terrace",
city: "Bellona",
post_code: "55112",
state: "AK",
country: "US",
},
email: "[email protected]",
phone: "+1 555 683 4463",
customer_number: "123",
plan_name: "Full Time",
plan: {
description: "Enjoy the stability of a Full Time membership",
total_price_per_cycle: "100.0",
currency: "USD",
cycle_duration: 1,
cancellation_period: 14,
},
payment_method_name: "Credit Card",
confirmed_at: "2012-04-12",
};
Expand Down
1 change: 1 addition & 0 deletions src/test/utils/mockBundle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export const mockBundle: KontentBundle<{}> = {
},
inputData: {},
inputDataRaw: {},
// https://docs.zapier.com/platform/build-cli/core#bundle-meta
meta: {
isBulkRead: false,
page: 0,
Expand Down
11 changes: 11 additions & 0 deletions src/types/api-responses.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ export type EventApiResponse = {
};
};

// Note: APIv2 address
type Address = {
company: string | null;
name: string | null;
Expand Down Expand Up @@ -172,10 +173,20 @@ export type MembershipApiResponse = {
company: string | null;
name: string | null;
full_address: string | null;
address: string | null;
post_code: string | null;
city: string | null;
state: string | null;
country: string | null;
};
customer_number: string | null;
plan: {
name: string;
description: string | null;
total_price_per_cycle: string;
currency: string | null;
cycle_duration: number;
cancellation_period: number | null;
};
payment_method: {
name: string;
Expand Down
16 changes: 16 additions & 0 deletions src/types/outputs.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,26 @@ export type ExternalBookingOutput = {
export type MembershipOutput = {
id: string;
name: string | null;
phone: string | null;
company: string | null;
address: {
full_address: string | null;
address: string | null;
city: string | null;
post_code: string | null;
state: string | null;
country: string | null;
};
email: string | null;
customer_number: string | null;
plan_name: string;
plan: {
description: string | null;
total_price_per_cycle: string;
cycle_duration: number;
currency: string | null;
cancellation_period: number | null;
};
payment_method_name: string | null;
confirmed_at: string | null;
canceled_to?: string;
Expand Down
16 changes: 16 additions & 0 deletions src/utils/api-to-output.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,25 @@ export function apiResponseToMembershipOutput(
id: membership.id,
name: membership.name,
email: membership.email,
phone: membership.phone,
company: membership.address.company,
address: {
full_address: membership.address.full_address,
address: membership.address.address,
city: membership.address.city,
post_code: membership.address.post_code,
state: membership.address.state,
country: membership.address.country,
},
customer_number: membership.customer_number,
plan_name: membership.plan.name,
plan: {
description: membership.plan.description,
total_price_per_cycle: membership.plan.total_price_per_cycle,
cycle_duration: membership.plan.cycle_duration,
currency: membership.plan.currency,
cancellation_period: membership.plan.cancellation_period,
},
payment_method_name: membership.payment_method?.name ?? null,
confirmed_at:
membership.confirmed_at?.replaceAll("/", "-").substring(0, 10) ?? null,
Expand Down
16 changes: 16 additions & 0 deletions src/utils/samples.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,25 @@ export const membershipSample: MembershipOutput = {
id: "003b37a3-f205-5d9e-9caf-c4ca612075d4",
name: "Sam Duncan",
company: "",
address: {
full_address: "982 Ruguw Terrace\n55112 Bellona",
address: "982 Ruguw Terrace",
city: "Bellona",
post_code: "55112",
state: "AK",
country: "US",
},
email: "[email protected]",
phone: "+1 555 683 4463",
customer_number: "123",
plan_name: "Full Time",
plan: {
description: "Enjoy the stability of a Full Time membership",
total_price_per_cycle: "100.0",
currency: "USD",
cycle_duration: 1,
cancellation_period: 14,
},
payment_method_name: "Credit Card",
confirmed_at: "2012-04-12",
canceled_to: "2012-04-12",
Expand Down

0 comments on commit 99f4d1e

Please sign in to comment.