Implement use of a custom fetch fn

This commit is contained in:
2026-05-02 10:09:18 +01:00
parent 50c2e5f427
commit ed2f8527d6
5 changed files with 16 additions and 12 deletions

View File

@@ -7,7 +7,7 @@ import { ValidationError } from '../lib/errors.js';
export class TrainsModule {
constructor(private client: BaseClient) { }
async getByHeadcode(headcode: string, date: string | Date = new Date, toc: string = ""): Promise<ApiResult<ApiTrainsTrainByHeadcode.TrainByHeadcodeResponse[]>> {
async getByHeadcode(headcode: string, date: string | Date = new Date, toc: string = "", customFetch?: typeof fetch): Promise<ApiResult<ApiTrainsTrainByHeadcode.TrainByHeadcodeResponse[]>> {
if (!IsValidHeadcode(headcode)) {
throw new ValidationError("headcode", "Invalid headcode format")
}
@@ -29,6 +29,8 @@ export class TrainsModule {
return this.client.request<ApiTrainsTrainByHeadcode.TrainByHeadcodeResponse[]>(path, {
method: 'GET',
});
}, customFetch);
}
async getByRid(rid: string, customFetch?: typeof fetch) {}
}