Skip to content

Commit

Permalink
fix: allow passing recipient email
Browse files Browse the repository at this point in the history
  • Loading branch information
rvanlaarhoven authored and EdieLemoine committed Oct 3, 2024
1 parent 7af85c3 commit 4be61ac
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
9 changes: 7 additions & 2 deletions src/endpoints/private/shipments/Shipment.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -103,7 +106,9 @@ export interface ShipmentPostData {
options?: ShipmentOptions;
physical_properties?: PhysicalProperties;
pickup?: ShipmentPickup | null;
recipient: WithRequired<Address, 'number'> | WithRequired<Address, 'street'>;
recipient:
| WithRequired<AddressWithContactDetails, 'number'>
| WithRequired<AddressWithContactDetails, 'street'>;
reference_identifier?: number | string;
shop_id?: number;
status?: ShipmentStatus;
Expand Down
4 changes: 2 additions & 2 deletions src/model/client/AbstractClient.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"}}]}}',
});
});

Expand All @@ -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',
Expand Down
1 change: 1 addition & 0 deletions test/mockData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export const POST_BODY_SHIPMENTS: EndpointBody<PostShipments> = [
person: 'Ms. Parcel',
street: 'Antareslaan 31',
postal_code: '2132 JE',
email: 'example@myparcel.nl',
},
},
];

0 comments on commit 4be61ac

Please sign in to comment.