Implement PIS, User and Reference API classes
This commit is contained in:
parent
c54e517700
commit
196cc8783b
@ -1,9 +0,0 @@
|
|||||||
import { BaseOwlBoardClient } from "./client";
|
|
||||||
|
|
||||||
export class LocationReferenceClientV2 {
|
|
||||||
private client: BaseOwlBoardClient;
|
|
||||||
|
|
||||||
constructor(client: BaseOwlBoardClient) {
|
|
||||||
this.client = client;
|
|
||||||
}
|
|
||||||
}
|
|
23
src/clients/ReferenceClientV2.ts
Normal file
23
src/clients/ReferenceClientV2.ts
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
import { validateReasonCode } from "../inputValidation/inputValidation";
|
||||||
|
import { ReferenceV2_LocationReferenceCodes, ReferenceV2_LocationReferenceCodeType, ReferenceV2_ReasonCode } from "../types/reference/ReferenceTypesV2";
|
||||||
|
import { BaseOwlBoardClient } from "./client";
|
||||||
|
|
||||||
|
export class ReferenceClientV2 {
|
||||||
|
private client: BaseOwlBoardClient;
|
||||||
|
|
||||||
|
constructor(client: BaseOwlBoardClient) {
|
||||||
|
this.client = client;
|
||||||
|
}
|
||||||
|
|
||||||
|
async defineReasonCode(reasonCode: number): Promise<ReferenceV2_ReasonCode> {
|
||||||
|
validateReasonCode(reasonCode);
|
||||||
|
const path = `/api/v2/ref/reasonCode/${reasonCode}`
|
||||||
|
return this.client.makeRequest("GET", path);
|
||||||
|
}
|
||||||
|
|
||||||
|
async lookupLocationReference(type: ReferenceV2_LocationReferenceCodeType, referenceCode: string): Promise<ReferenceV2_LocationReferenceCodes> {
|
||||||
|
// Validation Required Here
|
||||||
|
const path = `/api/v2/ref/locationCode/${type}/${referenceCode}`
|
||||||
|
return this.client.makeRequest("GET", path);
|
||||||
|
}
|
||||||
|
}
|
@ -1,3 +1,5 @@
|
|||||||
|
import { validateUuid } from "../inputValidation/inputValidation";
|
||||||
|
import { UserV2_RegistrationResponse } from "../types/user/UserTypesV2";
|
||||||
import { BaseOwlBoardClient } from "./client";
|
import { BaseOwlBoardClient } from "./client";
|
||||||
|
|
||||||
export class UserClientV2 {
|
export class UserClientV2 {
|
||||||
@ -6,4 +8,15 @@ export class UserClientV2 {
|
|||||||
constructor(client: BaseOwlBoardClient) {
|
constructor(client: BaseOwlBoardClient) {
|
||||||
this.client = client;
|
this.client = client;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async getUser(uuid: string): Promise<UserV2_RegistrationResponse> {
|
||||||
|
validateUuid(uuid);
|
||||||
|
const path = `/api/v2/user/${uuid}`;
|
||||||
|
return this.client.makeRequest("GET", path);
|
||||||
|
}
|
||||||
|
|
||||||
|
async checkAuth(): Promise<any> {
|
||||||
|
const path = '/api/v2/checkAuth'
|
||||||
|
return this.client.makeRequest("GET", path);
|
||||||
|
}
|
||||||
}
|
}
|
@ -1,6 +1,6 @@
|
|||||||
import { version } from "../constants";
|
import { version } from "../constants";
|
||||||
import { LdbClientV2 } from "./LdbClientV2";
|
import { LdbClientV2 } from "./LdbClientV2";
|
||||||
import { LocationReferenceClientV2 } from "./LocationReferenceClientV2";
|
import { ReferenceClientV2 } from "./ReferenceClientV2";
|
||||||
import { MiscClientV2 } from "./MiscClientV2";
|
import { MiscClientV2 } from "./MiscClientV2";
|
||||||
import { PisClientV2 } from "./PisClientV2";
|
import { PisClientV2 } from "./PisClientV2";
|
||||||
import { TrainClientV2 } from "./TrainClientV2";
|
import { TrainClientV2 } from "./TrainClientV2";
|
||||||
@ -80,7 +80,7 @@ export class OwlBoardClientV2 extends BaseOwlBoardClient {
|
|||||||
pis: PisClientV2;
|
pis: PisClientV2;
|
||||||
train: TrainClientV2;
|
train: TrainClientV2;
|
||||||
user: UserClientV2;
|
user: UserClientV2;
|
||||||
locationReference: LocationReferenceClientV2;
|
reference: ReferenceClientV2;
|
||||||
misc: MiscClientV2;
|
misc: MiscClientV2;
|
||||||
ldb: LdbClientV2;
|
ldb: LdbClientV2;
|
||||||
|
|
||||||
@ -89,7 +89,7 @@ export class OwlBoardClientV2 extends BaseOwlBoardClient {
|
|||||||
this.pis = new PisClientV2(this);
|
this.pis = new PisClientV2(this);
|
||||||
this.train = new TrainClientV2(this);
|
this.train = new TrainClientV2(this);
|
||||||
this.user = new UserClientV2(this);
|
this.user = new UserClientV2(this);
|
||||||
this.locationReference = new LocationReferenceClientV2(this);
|
this.reference = new ReferenceClientV2(this);
|
||||||
this.misc = new MiscClientV2(this);
|
this.misc = new MiscClientV2(this);
|
||||||
this.ldb = new LdbClientV2(this);
|
this.ldb = new LdbClientV2(this);
|
||||||
}
|
}
|
||||||
|
22
src/types/reference/ReferenceTypesV2.ts
Normal file
22
src/types/reference/ReferenceTypesV2.ts
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
// Location Reference codes are returned as an array containing one object
|
||||||
|
interface ReferenceV2_LocationReferenceCodesObject {
|
||||||
|
"3ALPHA": string;
|
||||||
|
NLC: number;
|
||||||
|
NLCDESC: string;
|
||||||
|
STANOX: string;
|
||||||
|
TIPLOC: string;
|
||||||
|
UIC: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type ReferenceV2_LocationReferenceCodes = ReferenceV2_LocationReferenceCodesObject[];
|
||||||
|
|
||||||
|
// Reason codes are returned as an array containing one object
|
||||||
|
interface ReferenceV2_ReasonCodeObject {
|
||||||
|
code: string;
|
||||||
|
lateReason: string;
|
||||||
|
cancReason: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export type ReferenceV2_ReasonCode = ReferenceV2_ReasonCodeObject[]
|
||||||
|
|
||||||
|
export type ReferenceV2_LocationReferenceCodeType = "tiploc" | "crs" | "stanox" | "nlc"
|
5
src/types/user/UserTypesV2.ts
Normal file
5
src/types/user/UserTypesV2.ts
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
export interface UserV2_RegistrationResponse {
|
||||||
|
status: number;
|
||||||
|
message: string;
|
||||||
|
api_key: string;
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user