diff --git a/CHANGELOG.md b/CHANGELOG.md index 6c8ab25..a33825c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/package.json b/package.json index 60c16aa..b69df8f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "cobot-zapier", - "version": "2.3.0", + "version": "2.3.1", "description": "", "main": "index.js", "scripts": { diff --git a/src/test/triggers/triggerMembershipCancelled.test.ts b/src/test/triggers/triggerMembershipCancelled.test.ts index 2d71de8..88b4474 100644 --- a/src/test/triggers/triggerMembershipCancelled.test.ts +++ b/src/test/triggers/triggerMembershipCancelled.test.ts @@ -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 = { @@ -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()); diff --git a/src/types/api-responses.d.ts b/src/types/api-responses.d.ts index 570077f..f4752ab 100644 --- a/src/types/api-responses.d.ts +++ b/src/types/api-responses.d.ts @@ -180,6 +180,7 @@ export type MembershipApiResponse = { name: string; } | null; confirmed_at: string | null; + canceled_to?: string; }; export type ContactApiResponse = { diff --git a/src/types/outputs.d.ts b/src/types/outputs.d.ts index 9cf9e1b..4f4f42f 100644 --- a/src/types/outputs.d.ts +++ b/src/types/outputs.d.ts @@ -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 = { diff --git a/src/utils/api-to-output.ts b/src/utils/api-to-output.ts index f686c11..db049f4 100644 --- a/src/utils/api-to-output.ts +++ b/src/utils/api-to-output.ts @@ -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, @@ -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(