Skip to content

Commit

Permalink
Add passenger note APIs
Browse files Browse the repository at this point in the history
  • Loading branch information
LeoAdamek committed Sep 5, 2024
1 parent 770cb9e commit 25a30e8
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 10 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "tigerbay",
"version": "1.1.0-beta.5",
"version": "1.1.0-beta.6",
"description": "API Client library for TigerBay",
"main": "lib/client.js",
"type": "commonjs",
Expand Down
28 changes: 19 additions & 9 deletions src/models/passengers.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { AxiosInstance } from "axios";
import { APIGroup, PatchPayload } from "./common";
import { CustomerContact } from "./customers";
import { Note } from "./notes";
import { AddNoteRequest } from "./reservations";

export class PassengerAPI extends APIGroup {
private booking: number;
Expand All @@ -15,6 +17,13 @@ export class PassengerAPI extends APIGroup {
public async getApis(): Promise<PassengerAPIS> {
return (await this.axios.get(`${this.path}/Apis`)).data
}

/**
* Update the passenger APIS details.
*/
public async updateApis(updates: PassengerAPIS): Promise<void> {
await this.axios.put(`${this.path}/apis`, updates)
}

/**
* List customer contacts
Expand Down Expand Up @@ -67,16 +76,17 @@ export class PassengerAPI extends APIGroup {
return (await this.axios.delete(`${this.path}/insurances/${id}`))
}

/**
* Update the passenger APIS details.
* Merges the given APIs details with the existing ones.
* Any properties in `updates` which are undefined will be unchanged.
*/
public async updateApis(updates: Partial<PassengerAPIS>): Promise<void> {
const existing = await this.getApis()
const payload = { ...existing, ...updates }

await this.axios.put(`${this.path}/apis`, payload)
public async notes(): Promise<Note[]> {
return (await this.axios.get(`${this.path}/notes`)).data
}

public async addNote(note: AddNoteRequest): Promise<Note> {
return (await this.axios.post(`${this.path}/notes`, note)).data
}

public async deleteNote(id: number): Promise<void> {
return (await this.axios.delete(`${this.path}/notes/${id}`))
}

/**
Expand Down

0 comments on commit 25a30e8

Please sign in to comment.