From 77a76c669b4f829eb8707231652b66c55389a5c8 Mon Sep 17 00:00:00 2001 From: Rick van Laarhoven Date: Fri, 3 May 2024 18:03:47 +0200 Subject: [PATCH] fix: allow passing recipient email --- src/endpoints/private/shipments/Shipment.types.ts | 9 +++++++-- src/model/client/AbstractClient.spec.ts | 4 ++-- test/mockData.ts | 1 + 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/endpoints/private/shipments/Shipment.types.ts b/src/endpoints/private/shipments/Shipment.types.ts index bf1ac41..619d7e3 100644 --- a/src/endpoints/private/shipments/Shipment.types.ts +++ b/src/endpoints/private/shipments/Shipment.types.ts @@ -6,7 +6,10 @@ import { type PackageTypeId, type ShipmentStatus, } from '@myparcel/constants'; -import {type Address, type AddressWithContactDetails, type RetailLocation} from '../../../types'; +import { + type AddressWithContactDetails, + type RetailLocation, +} from '../../../types'; import {type IntBoolean, type Price, type WithRequired} from '@/types'; export interface PostedShipmentReference { @@ -103,7 +106,9 @@ export interface ShipmentPostData { options?: ShipmentOptions; physical_properties?: PhysicalProperties; pickup?: ShipmentPickup | null; - recipient: WithRequired | WithRequired; + recipient: + | WithRequired + | WithRequired; reference_identifier?: number | string; shop_id?: number; status?: ShipmentStatus; diff --git a/src/model/client/AbstractClient.spec.ts b/src/model/client/AbstractClient.spec.ts index 0c41d6f..3d73be8 100644 --- a/src/model/client/AbstractClient.spec.ts +++ b/src/model/client/AbstractClient.spec.ts @@ -195,7 +195,7 @@ describe('AbstractClient', () => { 'Content-Type': 'application/vnd.shipment+json;charset=utf-8;version=1.1', }, method: 'POST', - body: '{"data":{"shipments":[{"carrier":1,"options":{"package_type":1,"delivery_type":2},"recipient":{"cc":"NL","city":"Hoofddorp","person":"Ms. Parcel","street":"Antareslaan 31","postal_code":"2132 JE"}}]}}', + body: '{"data":{"shipments":[{"carrier":1,"options":{"package_type":1,"delivery_type":2},"recipient":{"cc":"NL","city":"Hoofddorp","person":"Ms. Parcel","street":"Antareslaan 31","postal_code":"2132 JE","email":"example@myparcel.nl"}}]}}', }); }); @@ -209,7 +209,7 @@ describe('AbstractClient', () => { expect(fetchMock).toHaveBeenCalledWith('https://api.myparcel.nl/endpoint', { method: 'POST', - body: '{"data":{"carrier":1,"options":{"package_type":1,"delivery_type":2},"recipient":{"cc":"NL","city":"Hoofddorp","person":"Ms. Parcel","street":"Antareslaan 31","postal_code":"2132 JE"}}}', + body: '{"data":{"carrier":1,"options":{"package_type":1,"delivery_type":2},"recipient":{"cc":"NL","city":"Hoofddorp","person":"Ms. Parcel","street":"Antareslaan 31","postal_code":"2132 JE","email":"example@myparcel.nl"}}}', headers: { Accept: 'application/json', 'Content-Type': 'application/json', diff --git a/test/mockData.ts b/test/mockData.ts index c803ca5..8fa97bb 100644 --- a/test/mockData.ts +++ b/test/mockData.ts @@ -15,6 +15,7 @@ export const POST_BODY_SHIPMENTS: EndpointBody = [ person: 'Ms. Parcel', street: 'Antareslaan 31', postal_code: '2132 JE', + email: 'example@myparcel.nl', }, }, ];