import * as OJP_Types from 'ojp-shared-types';

interface HTTPConfig {
    url: string;
    authToken: string | null;
}
type Language = 'de' | 'fr' | 'it' | 'en';
interface XML_Config {
    ojpVersion: '1.0' | '2.0';
    defaultNS: 'ojp' | 'siri' | null;
    mapNS: Record<string, string>;
}
interface RequestInfo {
    requestDateTime: Date | null;
    requestXML: string | null;
    responseDateTime: Date | null;
    responseXML: string | null;
    parseDateTime: Date | null;
}

type GeoPositionLike = OJP_Types.GeoPositionSchema | number[] | string;
declare class GeoPosition implements OJP_Types.GeoPositionSchema {
    longitude: number;
    latitude: number;
    properties: Record<string, any>;
    constructor(geoPositionArg: GeoPositionLike | number, optionalLatitude?: number | null);
    isValid(): boolean;
    distanceFrom(pointB: GeoPosition): number;
    asLatLngString(roundCoords?: boolean): string;
    asLngLat(): [number, number];
}

declare class PlaceRef implements OJP_Types.PlaceRefSchema {
    stopPointRef?: string;
    stopPlaceRef?: string;
    geoPosition?: OJP_Types.GeoPositionSchema;
    name: OJP_Types.InternationalTextSchema;
    private constructor();
    static initWithPlaceRefsOrCoords(placeRefOrCoords: string, nameS?: string | null): PlaceRef;
}
declare class Trip implements OJP_Types.TripSchema {
    id: string;
    duration: string;
    startTime: string;
    endTime: string;
    transfers: number;
    leg: OJP_Types.LegSchema[];
    cancelled?: boolean;
    delayed?: boolean;
    deviation?: boolean;
    infeasible?: boolean;
    unplanned?: boolean;
    private constructor();
    static initWithTripXML(rawXML: string): Trip;
}
interface NearbyPlace {
    distance: number;
    object: Place;
}
declare class Place implements OJP_Types.PlaceSchema {
    stopPoint?: OJP_Types.StopPointSchema;
    stopPlace?: OJP_Types.StopPlaceSchema;
    topographicPlace?: OJP_Types.TopographicPlaceSchema;
    pointOfInterest?: OJP_Types.PointOfInterestSchema;
    address?: OJP_Types.AddressSchema;
    name: OJP_Types.InternationalTextSchema;
    geoPosition: GeoPosition;
    mode: OJP_Types.ModeStructureSchema[];
    placeType: OJP_Types.PlaceTypeEnum | null;
    private constructor();
    static initWithXMLSchema(placeSchema: OJP_Types.PlaceSchema): Place;
    static initWithCoords(geoPositionArg: GeoPositionLike | number, optionalLatitude?: number | null): Place;
    static Empty(): Place;
    findClosestPlace(otherPlaces: Place[]): NearbyPlace | null;
    asStopPlaceRefOrCoords(): string;
}
declare class PlaceResult implements OJP_Types.PlaceResultSchema {
    place: Place;
    complete: boolean;
    probability?: number;
    private constructor();
    static initWithXMLSchema(placeResultSchema: OJP_Types.PlaceResultSchema): PlaceResult;
    static initWithXML(nodeXML: string): PlaceResult;
}
declare class StopEventResult implements OJP_Types.StopEventResultSchema {
    id: string;
    stopEvent: OJP_Types.StopEventSchema;
    private constructor();
    static initWithXML(nodeXML: string): StopEventResult;
}

declare class BaseRequest {
    requestInfo: RequestInfo;
    mockRequestXML: string | null;
    mockResponseXML: string | null;
    enableExtensions: boolean;
    protected constructor();
}
declare class TripRequest extends BaseRequest implements OJP_Types.TripRequestSchema {
    requestTimestamp: string;
    origin: OJP_Types.PlaceContextSchema;
    destination: OJP_Types.PlaceContextSchema;
    via: OJP_Types.ViaPointSchema[];
    params?: OJP_Types.TripParamsSchema;
    private constructor();
    private static DefaultRequestParams;
    private static Default;
    static initWithRequestMock(mockText: string): TripRequest;
    static initWithResponseMock(mockText: string): TripRequest;
    static initWithPlaceRefsOrCoords(originPlaceRefS: string, destinationPlaceRefS: string): TripRequest;
    static initWithPlaces(origin: Place, destination: Place): TripRequest;
    setArrivalDatetime(newDatetime?: Date): void;
    setDepartureDatetime(newDatetime?: Date): void;
    buildRequestXML(language: Language, requestorRef: string, xmlConfig?: XML_Config): string;
}
declare class LocationInformationRequest extends BaseRequest implements OJP_Types.LocationInformationRequestSchema {
    requestTimestamp: string;
    initialInput?: OJP_Types.InitialInputSchema;
    placeRef?: PlaceRef;
    restrictions?: OJP_Types.LIR_RequestParamsSchema;
    private constructor();
    private static DefaultRequestParams;
    private static Default;
    static initWithRequestMock(mockText: string): LocationInformationRequest;
    static initWithResponseMock(mockText: string): LocationInformationRequest;
    static initWithLocationName(name: string): LocationInformationRequest;
    static initWithPlaceRef(placeRefOrCoords: string): LocationInformationRequest;
    static initWithBBOX(bboxData: string | number[], placeType: OJP_Types.PlaceTypeEnum[], numberOfResults?: number): LocationInformationRequest;
    buildRequestXML(language: Language, requestorRef: string, xmlConfig: XML_Config): string;
}
declare class StopEventRequest extends BaseRequest implements OJP_Types.StopEventRequestSchema {
    requestTimestamp: string;
    location: OJP_Types.SER_RequestLocationSchema;
    params?: OJP_Types.SER_RequestParamsSchema;
    private constructor();
    private static DefaultRequestParams;
    private static Default;
    static initWithRequestMock(mockText: string): StopEventRequest;
    static initWithResponseMock(mockText: string): StopEventRequest;
    static initWithPlaceRefAndDate(placeRefS: string, date?: Date): StopEventRequest;
    buildRequestXML(language: Language, requestorRef: string, xmlConfig: XML_Config): string;
}
declare class TripRefineRequest extends BaseRequest implements OJP_Types.TRR_RequestSchema {
    requestTimestamp: string;
    refineParams?: OJP_Types.TRR_RequestParamsSchema;
    tripResult: OJP_Types.TripResultSchema;
    private constructor();
    private static DefaultRequestParams;
    private static Default;
    static initWithRequestMock(mockText: string): TripRefineRequest;
    static initWithResponseMock(mockText: string): TripRefineRequest;
    static initWithTrip(trip: Trip): TripRefineRequest;
    buildRequestXML(language: Language, requestorRef: string, xmlConfig: XML_Config): string;
}
declare class FareRequest extends BaseRequest implements OJP_Types.FareRequestsSchema {
    requestTimestamp: string;
    itemsWrapper: OJP_Types.FareRequestSchema[];
    private constructor();
    private static DefaultRequestParams;
    private static Default;
    static initWithRequestMock(mockText: string): FareRequest;
    static initWithResponseMock(mockText: string): FareRequest;
    private static initWithOJPv1Trips;
    static initWithOJPv2Trips(trips: OJP_Types.TripSchema[]): FareRequest;
    buildRequestXML(language: Language, requestorRef: string, xmlConfig?: XML_Config): string;
}
declare class TripInfoRequest extends BaseRequest implements OJP_Types.TIR_RequestSchema {
    requestTimestamp: string;
    journeyRef: string;
    operatingDayRef: string;
    params?: OJP_Types.TIR_RequestParamsSchema;
    private constructor();
    private static DefaultRequestParams;
    private static Default;
    static initWithRequestMock(mockText: string): TripInfoRequest;
    static initWithResponseMock(mockText: string): TripInfoRequest;
    static initWithJourneyRef(journeyRef: string, journeyDate?: Date): TripInfoRequest;
    buildRequestXML(language: Language, requestorRef: string, xmlConfig: XML_Config): string;
    enableTrackProjection(): void;
    private patchV1;
}

declare class XmlSerializer {
    xmlConfig: XML_Config;
    constructor(xmlConfig?: XML_Config);
    serialize(obj: Record<string, any>, wrapperNodeName: string): string;
}

declare const SDK_VERSION = "0.20.21";

declare class DateHelpers {
    static formatDate(d: Date): string;
    static formatTimeHHMM(d?: Date): string;
    static computeDelayMinutes(timetableTimeS: Date | string, estimatedTimeS: Date | string | null): number | null;
}

type ResponseOk<T> = {
    ok: true;
    value: T;
};
type ResponseError<E> = {
    ok: false;
    error: E;
};
type OJP_Response<T, E> = ResponseOk<T> | ResponseError<E>;
declare class SDK {
    private requestorRef;
    private httpConfig;
    private language;
    private xmlConfig;
    constructor(requestorRef: string, httpConfig: HTTPConfig, language: Language, xmlConfig?: XML_Config);
    private computeResponse;
    private fetchResponse;
    fetchTripRequestResponse(request: TripRequest): Promise<OJP_Response<OJP_Types.TripDeliverySchema, Error>>;
    fetchLocationInformationRequestResponse(request: LocationInformationRequest): Promise<OJP_Response<OJP_Types.LocationInformationDeliverySchema, Error>>;
    fetchStopEventRequestResponse(request: StopEventRequest): Promise<OJP_Response<OJP_Types.StopEventDeliverySchema, Error>>;
    fetchTripRefineRequestResponse(request: TripRefineRequest): Promise<OJP_Response<OJP_Types.TRR_DeliverySchema, Error>>;
    fetchTripInfoRequestResponse(request: TripInfoRequest): Promise<OJP_Response<OJP_Types.TripInfoDeliverySchema | OJP_Types.OJPv1_TripInfoDeliverySchema, Error>>;
    fetchFareRequestResponse(request: FareRequest): Promise<OJP_Response<OJP_Types.FareDeliverySchema, Error>>;
    fetchTrips(tripRequest: TripRequest): Promise<Trip[]>;
    fetchPlaceResults(lirRequest: LocationInformationRequest): Promise<PlaceResult[]>;
    fetchStopEvents(request: StopEventRequest): Promise<StopEventResult[]>;
    fetchTRR_Trips(request: TripRefineRequest): Promise<Trip[]>;
}

export { DateHelpers, FareRequest, GeoPosition, type HTTPConfig, type Language, LocationInformationRequest, Place, PlaceResult, type RequestInfo, SDK, SDK_VERSION, StopEventRequest, StopEventResult, Trip, TripInfoRequest, TripRefineRequest, TripRequest, XmlSerializer };
