-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
111 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import { AxiosInstance } from "axios"; | ||
import { APIGroup } from "./common"; | ||
import { CustomerContact } from "./customers"; | ||
|
||
export class PassengerAPI extends APIGroup { | ||
private booking: number; | ||
private id: number; | ||
|
||
constructor(axios: AxiosInstance, booking: number, passenger: number) { | ||
super(axios) | ||
this.booking = booking | ||
this.id = passenger | ||
} | ||
|
||
public async getApis(): Promise<PassengerAPIS> { | ||
return (await this.axios.get(`${this.path}/Apis`)).data | ||
} | ||
|
||
|
||
public async contacts(): Promise<CustomerContact[]> { | ||
return (await this.axios.get(`${this.path}/Contacts`)) | ||
} | ||
|
||
/** | ||
* Update the passenger APIS details. | ||
* Merges the given APIs details with the existing ones. | ||
* Any properties in `updates` which are null or undefined will be unchanged. | ||
*/ | ||
public async updateApis(updates: Partial<PassengerAPIS>): Promise<void> { | ||
const existing = await this.getApis() | ||
const payload = { ...updates, ...existing } | ||
|
||
await this.axios.put(`${this.path}/apis`, payload) | ||
} | ||
|
||
/** | ||
* Get the path to the current passenger resource. | ||
*/ | ||
public get path(): string { | ||
return `/reservations/${this.booking}/passengers/${this.id}` | ||
} | ||
} | ||
|
||
|
||
export interface PassengerAPIS { | ||
DocumentType: string; | ||
DocumentNumber: string; | ||
Nationality: string; | ||
PlaceOfIssue: string; | ||
CountryOfResidence: string; | ||
IssueDate: string; | ||
ExpiryDate: string; | ||
DateOfBirth: string; | ||
PlaceOfBirth: string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters