Skip to content

Commit

Permalink
Added canceled_to field to Cancelled memberships trigger (#177)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jsnxyz authored Oct 18, 2024
1 parent 5ab0353 commit 9d38d33
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,7 @@ Added associated `contact` to the invoice on trigger/created_invoice.
## 2.3.0

Added trigger/cancelled_membership

## 2.3.1

Added `canceled_to` field to trigger on trigger/cancelled_membership which gives the date of cancellation
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.3.0",
"version": "2.3.1",
"description": "",
"main": "index.js",
"scripts": {
Expand Down
2 changes: 2 additions & 0 deletions src/test/triggers/triggerMembershipCancelled.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ const membershipResponse: MembershipApiResponse = {
},
customer_number: "123",
confirmed_at: "2012/04/12 12:00:00 +0000",
canceled_to: "2012/04/14",
};

const membershipOutput: MembershipOutput = {
Expand All @@ -44,6 +45,7 @@ const membershipOutput: MembershipOutput = {
plan_name: "Full Time",
payment_method_name: "Credit Card",
confirmed_at: "2012-04-12",
canceled_to: "2012-04-14",
};

afterEach(() => nock.cleanAll());
Expand Down
1 change: 1 addition & 0 deletions src/types/api-responses.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ export type MembershipApiResponse = {
name: string;
} | null;
confirmed_at: string | null;
canceled_to?: string;
};

export type ContactApiResponse = {
Expand Down
1 change: 1 addition & 0 deletions src/types/outputs.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ export type MembershipOutput = {
plan_name: string;
payment_method_name: string | null;
confirmed_at: string | null;
canceled_to?: string;
};

export type InvoiceMembershipOutput = {
Expand Down
6 changes: 5 additions & 1 deletion src/utils/api-to-output.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { ExternalBookingWithResourceApiResponse, apiCallUrl } from "./api";
export function apiResponseToMembershipOutput(
membership: MembershipApiResponse,
): MembershipOutput {
return {
const output: MembershipOutput = {
id: membership.id,
name: membership.name,
email: membership.email,
Expand All @@ -30,6 +30,10 @@ export function apiResponseToMembershipOutput(
confirmed_at:
membership.confirmed_at?.replaceAll("/", "-").substring(0, 10) ?? null,
};
if (membership.canceled_to) {
output.canceled_to = membership.canceled_to.replaceAll("/", "-");
}
return output;
}

export async function apiResponseToInvoiceOutput(
Expand Down
1 change: 1 addition & 0 deletions src/utils/samples.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ export const membershipSample: MembershipOutput = {
plan_name: "Full Time",
payment_method_name: "Credit Card",
confirmed_at: "2012-04-12",
canceled_to: "2012-04-12",
};

export const invoiceSample: InvoiceOutput = {
Expand Down

0 comments on commit 9d38d33

Please sign in to comment.