import { BaseOwlBoardClient } from "./client";
import { ValidationError } from "../errors";

export class PisClientV2 {
    private client: BaseOwlBoardClient;

    constructor(client: BaseOwlBoardClient) {
        this.client = client;
    }

    async getStopsByPis(code: string): Promise<any> {
        const codeRegex = /^\d{4}$/;
        if (!codeRegex.test(code)) {
            throw new ValidationError("Invalid input: code must be a four-character string consisting of only numerals")
        }
        const path = `/api/v2/pis/byCode/${code}`
        return this.client.makeRequest("GET", path);
    }
}