From 4859ae6201e63dcf1a8b393fbbfe50b8c3c45b89 Mon Sep 17 00:00:00 2001 From: MachineUserPTV Date: Thu, 28 Nov 2024 08:46:10 +0000 Subject: [PATCH] Automatic synchronisation from developer.myptv.com --- typescript/apis/PositionsApi.ts | 53 +-- typescript/apis/TracksApi.ts | 74 ++-- typescript/index.ts | 4 +- typescript/models/CalculationMode.ts | 25 +- typescript/models/CausingError.ts | 50 ++- typescript/models/EmissionStandard.ts | 47 ++- typescript/models/ErrorResponse.ts | 47 +-- .../models/LowEmissionZoneDescriptors.ts | 42 +-- typescript/models/MatchType.ts | 25 +- typescript/models/MatchedPath.ts | 51 ++- typescript/models/MatchedPosition.ts | 106 +++--- typescript/models/MatchedTrack.ts | 42 ++- typescript/models/MatchedTrackIdentifier.ts | 23 +- typescript/models/MatchedTrackPosition.ts | 77 +++-- typescript/models/MatchedTrackResultType.ts | 29 +- typescript/models/MatchingResponse.ts | 72 ++-- typescript/models/MatchingStatus.ts | 25 +- typescript/models/PositionsResultType.ts | 29 +- typescript/models/SegmentAttributes.ts | 92 ++--- .../models/SegmentLocationDescriptors.ts | 44 +-- typescript/models/Toll.ts | 24 +- typescript/models/Track.ts | 25 +- typescript/models/TrackPosition.ts | 46 ++- typescript/models/Vehicle.ts | 45 +-- typescript/models/Warning.ts | 34 +- typescript/runtime.ts | 316 ++++++++++++------ 26 files changed, 886 insertions(+), 561 deletions(-) diff --git a/typescript/apis/PositionsApi.ts b/typescript/apis/PositionsApi.ts index f1aa404..d27704e 100644 --- a/typescript/apis/PositionsApi.ts +++ b/typescript/apis/PositionsApi.ts @@ -4,7 +4,7 @@ * Map Matching * With the Map Matching service you can assign GPS positions to road segments on a digital map. * - * The version of the OpenAPI document: 1.6 + * The version of the OpenAPI document: 1.7 * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). @@ -14,20 +14,22 @@ import * as runtime from '../runtime'; +import type { + CalculationMode, + ErrorResponse, + MatchedPosition, + PositionsResultType, +} from '../models/index'; import { - CalculationMode, CalculationModeFromJSON, CalculationModeToJSON, - ErrorResponse, ErrorResponseFromJSON, ErrorResponseToJSON, - MatchedPosition, MatchedPositionFromJSON, MatchedPositionToJSON, - PositionsResultType, PositionsResultTypeFromJSON, PositionsResultTypeToJSON, -} from '../models'; +} from '../models/index'; export interface MatchPositionRequest { latitude: number; @@ -46,42 +48,47 @@ export class PositionsApi extends runtime.BaseAPI { /** * Matches a single unrelated position on a map. */ - async matchPositionRaw(requestParameters: MatchPositionRequest, initOverrides?: RequestInit): Promise> { - if (requestParameters.latitude === null || requestParameters.latitude === undefined) { - throw new runtime.RequiredError('latitude','Required parameter requestParameters.latitude was null or undefined when calling matchPosition.'); + async matchPositionRaw(requestParameters: MatchPositionRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + if (requestParameters['latitude'] == null) { + throw new runtime.RequiredError( + 'latitude', + 'Required parameter "latitude" was null or undefined when calling matchPosition().' + ); } - if (requestParameters.longitude === null || requestParameters.longitude === undefined) { - throw new runtime.RequiredError('longitude','Required parameter requestParameters.longitude was null or undefined when calling matchPosition.'); + if (requestParameters['longitude'] == null) { + throw new runtime.RequiredError( + 'longitude', + 'Required parameter "longitude" was null or undefined when calling matchPosition().' + ); } const queryParameters: any = {}; - if (requestParameters.heading !== undefined) { - queryParameters['heading'] = requestParameters.heading; + if (requestParameters['heading'] != null) { + queryParameters['heading'] = requestParameters['heading']; } - if (requestParameters.calculationMode !== undefined) { - queryParameters['calculationMode'] = requestParameters.calculationMode; + if (requestParameters['calculationMode'] != null) { + queryParameters['calculationMode'] = requestParameters['calculationMode']; } - if (requestParameters.results) { - queryParameters['results'] = requestParameters.results.join(runtime.COLLECTION_FORMATS["csv"]); + if (requestParameters['results'] != null) { + queryParameters['results'] = requestParameters['results']!.join(runtime.COLLECTION_FORMATS["csv"]); } - if (requestParameters.language !== undefined) { - queryParameters['language'] = requestParameters.language; + if (requestParameters['language'] != null) { + queryParameters['language'] = requestParameters['language']; } const headerParameters: runtime.HTTPHeaders = {}; - headerParameters['User-Agent'] = "ptv-generated typescript client"; if (this.configuration && this.configuration.apiKey) { - headerParameters["apiKey"] = this.configuration.apiKey("apiKey"); // apiKeyAuth authentication + headerParameters["apiKey"] = await this.configuration.apiKey("apiKey"); // apiKeyAuth authentication } const response = await this.request({ - path: `/positions/{latitude}/{longitude}`.replace(`{${"latitude"}}`, encodeURIComponent(String(requestParameters.latitude))).replace(`{${"longitude"}}`, encodeURIComponent(String(requestParameters.longitude))), + path: `/positions/{latitude}/{longitude}`.replace(`{${"latitude"}}`, encodeURIComponent(String(requestParameters['latitude']))).replace(`{${"longitude"}}`, encodeURIComponent(String(requestParameters['longitude']))), method: 'GET', headers: headerParameters, query: queryParameters, @@ -93,7 +100,7 @@ export class PositionsApi extends runtime.BaseAPI { /** * Matches a single unrelated position on a map. */ - async matchPosition(requestParameters: MatchPositionRequest, initOverrides?: RequestInit): Promise { + async matchPosition(requestParameters: MatchPositionRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { const response = await this.matchPositionRaw(requestParameters, initOverrides); return await response.value(); } diff --git a/typescript/apis/TracksApi.ts b/typescript/apis/TracksApi.ts index 72a408e..08b907d 100644 --- a/typescript/apis/TracksApi.ts +++ b/typescript/apis/TracksApi.ts @@ -4,7 +4,7 @@ * Map Matching * With the Map Matching service you can assign GPS positions to road segments on a digital map. * - * The version of the OpenAPI document: 1.6 + * The version of the OpenAPI document: 1.7 * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). @@ -14,26 +14,28 @@ import * as runtime from '../runtime'; +import type { + CalculationMode, + ErrorResponse, + MatchedTrackIdentifier, + MatchedTrackResultType, + MatchingResponse, + Track, +} from '../models/index'; import { - CalculationMode, CalculationModeFromJSON, CalculationModeToJSON, - ErrorResponse, ErrorResponseFromJSON, ErrorResponseToJSON, - MatchedTrackIdentifier, MatchedTrackIdentifierFromJSON, MatchedTrackIdentifierToJSON, - MatchedTrackResultType, MatchedTrackResultTypeFromJSON, MatchedTrackResultTypeToJSON, - MatchingResponse, MatchingResponseFromJSON, MatchingResponseToJSON, - Track, TrackFromJSON, TrackToJSON, -} from '../models'; +} from '../models/index'; export interface CreateMatchedTrackRequest { track: Track; @@ -57,24 +59,26 @@ export class TracksApi extends runtime.BaseAPI { /** * Creates a complete track by triggering a matching calculation for it. */ - async createMatchedTrackRaw(requestParameters: CreateMatchedTrackRequest, initOverrides?: RequestInit): Promise> { - if (requestParameters.track === null || requestParameters.track === undefined) { - throw new runtime.RequiredError('track','Required parameter requestParameters.track was null or undefined when calling createMatchedTrack.'); + async createMatchedTrackRaw(requestParameters: CreateMatchedTrackRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + if (requestParameters['track'] == null) { + throw new runtime.RequiredError( + 'track', + 'Required parameter "track" was null or undefined when calling createMatchedTrack().' + ); } const queryParameters: any = {}; - if (requestParameters.calculationMode !== undefined) { - queryParameters['calculationMode'] = requestParameters.calculationMode; + if (requestParameters['calculationMode'] != null) { + queryParameters['calculationMode'] = requestParameters['calculationMode']; } const headerParameters: runtime.HTTPHeaders = {}; - headerParameters['User-Agent'] = "ptv-generated typescript client"; headerParameters['Content-Type'] = 'application/json'; if (this.configuration && this.configuration.apiKey) { - headerParameters["apiKey"] = this.configuration.apiKey("apiKey"); // apiKeyAuth authentication + headerParameters["apiKey"] = await this.configuration.apiKey("apiKey"); // apiKeyAuth authentication } const response = await this.request({ @@ -82,7 +86,7 @@ export class TracksApi extends runtime.BaseAPI { method: 'POST', headers: headerParameters, query: queryParameters, - body: TrackToJSON(requestParameters.track), + body: TrackToJSON(requestParameters['track']), }, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => MatchedTrackIdentifierFromJSON(jsonValue)); @@ -91,7 +95,7 @@ export class TracksApi extends runtime.BaseAPI { /** * Creates a complete track by triggering a matching calculation for it. */ - async createMatchedTrack(requestParameters: CreateMatchedTrackRequest, initOverrides?: RequestInit): Promise { + async createMatchedTrack(requestParameters: CreateMatchedTrackRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { const response = await this.createMatchedTrackRaw(requestParameters, initOverrides); return await response.value(); } @@ -99,22 +103,24 @@ export class TracksApi extends runtime.BaseAPI { /** * Deletes a matched track specified by its ID. */ - async deleteMatchedTrackRaw(requestParameters: DeleteMatchedTrackRequest, initOverrides?: RequestInit): Promise> { - if (requestParameters.id === null || requestParameters.id === undefined) { - throw new runtime.RequiredError('id','Required parameter requestParameters.id was null or undefined when calling deleteMatchedTrack.'); + async deleteMatchedTrackRaw(requestParameters: DeleteMatchedTrackRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + if (requestParameters['id'] == null) { + throw new runtime.RequiredError( + 'id', + 'Required parameter "id" was null or undefined when calling deleteMatchedTrack().' + ); } const queryParameters: any = {}; const headerParameters: runtime.HTTPHeaders = {}; - headerParameters['User-Agent'] = "ptv-generated typescript client"; if (this.configuration && this.configuration.apiKey) { - headerParameters["apiKey"] = this.configuration.apiKey("apiKey"); // apiKeyAuth authentication + headerParameters["apiKey"] = await this.configuration.apiKey("apiKey"); // apiKeyAuth authentication } const response = await this.request({ - path: `/tracks/{id}`.replace(`{${"id"}}`, encodeURIComponent(String(requestParameters.id))), + path: `/tracks/{id}`.replace(`{${"id"}}`, encodeURIComponent(String(requestParameters['id']))), method: 'DELETE', headers: headerParameters, query: queryParameters, @@ -126,33 +132,35 @@ export class TracksApi extends runtime.BaseAPI { /** * Deletes a matched track specified by its ID. */ - async deleteMatchedTrack(requestParameters: DeleteMatchedTrackRequest, initOverrides?: RequestInit): Promise { + async deleteMatchedTrack(requestParameters: DeleteMatchedTrackRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { await this.deleteMatchedTrackRaw(requestParameters, initOverrides); } /** * Gets the results of a matching calculation specified by its ID. */ - async getMatchedTrackRaw(requestParameters: GetMatchedTrackRequest, initOverrides?: RequestInit): Promise> { - if (requestParameters.id === null || requestParameters.id === undefined) { - throw new runtime.RequiredError('id','Required parameter requestParameters.id was null or undefined when calling getMatchedTrack.'); + async getMatchedTrackRaw(requestParameters: GetMatchedTrackRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + if (requestParameters['id'] == null) { + throw new runtime.RequiredError( + 'id', + 'Required parameter "id" was null or undefined when calling getMatchedTrack().' + ); } const queryParameters: any = {}; - if (requestParameters.results) { - queryParameters['results'] = requestParameters.results.join(runtime.COLLECTION_FORMATS["csv"]); + if (requestParameters['results'] != null) { + queryParameters['results'] = requestParameters['results']!.join(runtime.COLLECTION_FORMATS["csv"]); } const headerParameters: runtime.HTTPHeaders = {}; - headerParameters['User-Agent'] = "ptv-generated typescript client"; if (this.configuration && this.configuration.apiKey) { - headerParameters["apiKey"] = this.configuration.apiKey("apiKey"); // apiKeyAuth authentication + headerParameters["apiKey"] = await this.configuration.apiKey("apiKey"); // apiKeyAuth authentication } const response = await this.request({ - path: `/tracks/{id}`.replace(`{${"id"}}`, encodeURIComponent(String(requestParameters.id))), + path: `/tracks/{id}`.replace(`{${"id"}}`, encodeURIComponent(String(requestParameters['id']))), method: 'GET', headers: headerParameters, query: queryParameters, @@ -164,7 +172,7 @@ export class TracksApi extends runtime.BaseAPI { /** * Gets the results of a matching calculation specified by its ID. */ - async getMatchedTrack(requestParameters: GetMatchedTrackRequest, initOverrides?: RequestInit): Promise { + async getMatchedTrack(requestParameters: GetMatchedTrackRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { const response = await this.getMatchedTrackRaw(requestParameters, initOverrides); return await response.value(); } diff --git a/typescript/index.ts b/typescript/index.ts index be9d1ed..bebe8bb 100644 --- a/typescript/index.ts +++ b/typescript/index.ts @@ -1,5 +1,5 @@ /* tslint:disable */ /* eslint-disable */ export * from './runtime'; -export * from './apis'; -export * from './models'; +export * from './apis/index'; +export * from './models/index'; diff --git a/typescript/models/CalculationMode.ts b/typescript/models/CalculationMode.ts index f46eb7a..5629636 100644 --- a/typescript/models/CalculationMode.ts +++ b/typescript/models/CalculationMode.ts @@ -4,7 +4,7 @@ * Map Matching * With the Map Matching service you can assign GPS positions to road segments on a digital map. * - * The version of the OpenAPI document: 1.6 + * The version of the OpenAPI document: 1.7 * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). @@ -12,18 +12,31 @@ * Do not edit the class manually. */ + /** * Enumeration to define the calculation behavior of the matching, i.e. if the focus of calculation is on performance, quality or both. * * `PERFORMANCE` - The matching focuses on performance. This means to take into account a higher number of failed matches and in the case of track matching that the matched track may be split into several paths. * * `STANDARD` - The matching chooses a standard trade-off between quality and performance. * * `QUALITY` - The matching focuses on high solution quality. This means that as many as possible of the input positions are matched and taken into account. Though the processing time of the request can be high. * @export - * @enum {string} */ -export enum CalculationMode { - PERFORMANCE = 'PERFORMANCE', - STANDARD = 'STANDARD', - QUALITY = 'QUALITY' +export const CalculationMode = { + PERFORMANCE: 'PERFORMANCE', + STANDARD: 'STANDARD', + QUALITY: 'QUALITY' +} as const; +export type CalculationMode = typeof CalculationMode[keyof typeof CalculationMode]; + + +export function instanceOfCalculationMode(value: any): boolean { + for (const key in CalculationMode) { + if (Object.prototype.hasOwnProperty.call(CalculationMode, key)) { + if (CalculationMode[key as keyof typeof CalculationMode] === value) { + return true; + } + } + } + return false; } export function CalculationModeFromJSON(json: any): CalculationMode { diff --git a/typescript/models/CausingError.ts b/typescript/models/CausingError.ts index 7c45f18..5661bf1 100644 --- a/typescript/models/CausingError.ts +++ b/typescript/models/CausingError.ts @@ -4,7 +4,7 @@ * Map Matching * With the Map Matching service you can assign GPS positions to road segments on a digital map. * - * The version of the OpenAPI document: 1.6 + * The version of the OpenAPI document: 1.7 * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). @@ -12,7 +12,7 @@ * Do not edit the class manually. */ -import { exists, mapValues } from '../runtime'; +import { mapValues } from '../runtime'; /** * * @export @@ -38,7 +38,17 @@ export interface CausingError { * * `GENERAL_MINIMUM_VALUE_VIOLATED` - The minimum value restriction is violated. * * `minimumValue` - The minimum value (integer or double). * * `GENERAL_MAXIMUM_VALUE_VIOLATED` - The maximum value restriction is violated. - * * `maximumValue` - The maximum value (integer or double). + * * `maximumValue` - The maximum value (integer or double). + * * `MAP_MATCH_QUOTA_EXCEEDED` - A product-specific restriction count is violated. + * * `maximumLength` - Maximum number of input positions. + * * `MAP_MATCH_TIMESTAMPS_ALL_OR_NONE_VIOLATED` - Either all or none of the timestamps must be set. + * * `numberOfDefinedTimestamps` - Total number of input positions with timestamp. + * * `numberOfUndefinedTimestamps` - Total number of input positions without timestamp. + * * `MAP_MATCH_TIMESTAMPS_ASCENDING_VIOLATED` - Timestamps are not ascending. + * * `numberOfNotAscendingTimestamps` - Total number of not ascending timestamps. + * * `indexOfFirstViolatedTimestamp` - Index of the first not ascending timestamp. + * * `timestamp` - Value of the first not ascending timestamp. + * * `previousTimestamp` - Value of the timestamp before the first not ascending one. * @type {string} * @memberof CausingError */ @@ -51,10 +61,19 @@ export interface CausingError { parameter?: string; /** * Additional properties specific to this error class. - * @type {{ [key: string]: object; }} + * @type {{ [key: string]: any; }} * @memberof CausingError */ - details?: { [key: string]: object; }; + details?: { [key: string]: any; }; +} + +/** + * Check if a given object implements the CausingError interface. + */ +export function instanceOfCausingError(value: object): value is CausingError { + if (!('description' in value) || value['description'] === undefined) return false; + if (!('errorCode' in value) || value['errorCode'] === undefined) return false; + return true; } export function CausingErrorFromJSON(json: any): CausingError { @@ -62,31 +81,28 @@ export function CausingErrorFromJSON(json: any): CausingError { } export function CausingErrorFromJSONTyped(json: any, ignoreDiscriminator: boolean): CausingError { - if ((json === undefined) || (json === null)) { + if (json == null) { return json; } return { 'description': json['description'], 'errorCode': json['errorCode'], - 'parameter': !exists(json, 'parameter') ? undefined : json['parameter'], - 'details': !exists(json, 'details') ? undefined : json['details'], + 'parameter': json['parameter'] == null ? undefined : json['parameter'], + 'details': json['details'] == null ? undefined : json['details'], }; } export function CausingErrorToJSON(value?: CausingError | null): any { - if (value === undefined) { - return undefined; - } - if (value === null) { - return null; + if (value == null) { + return value; } return { - 'description': value.description, - 'errorCode': value.errorCode, - 'parameter': value.parameter, - 'details': value.details, + 'description': value['description'], + 'errorCode': value['errorCode'], + 'parameter': value['parameter'], + 'details': value['details'], }; } diff --git a/typescript/models/EmissionStandard.ts b/typescript/models/EmissionStandard.ts index 27be1b9..703a359 100644 --- a/typescript/models/EmissionStandard.ts +++ b/typescript/models/EmissionStandard.ts @@ -4,7 +4,7 @@ * Map Matching * With the Map Matching service you can assign GPS positions to road segments on a digital map. * - * The version of the OpenAPI document: 1.6 + * The version of the OpenAPI document: 1.7 * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). @@ -12,26 +12,39 @@ * Do not edit the class manually. */ + /** * The emission standard of the vehicle valid in the European Union. * @export - * @enum {string} */ -export enum EmissionStandard { - NONE = 'NONE', - EURO_0 = 'EURO_0', - EURO_1 = 'EURO_1', - EURO_2 = 'EURO_2', - EURO_3 = 'EURO_3', - EURO_4 = 'EURO_4', - EURO_5 = 'EURO_5', - EURO_EEV = 'EURO_EEV', - EURO_6 = 'EURO_6', - EURO_6C = 'EURO_6C', - EURO_6D_TEMP = 'EURO_6D_TEMP', - EURO_6D = 'EURO_6D', - EURO_6E = 'EURO_6E', - EURO_7 = 'EURO_7' +export const EmissionStandard = { + NONE: 'NONE', + EURO_0: 'EURO_0', + EURO_1: 'EURO_1', + EURO_2: 'EURO_2', + EURO_3: 'EURO_3', + EURO_4: 'EURO_4', + EURO_5: 'EURO_5', + EURO_EEV: 'EURO_EEV', + EURO_6: 'EURO_6', + EURO_6C: 'EURO_6C', + EURO_6D_TEMP: 'EURO_6D_TEMP', + EURO_6D: 'EURO_6D', + EURO_6E: 'EURO_6E', + EURO_7: 'EURO_7' +} as const; +export type EmissionStandard = typeof EmissionStandard[keyof typeof EmissionStandard]; + + +export function instanceOfEmissionStandard(value: any): boolean { + for (const key in EmissionStandard) { + if (Object.prototype.hasOwnProperty.call(EmissionStandard, key)) { + if (EmissionStandard[key as keyof typeof EmissionStandard] === value) { + return true; + } + } + } + return false; } export function EmissionStandardFromJSON(json: any): EmissionStandard { diff --git a/typescript/models/ErrorResponse.ts b/typescript/models/ErrorResponse.ts index dfd5822..95c3af5 100644 --- a/typescript/models/ErrorResponse.ts +++ b/typescript/models/ErrorResponse.ts @@ -4,7 +4,7 @@ * Map Matching * With the Map Matching service you can assign GPS positions to road segments on a digital map. * - * The version of the OpenAPI document: 1.6 + * The version of the OpenAPI document: 1.7 * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). @@ -12,9 +12,9 @@ * Do not edit the class manually. */ -import { exists, mapValues } from '../runtime'; +import { mapValues } from '../runtime'; +import type { CausingError } from './CausingError'; import { - CausingError, CausingErrorFromJSON, CausingErrorFromJSONTyped, CausingErrorToJSON, @@ -88,10 +88,20 @@ export interface ErrorResponse { causes?: Array; /** * Additional properties specific to this error class. - * @type {{ [key: string]: object; }} + * @type {{ [key: string]: any; }} * @memberof ErrorResponse */ - details?: { [key: string]: object; }; + details?: { [key: string]: any; }; +} + +/** + * Check if a given object implements the ErrorResponse interface. + */ +export function instanceOfErrorResponse(value: object): value is ErrorResponse { + if (!('description' in value) || value['description'] === undefined) return false; + if (!('errorCode' in value) || value['errorCode'] === undefined) return false; + if (!('traceId' in value) || value['traceId'] === undefined) return false; + return true; } export function ErrorResponseFromJSON(json: any): ErrorResponse { @@ -99,7 +109,7 @@ export function ErrorResponseFromJSON(json: any): ErrorResponse { } export function ErrorResponseFromJSONTyped(json: any, ignoreDiscriminator: boolean): ErrorResponse { - if ((json === undefined) || (json === null)) { + if (json == null) { return json; } return { @@ -107,27 +117,24 @@ export function ErrorResponseFromJSONTyped(json: any, ignoreDiscriminator: boole 'description': json['description'], 'errorCode': json['errorCode'], 'traceId': json['traceId'], - 'errorId': !exists(json, 'errorId') ? undefined : json['errorId'], - 'causes': !exists(json, 'causes') ? undefined : ((json['causes'] as Array).map(CausingErrorFromJSON)), - 'details': !exists(json, 'details') ? undefined : json['details'], + 'errorId': json['errorId'] == null ? undefined : json['errorId'], + 'causes': json['causes'] == null ? undefined : ((json['causes'] as Array).map(CausingErrorFromJSON)), + 'details': json['details'] == null ? undefined : json['details'], }; } export function ErrorResponseToJSON(value?: ErrorResponse | null): any { - if (value === undefined) { - return undefined; - } - if (value === null) { - return null; + if (value == null) { + return value; } return { - 'description': value.description, - 'errorCode': value.errorCode, - 'traceId': value.traceId, - 'errorId': value.errorId, - 'causes': value.causes === undefined ? undefined : ((value.causes as Array).map(CausingErrorToJSON)), - 'details': value.details, + 'description': value['description'], + 'errorCode': value['errorCode'], + 'traceId': value['traceId'], + 'errorId': value['errorId'], + 'causes': value['causes'] == null ? undefined : ((value['causes'] as Array).map(CausingErrorToJSON)), + 'details': value['details'], }; } diff --git a/typescript/models/LowEmissionZoneDescriptors.ts b/typescript/models/LowEmissionZoneDescriptors.ts index f9b9bdf..5793aa6 100644 --- a/typescript/models/LowEmissionZoneDescriptors.ts +++ b/typescript/models/LowEmissionZoneDescriptors.ts @@ -4,7 +4,7 @@ * Map Matching * With the Map Matching service you can assign GPS positions to road segments on a digital map. * - * The version of the OpenAPI document: 1.6 + * The version of the OpenAPI document: 1.7 * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). @@ -12,9 +12,9 @@ * Do not edit the class manually. */ -import { exists, mapValues } from '../runtime'; +import { mapValues } from '../runtime'; +import type { Vehicle } from './Vehicle'; import { - Vehicle, VehicleFromJSON, VehicleFromJSONTyped, VehicleToJSON, @@ -64,38 +64,42 @@ export interface LowEmissionZoneDescriptors { vehicles?: Array; } +/** + * Check if a given object implements the LowEmissionZoneDescriptors interface. + */ +export function instanceOfLowEmissionZoneDescriptors(value: object): value is LowEmissionZoneDescriptors { + return true; +} + export function LowEmissionZoneDescriptorsFromJSON(json: any): LowEmissionZoneDescriptors { return LowEmissionZoneDescriptorsFromJSONTyped(json, false); } export function LowEmissionZoneDescriptorsFromJSONTyped(json: any, ignoreDiscriminator: boolean): LowEmissionZoneDescriptors { - if ((json === undefined) || (json === null)) { + if (json == null) { return json; } return { - 'name': !exists(json, 'name') ? undefined : json['name'], - 'approvals': !exists(json, 'approvals') ? undefined : json['approvals'], - 'vehicleCategories': !exists(json, 'vehicleCategories') ? undefined : json['vehicleCategories'], - 'fuelTypes': !exists(json, 'fuelTypes') ? undefined : json['fuelTypes'], - 'vehicles': !exists(json, 'vehicles') ? undefined : ((json['vehicles'] as Array).map(VehicleFromJSON)), + 'name': json['name'] == null ? undefined : json['name'], + 'approvals': json['approvals'] == null ? undefined : json['approvals'], + 'vehicleCategories': json['vehicleCategories'] == null ? undefined : json['vehicleCategories'], + 'fuelTypes': json['fuelTypes'] == null ? undefined : json['fuelTypes'], + 'vehicles': json['vehicles'] == null ? undefined : ((json['vehicles'] as Array).map(VehicleFromJSON)), }; } export function LowEmissionZoneDescriptorsToJSON(value?: LowEmissionZoneDescriptors | null): any { - if (value === undefined) { - return undefined; - } - if (value === null) { - return null; + if (value == null) { + return value; } return { - 'name': value.name, - 'approvals': value.approvals, - 'vehicleCategories': value.vehicleCategories, - 'fuelTypes': value.fuelTypes, - 'vehicles': value.vehicles === undefined ? undefined : ((value.vehicles as Array).map(VehicleToJSON)), + 'name': value['name'], + 'approvals': value['approvals'], + 'vehicleCategories': value['vehicleCategories'], + 'fuelTypes': value['fuelTypes'], + 'vehicles': value['vehicles'] == null ? undefined : ((value['vehicles'] as Array).map(VehicleToJSON)), }; } diff --git a/typescript/models/MatchType.ts b/typescript/models/MatchType.ts index 2be81c2..fc6a824 100644 --- a/typescript/models/MatchType.ts +++ b/typescript/models/MatchType.ts @@ -4,7 +4,7 @@ * Map Matching * With the Map Matching service you can assign GPS positions to road segments on a digital map. * - * The version of the OpenAPI document: 1.6 + * The version of the OpenAPI document: 1.7 * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). @@ -12,18 +12,31 @@ * Do not edit the class manually. */ + /** * Gives information on the result of this match, i.e. whether the position was matched successfully or whether the position is considered as part of the track or not. * * `MATCH_SUCCESSFUL` - The position was matched successfully. * * `MATCH_FAILED` - The position could not be matched. * * `NOT_CONSIDERED` - The position was not considered. * @export - * @enum {string} */ -export enum MatchType { - MATCH_SUCCESSFUL = 'MATCH_SUCCESSFUL', - MATCH_FAILED = 'MATCH_FAILED', - NOT_CONSIDERED = 'NOT_CONSIDERED' +export const MatchType = { + MATCH_SUCCESSFUL: 'MATCH_SUCCESSFUL', + MATCH_FAILED: 'MATCH_FAILED', + NOT_CONSIDERED: 'NOT_CONSIDERED' +} as const; +export type MatchType = typeof MatchType[keyof typeof MatchType]; + + +export function instanceOfMatchType(value: any): boolean { + for (const key in MatchType) { + if (Object.prototype.hasOwnProperty.call(MatchType, key)) { + if (MatchType[key as keyof typeof MatchType] === value) { + return true; + } + } + } + return false; } export function MatchTypeFromJSON(json: any): MatchType { diff --git a/typescript/models/MatchedPath.ts b/typescript/models/MatchedPath.ts index b83710a..10360dc 100644 --- a/typescript/models/MatchedPath.ts +++ b/typescript/models/MatchedPath.ts @@ -4,7 +4,7 @@ * Map Matching * With the Map Matching service you can assign GPS positions to road segments on a digital map. * - * The version of the OpenAPI document: 1.6 + * The version of the OpenAPI document: 1.7 * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). @@ -12,7 +12,7 @@ * Do not edit the class manually. */ -import { exists, mapValues } from '../runtime'; +import { mapValues } from '../runtime'; /** * Detailed information about a continuous part of a matched track. * @export @@ -25,12 +25,24 @@ export interface MatchedPath { * @memberof MatchedPath */ distance: number; + /** + * Start time of this path defined according to [RFC 3339](https://tools.ietf.org/html/rfc3339). + * @type {Date} + * @memberof MatchedPath + */ + startTime?: Date; /** * The index in the list of trackPositions of the start position of this path. It is available only if the list of trackPositions is requested by MatchedTrackResults.TRACK_POSITIONS. * @type {number} * @memberof MatchedPath */ startTrackPositionIndex?: number; + /** + * End time of this path defined according to [RFC 3339](https://tools.ietf.org/html/rfc3339). + * @type {Date} + * @memberof MatchedPath + */ + endTime?: Date; /** * The index in the list of trackPositions of the end position of this path. It is available only if the list of trackPositions is requested by MatchedTrackResults.TRACK_POSITIONS. * @type {number} @@ -45,36 +57,45 @@ export interface MatchedPath { routeId?: string; } +/** + * Check if a given object implements the MatchedPath interface. + */ +export function instanceOfMatchedPath(value: object): value is MatchedPath { + if (!('distance' in value) || value['distance'] === undefined) return false; + return true; +} + export function MatchedPathFromJSON(json: any): MatchedPath { return MatchedPathFromJSONTyped(json, false); } export function MatchedPathFromJSONTyped(json: any, ignoreDiscriminator: boolean): MatchedPath { - if ((json === undefined) || (json === null)) { + if (json == null) { return json; } return { 'distance': json['distance'], - 'startTrackPositionIndex': !exists(json, 'startTrackPositionIndex') ? undefined : json['startTrackPositionIndex'], - 'endTrackPositionIndex': !exists(json, 'endTrackPositionIndex') ? undefined : json['endTrackPositionIndex'], - 'routeId': !exists(json, 'routeId') ? undefined : json['routeId'], + 'startTime': json['startTime'] == null ? undefined : (new Date(json['startTime'])), + 'startTrackPositionIndex': json['startTrackPositionIndex'] == null ? undefined : json['startTrackPositionIndex'], + 'endTime': json['endTime'] == null ? undefined : (new Date(json['endTime'])), + 'endTrackPositionIndex': json['endTrackPositionIndex'] == null ? undefined : json['endTrackPositionIndex'], + 'routeId': json['routeId'] == null ? undefined : json['routeId'], }; } export function MatchedPathToJSON(value?: MatchedPath | null): any { - if (value === undefined) { - return undefined; - } - if (value === null) { - return null; + if (value == null) { + return value; } return { - 'distance': value.distance, - 'startTrackPositionIndex': value.startTrackPositionIndex, - 'endTrackPositionIndex': value.endTrackPositionIndex, - 'routeId': value.routeId, + 'distance': value['distance'], + 'startTime': value['startTime'] == null ? undefined : ((value['startTime']).toISOString()), + 'startTrackPositionIndex': value['startTrackPositionIndex'], + 'endTime': value['endTime'] == null ? undefined : ((value['endTime']).toISOString()), + 'endTrackPositionIndex': value['endTrackPositionIndex'], + 'routeId': value['routeId'], }; } diff --git a/typescript/models/MatchedPosition.ts b/typescript/models/MatchedPosition.ts index 6084e75..4d3d3f3 100644 --- a/typescript/models/MatchedPosition.ts +++ b/typescript/models/MatchedPosition.ts @@ -4,7 +4,7 @@ * Map Matching * With the Map Matching service you can assign GPS positions to road segments on a digital map. * - * The version of the OpenAPI document: 1.6 + * The version of the OpenAPI document: 1.7 * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). @@ -12,37 +12,37 @@ * Do not edit the class manually. */ -import { exists, mapValues } from '../runtime'; +import { mapValues } from '../runtime'; +import type { Warning } from './Warning'; import { - LowEmissionZoneDescriptors, - LowEmissionZoneDescriptorsFromJSON, - LowEmissionZoneDescriptorsFromJSONTyped, - LowEmissionZoneDescriptorsToJSON, -} from './LowEmissionZoneDescriptors'; -import { - SegmentAttributes, - SegmentAttributesFromJSON, - SegmentAttributesFromJSONTyped, - SegmentAttributesToJSON, -} from './SegmentAttributes'; + WarningFromJSON, + WarningFromJSONTyped, + WarningToJSON, +} from './Warning'; +import type { SegmentLocationDescriptors } from './SegmentLocationDescriptors'; import { - SegmentLocationDescriptors, SegmentLocationDescriptorsFromJSON, SegmentLocationDescriptorsFromJSONTyped, SegmentLocationDescriptorsToJSON, } from './SegmentLocationDescriptors'; +import type { SegmentAttributes } from './SegmentAttributes'; +import { + SegmentAttributesFromJSON, + SegmentAttributesFromJSONTyped, + SegmentAttributesToJSON, +} from './SegmentAttributes'; +import type { Toll } from './Toll'; import { - Toll, TollFromJSON, TollFromJSONTyped, TollToJSON, } from './Toll'; +import type { LowEmissionZoneDescriptors } from './LowEmissionZoneDescriptors'; import { - Warning, - WarningFromJSON, - WarningFromJSONTyped, - WarningToJSON, -} from './Warning'; + LowEmissionZoneDescriptorsFromJSON, + LowEmissionZoneDescriptorsFromJSONTyped, + LowEmissionZoneDescriptorsToJSON, +} from './LowEmissionZoneDescriptors'; /** * Represents the successful match of a position on the map including the matched segment and the deviation to the input position. For unsuccessful matches an empty object is returned. @@ -55,31 +55,31 @@ export interface MatchedPosition { * @type {number} * @memberof MatchedPosition */ - latitude?: number | null; + latitude?: number; /** * The longitude value in degrees (WGS84/EPSG:4326) from west to east. This refers to the coordinates on the segment to which the input position matches. * @type {number} * @memberof MatchedPosition */ - longitude?: number | null; + longitude?: number; /** * The geometry of the matched segment as a GeoJSON representation. Coordinates are always present in WGS84 (EPSG:4326). * @type {string} * @memberof MatchedPosition */ - segmentGeometry?: string | null; + segmentGeometry?: string; /** * The straight-line distance (Euclidean distance) [m] from the input position to the matching segment. * @type {number} * @memberof MatchedPosition */ - matchDistance?: number | null; + matchDistance?: number; /** * The difference in degrees \[°\] between the angle of the travel direction and the angle of the matching segment. This value is always smaller than the straight angle. * @type {number} * @memberof MatchedPosition */ - angleDifference?: number | null; + angleDifference?: number; /** * * @type {SegmentLocationDescriptors} @@ -112,48 +112,52 @@ export interface MatchedPosition { warnings?: Array; } +/** + * Check if a given object implements the MatchedPosition interface. + */ +export function instanceOfMatchedPosition(value: object): value is MatchedPosition { + return true; +} + export function MatchedPositionFromJSON(json: any): MatchedPosition { return MatchedPositionFromJSONTyped(json, false); } export function MatchedPositionFromJSONTyped(json: any, ignoreDiscriminator: boolean): MatchedPosition { - if ((json === undefined) || (json === null)) { + if (json == null) { return json; } return { - 'latitude': !exists(json, 'latitude') ? undefined : json['latitude'], - 'longitude': !exists(json, 'longitude') ? undefined : json['longitude'], - 'segmentGeometry': !exists(json, 'segmentGeometry') ? undefined : json['segmentGeometry'], - 'matchDistance': !exists(json, 'matchDistance') ? undefined : json['matchDistance'], - 'angleDifference': !exists(json, 'angleDifference') ? undefined : json['angleDifference'], - 'segmentLocationDescriptors': !exists(json, 'segmentLocationDescriptors') ? undefined : SegmentLocationDescriptorsFromJSON(json['segmentLocationDescriptors']), - 'segmentAttributes': !exists(json, 'segmentAttributes') ? undefined : SegmentAttributesFromJSON(json['segmentAttributes']), - 'lowEmissionZones': !exists(json, 'lowEmissionZones') ? undefined : ((json['lowEmissionZones'] as Array).map(LowEmissionZoneDescriptorsFromJSON)), - 'toll': !exists(json, 'toll') ? undefined : TollFromJSON(json['toll']), - 'warnings': !exists(json, 'warnings') ? undefined : ((json['warnings'] as Array).map(WarningFromJSON)), + 'latitude': json['latitude'] == null ? undefined : json['latitude'], + 'longitude': json['longitude'] == null ? undefined : json['longitude'], + 'segmentGeometry': json['segmentGeometry'] == null ? undefined : json['segmentGeometry'], + 'matchDistance': json['matchDistance'] == null ? undefined : json['matchDistance'], + 'angleDifference': json['angleDifference'] == null ? undefined : json['angleDifference'], + 'segmentLocationDescriptors': json['segmentLocationDescriptors'] == null ? undefined : SegmentLocationDescriptorsFromJSON(json['segmentLocationDescriptors']), + 'segmentAttributes': json['segmentAttributes'] == null ? undefined : SegmentAttributesFromJSON(json['segmentAttributes']), + 'lowEmissionZones': json['lowEmissionZones'] == null ? undefined : ((json['lowEmissionZones'] as Array).map(LowEmissionZoneDescriptorsFromJSON)), + 'toll': json['toll'] == null ? undefined : TollFromJSON(json['toll']), + 'warnings': json['warnings'] == null ? undefined : ((json['warnings'] as Array).map(WarningFromJSON)), }; } export function MatchedPositionToJSON(value?: MatchedPosition | null): any { - if (value === undefined) { - return undefined; - } - if (value === null) { - return null; + if (value == null) { + return value; } return { - 'latitude': value.latitude, - 'longitude': value.longitude, - 'segmentGeometry': value.segmentGeometry, - 'matchDistance': value.matchDistance, - 'angleDifference': value.angleDifference, - 'segmentLocationDescriptors': SegmentLocationDescriptorsToJSON(value.segmentLocationDescriptors), - 'segmentAttributes': SegmentAttributesToJSON(value.segmentAttributes), - 'lowEmissionZones': value.lowEmissionZones === undefined ? undefined : ((value.lowEmissionZones as Array).map(LowEmissionZoneDescriptorsToJSON)), - 'toll': TollToJSON(value.toll), - 'warnings': value.warnings === undefined ? undefined : ((value.warnings as Array).map(WarningToJSON)), + 'latitude': value['latitude'], + 'longitude': value['longitude'], + 'segmentGeometry': value['segmentGeometry'], + 'matchDistance': value['matchDistance'], + 'angleDifference': value['angleDifference'], + 'segmentLocationDescriptors': SegmentLocationDescriptorsToJSON(value['segmentLocationDescriptors']), + 'segmentAttributes': SegmentAttributesToJSON(value['segmentAttributes']), + 'lowEmissionZones': value['lowEmissionZones'] == null ? undefined : ((value['lowEmissionZones'] as Array).map(LowEmissionZoneDescriptorsToJSON)), + 'toll': TollToJSON(value['toll']), + 'warnings': value['warnings'] == null ? undefined : ((value['warnings'] as Array).map(WarningToJSON)), }; } diff --git a/typescript/models/MatchedTrack.ts b/typescript/models/MatchedTrack.ts index 2b3bd0f..5cd9cf9 100644 --- a/typescript/models/MatchedTrack.ts +++ b/typescript/models/MatchedTrack.ts @@ -4,7 +4,7 @@ * Map Matching * With the Map Matching service you can assign GPS positions to road segments on a digital map. * - * The version of the OpenAPI document: 1.6 + * The version of the OpenAPI document: 1.7 * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). @@ -12,15 +12,15 @@ * Do not edit the class manually. */ -import { exists, mapValues } from '../runtime'; +import { mapValues } from '../runtime'; +import type { MatchedPath } from './MatchedPath'; import { - MatchedPath, MatchedPathFromJSON, MatchedPathFromJSONTyped, MatchedPathToJSON, } from './MatchedPath'; +import type { MatchedTrackPosition } from './MatchedTrackPosition'; import { - MatchedTrackPosition, MatchedTrackPositionFromJSON, MatchedTrackPositionFromJSONTyped, MatchedTrackPositionToJSON, @@ -64,38 +64,44 @@ export interface MatchedTrack { trackPositions?: Array; } +/** + * Check if a given object implements the MatchedTrack interface. + */ +export function instanceOfMatchedTrack(value: object): value is MatchedTrack { + if (!('id' in value) || value['id'] === undefined) return false; + if (!('distance' in value) || value['distance'] === undefined) return false; + return true; +} + export function MatchedTrackFromJSON(json: any): MatchedTrack { return MatchedTrackFromJSONTyped(json, false); } export function MatchedTrackFromJSONTyped(json: any, ignoreDiscriminator: boolean): MatchedTrack { - if ((json === undefined) || (json === null)) { + if (json == null) { return json; } return { 'id': json['id'], 'distance': json['distance'], - 'paths': !exists(json, 'paths') ? undefined : ((json['paths'] as Array).map(MatchedPathFromJSON)), - 'geometry': !exists(json, 'geometry') ? undefined : json['geometry'], - 'trackPositions': !exists(json, 'trackPositions') ? undefined : ((json['trackPositions'] as Array).map(MatchedTrackPositionFromJSON)), + 'paths': json['paths'] == null ? undefined : ((json['paths'] as Array).map(MatchedPathFromJSON)), + 'geometry': json['geometry'] == null ? undefined : json['geometry'], + 'trackPositions': json['trackPositions'] == null ? undefined : ((json['trackPositions'] as Array).map(MatchedTrackPositionFromJSON)), }; } export function MatchedTrackToJSON(value?: MatchedTrack | null): any { - if (value === undefined) { - return undefined; - } - if (value === null) { - return null; + if (value == null) { + return value; } return { - 'id': value.id, - 'distance': value.distance, - 'paths': value.paths === undefined ? undefined : ((value.paths as Array).map(MatchedPathToJSON)), - 'geometry': value.geometry, - 'trackPositions': value.trackPositions === undefined ? undefined : ((value.trackPositions as Array).map(MatchedTrackPositionToJSON)), + 'id': value['id'], + 'distance': value['distance'], + 'paths': value['paths'] == null ? undefined : ((value['paths'] as Array).map(MatchedPathToJSON)), + 'geometry': value['geometry'], + 'trackPositions': value['trackPositions'] == null ? undefined : ((value['trackPositions'] as Array).map(MatchedTrackPositionToJSON)), }; } diff --git a/typescript/models/MatchedTrackIdentifier.ts b/typescript/models/MatchedTrackIdentifier.ts index c29cde7..a41c727 100644 --- a/typescript/models/MatchedTrackIdentifier.ts +++ b/typescript/models/MatchedTrackIdentifier.ts @@ -4,7 +4,7 @@ * Map Matching * With the Map Matching service you can assign GPS positions to road segments on a digital map. * - * The version of the OpenAPI document: 1.6 + * The version of the OpenAPI document: 1.7 * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). @@ -12,7 +12,7 @@ * Do not edit the class manually. */ -import { exists, mapValues } from '../runtime'; +import { mapValues } from '../runtime'; /** * * @export @@ -27,12 +27,20 @@ export interface MatchedTrackIdentifier { id: string; } +/** + * Check if a given object implements the MatchedTrackIdentifier interface. + */ +export function instanceOfMatchedTrackIdentifier(value: object): value is MatchedTrackIdentifier { + if (!('id' in value) || value['id'] === undefined) return false; + return true; +} + export function MatchedTrackIdentifierFromJSON(json: any): MatchedTrackIdentifier { return MatchedTrackIdentifierFromJSONTyped(json, false); } export function MatchedTrackIdentifierFromJSONTyped(json: any, ignoreDiscriminator: boolean): MatchedTrackIdentifier { - if ((json === undefined) || (json === null)) { + if (json == null) { return json; } return { @@ -42,15 +50,12 @@ export function MatchedTrackIdentifierFromJSONTyped(json: any, ignoreDiscriminat } export function MatchedTrackIdentifierToJSON(value?: MatchedTrackIdentifier | null): any { - if (value === undefined) { - return undefined; - } - if (value === null) { - return null; + if (value == null) { + return value; } return { - 'id': value.id, + 'id': value['id'], }; } diff --git a/typescript/models/MatchedTrackPosition.ts b/typescript/models/MatchedTrackPosition.ts index 2c1c076..73715ef 100644 --- a/typescript/models/MatchedTrackPosition.ts +++ b/typescript/models/MatchedTrackPosition.ts @@ -4,7 +4,7 @@ * Map Matching * With the Map Matching service you can assign GPS positions to road segments on a digital map. * - * The version of the OpenAPI document: 1.6 + * The version of the OpenAPI document: 1.7 * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). @@ -12,15 +12,15 @@ * Do not edit the class manually. */ -import { exists, mapValues } from '../runtime'; +import { mapValues } from '../runtime'; +import type { MatchType } from './MatchType'; import { - MatchType, MatchTypeFromJSON, MatchTypeFromJSONTyped, MatchTypeToJSON, } from './MatchType'; +import type { SegmentAttributes } from './SegmentAttributes'; import { - SegmentAttributes, SegmentAttributesFromJSON, SegmentAttributesFromJSONTyped, SegmentAttributesToJSON, @@ -38,42 +38,48 @@ export interface MatchedTrackPosition { * @memberof MatchedTrackPosition */ matchType: MatchType; + /** + * Time defined according to [RFC 3339](https://tools.ietf.org/html/rfc3339) when the position was passed. + * @type {Date} + * @memberof MatchedTrackPosition + */ + timestamp?: Date; /** * The travel distance [m] from the previous position. It is available only if MatchedTrackPosition.matchType is MATCH\_SUCCESSFUL. * @type {number} * @memberof MatchedTrackPosition */ - distanceFromPreviousMatch?: number | null; + distanceFromPreviousMatch?: number; /** * The latitude value in degrees (WGS84/EPSG:4326) from south to north. This refers to the coordinates on the segment to which the input position matches. It is available only if MatchedTrackPosition.matchType is MATCH\_SUCCESSFUL. * @type {number} * @memberof MatchedTrackPosition */ - latitude?: number | null; + latitude?: number; /** * The longitude value in degrees (WGS84/EPSG:4326) from west to east. This refers to the coordinates on the segment to which the input position matches. It is available only if MatchedTrackPosition.matchType is MATCH\_SUCCESSFUL. * @type {number} * @memberof MatchedTrackPosition */ - longitude?: number | null; + longitude?: number; /** * The geometry of the matched segment as a GeoJSON representation. Coordinates are always present in WGS84 (EPSG:4326). It is available only if MatchedTrackPosition.matchType is MATCH\_SUCCESSFUL. * @type {string} * @memberof MatchedTrackPosition */ - segmentGeometry?: string | null; + segmentGeometry?: string; /** * The straight-line distance (Euclidean distance) [m] from the input position to the matching segment. It is available only if MatchedTrackPosition.matchType is MATCH\_SUCCESSFUL. * @type {number} * @memberof MatchedTrackPosition */ - matchDistance?: number | null; + matchDistance?: number; /** * The difference in degrees \[°\] between the angle of the heading of the input position and the angle of the matching segment. This difference is always smaller than the straight angle. It is available only if MatchedTrackPosition.matchType is MATCH\_SUCCESSFUL. * @type {number} * @memberof MatchedTrackPosition */ - angleDifference?: number | null; + angleDifference?: number; /** * * @type {SegmentAttributes} @@ -82,44 +88,53 @@ export interface MatchedTrackPosition { segmentAttributes?: SegmentAttributes; } + + +/** + * Check if a given object implements the MatchedTrackPosition interface. + */ +export function instanceOfMatchedTrackPosition(value: object): value is MatchedTrackPosition { + if (!('matchType' in value) || value['matchType'] === undefined) return false; + return true; +} + export function MatchedTrackPositionFromJSON(json: any): MatchedTrackPosition { return MatchedTrackPositionFromJSONTyped(json, false); } export function MatchedTrackPositionFromJSONTyped(json: any, ignoreDiscriminator: boolean): MatchedTrackPosition { - if ((json === undefined) || (json === null)) { + if (json == null) { return json; } return { 'matchType': MatchTypeFromJSON(json['matchType']), - 'distanceFromPreviousMatch': !exists(json, 'distanceFromPreviousMatch') ? undefined : json['distanceFromPreviousMatch'], - 'latitude': !exists(json, 'latitude') ? undefined : json['latitude'], - 'longitude': !exists(json, 'longitude') ? undefined : json['longitude'], - 'segmentGeometry': !exists(json, 'segmentGeometry') ? undefined : json['segmentGeometry'], - 'matchDistance': !exists(json, 'matchDistance') ? undefined : json['matchDistance'], - 'angleDifference': !exists(json, 'angleDifference') ? undefined : json['angleDifference'], - 'segmentAttributes': !exists(json, 'segmentAttributes') ? undefined : SegmentAttributesFromJSON(json['segmentAttributes']), + 'timestamp': json['timestamp'] == null ? undefined : (new Date(json['timestamp'])), + 'distanceFromPreviousMatch': json['distanceFromPreviousMatch'] == null ? undefined : json['distanceFromPreviousMatch'], + 'latitude': json['latitude'] == null ? undefined : json['latitude'], + 'longitude': json['longitude'] == null ? undefined : json['longitude'], + 'segmentGeometry': json['segmentGeometry'] == null ? undefined : json['segmentGeometry'], + 'matchDistance': json['matchDistance'] == null ? undefined : json['matchDistance'], + 'angleDifference': json['angleDifference'] == null ? undefined : json['angleDifference'], + 'segmentAttributes': json['segmentAttributes'] == null ? undefined : SegmentAttributesFromJSON(json['segmentAttributes']), }; } export function MatchedTrackPositionToJSON(value?: MatchedTrackPosition | null): any { - if (value === undefined) { - return undefined; - } - if (value === null) { - return null; + if (value == null) { + return value; } return { - 'matchType': MatchTypeToJSON(value.matchType), - 'distanceFromPreviousMatch': value.distanceFromPreviousMatch, - 'latitude': value.latitude, - 'longitude': value.longitude, - 'segmentGeometry': value.segmentGeometry, - 'matchDistance': value.matchDistance, - 'angleDifference': value.angleDifference, - 'segmentAttributes': SegmentAttributesToJSON(value.segmentAttributes), + 'matchType': MatchTypeToJSON(value['matchType']), + 'timestamp': value['timestamp'] == null ? undefined : ((value['timestamp']).toISOString()), + 'distanceFromPreviousMatch': value['distanceFromPreviousMatch'], + 'latitude': value['latitude'], + 'longitude': value['longitude'], + 'segmentGeometry': value['segmentGeometry'], + 'matchDistance': value['matchDistance'], + 'angleDifference': value['angleDifference'], + 'segmentAttributes': SegmentAttributesToJSON(value['segmentAttributes']), }; } diff --git a/typescript/models/MatchedTrackResultType.ts b/typescript/models/MatchedTrackResultType.ts index 716ac92..5170549 100644 --- a/typescript/models/MatchedTrackResultType.ts +++ b/typescript/models/MatchedTrackResultType.ts @@ -4,7 +4,7 @@ * Map Matching * With the Map Matching service you can assign GPS positions to road segments on a digital map. * - * The version of the OpenAPI document: 1.6 + * The version of the OpenAPI document: 1.7 * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). @@ -12,6 +12,7 @@ * Do not edit the class manually. */ + /** * Select properties for the MatchedTrack. * * `PATHS` - The MatchedTrack will contain the paths. @@ -20,14 +21,26 @@ * * `ROUTE_ID` - The MatchedTrack will contain the route ID for each path. PATHS will automatically be included. * * `SEGMENT_ATTRIBUTES` - The MatchedTrack will contain segment attributes for the track positions. TRACK_POSITIONS will automatically be included. * @export - * @enum {string} */ -export enum MatchedTrackResultType { - PATHS = 'PATHS', - GEOMETRY = 'GEOMETRY', - TRACK_POSITIONS = 'TRACK_POSITIONS', - ROUTE_ID = 'ROUTE_ID', - SEGMENT_ATTRIBUTES = 'SEGMENT_ATTRIBUTES' +export const MatchedTrackResultType = { + PATHS: 'PATHS', + GEOMETRY: 'GEOMETRY', + TRACK_POSITIONS: 'TRACK_POSITIONS', + ROUTE_ID: 'ROUTE_ID', + SEGMENT_ATTRIBUTES: 'SEGMENT_ATTRIBUTES' +} as const; +export type MatchedTrackResultType = typeof MatchedTrackResultType[keyof typeof MatchedTrackResultType]; + + +export function instanceOfMatchedTrackResultType(value: any): boolean { + for (const key in MatchedTrackResultType) { + if (Object.prototype.hasOwnProperty.call(MatchedTrackResultType, key)) { + if (MatchedTrackResultType[key as keyof typeof MatchedTrackResultType] === value) { + return true; + } + } + } + return false; } export function MatchedTrackResultTypeFromJSON(json: any): MatchedTrackResultType { diff --git a/typescript/models/MatchingResponse.ts b/typescript/models/MatchingResponse.ts index a6c71cc..7f5a9de 100644 --- a/typescript/models/MatchingResponse.ts +++ b/typescript/models/MatchingResponse.ts @@ -4,7 +4,7 @@ * Map Matching * With the Map Matching service you can assign GPS positions to road segments on a digital map. * - * The version of the OpenAPI document: 1.6 + * The version of the OpenAPI document: 1.7 * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). @@ -12,31 +12,31 @@ * Do not edit the class manually. */ -import { exists, mapValues } from '../runtime'; +import { mapValues } from '../runtime'; +import type { Warning } from './Warning'; import { - ErrorResponse, - ErrorResponseFromJSON, - ErrorResponseFromJSONTyped, - ErrorResponseToJSON, -} from './ErrorResponse'; -import { - MatchedTrack, - MatchedTrackFromJSON, - MatchedTrackFromJSONTyped, - MatchedTrackToJSON, -} from './MatchedTrack'; + WarningFromJSON, + WarningFromJSONTyped, + WarningToJSON, +} from './Warning'; +import type { MatchingStatus } from './MatchingStatus'; import { - MatchingStatus, MatchingStatusFromJSON, MatchingStatusFromJSONTyped, MatchingStatusToJSON, } from './MatchingStatus'; +import type { MatchedTrack } from './MatchedTrack'; import { - Warning, - WarningFromJSON, - WarningFromJSONTyped, - WarningToJSON, -} from './Warning'; + MatchedTrackFromJSON, + MatchedTrackFromJSONTyped, + MatchedTrackToJSON, +} from './MatchedTrack'; +import type { ErrorResponse } from './ErrorResponse'; +import { + ErrorResponseFromJSON, + ErrorResponseFromJSONTyped, + ErrorResponseToJSON, +} from './ErrorResponse'; /** * Contains the results of a matching calculation. If the 'status' is 'RUNNING', the matching calculation is still running and no further properties are set. If the 'status' is 'SUCCEEDED', the matching result is present as property 'matchedTrack'. If the 'status' is 'FAILED', the failure result is present as property 'error'. @@ -70,36 +70,42 @@ export interface MatchingResponse { warnings?: Array; } + + +/** + * Check if a given object implements the MatchingResponse interface. + */ +export function instanceOfMatchingResponse(value: object): value is MatchingResponse { + return true; +} + export function MatchingResponseFromJSON(json: any): MatchingResponse { return MatchingResponseFromJSONTyped(json, false); } export function MatchingResponseFromJSONTyped(json: any, ignoreDiscriminator: boolean): MatchingResponse { - if ((json === undefined) || (json === null)) { + if (json == null) { return json; } return { - 'status': !exists(json, 'status') ? undefined : MatchingStatusFromJSON(json['status']), - 'matchedTrack': !exists(json, 'matchedTrack') ? undefined : MatchedTrackFromJSON(json['matchedTrack']), - 'error': !exists(json, 'error') ? undefined : ErrorResponseFromJSON(json['error']), - 'warnings': !exists(json, 'warnings') ? undefined : ((json['warnings'] as Array).map(WarningFromJSON)), + 'status': json['status'] == null ? undefined : MatchingStatusFromJSON(json['status']), + 'matchedTrack': json['matchedTrack'] == null ? undefined : MatchedTrackFromJSON(json['matchedTrack']), + 'error': json['error'] == null ? undefined : ErrorResponseFromJSON(json['error']), + 'warnings': json['warnings'] == null ? undefined : ((json['warnings'] as Array).map(WarningFromJSON)), }; } export function MatchingResponseToJSON(value?: MatchingResponse | null): any { - if (value === undefined) { - return undefined; - } - if (value === null) { - return null; + if (value == null) { + return value; } return { - 'status': MatchingStatusToJSON(value.status), - 'matchedTrack': MatchedTrackToJSON(value.matchedTrack), - 'error': ErrorResponseToJSON(value.error), - 'warnings': value.warnings === undefined ? undefined : ((value.warnings as Array).map(WarningToJSON)), + 'status': MatchingStatusToJSON(value['status']), + 'matchedTrack': MatchedTrackToJSON(value['matchedTrack']), + 'error': ErrorResponseToJSON(value['error']), + 'warnings': value['warnings'] == null ? undefined : ((value['warnings'] as Array).map(WarningToJSON)), }; } diff --git a/typescript/models/MatchingStatus.ts b/typescript/models/MatchingStatus.ts index 6285b83..78acf5e 100644 --- a/typescript/models/MatchingStatus.ts +++ b/typescript/models/MatchingStatus.ts @@ -4,7 +4,7 @@ * Map Matching * With the Map Matching service you can assign GPS positions to road segments on a digital map. * - * The version of the OpenAPI document: 1.6 + * The version of the OpenAPI document: 1.7 * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). @@ -12,18 +12,31 @@ * Do not edit the class manually. */ + /** * The current status of the matching calculation. * * `RUNNING` - The matching calculation is still running. * * `SUCCEEDED` - The matching calculation has completed successfully. * * `FAILED` - The matching calculation has completed with a failure. * @export - * @enum {string} */ -export enum MatchingStatus { - RUNNING = 'RUNNING', - SUCCEEDED = 'SUCCEEDED', - FAILED = 'FAILED' +export const MatchingStatus = { + RUNNING: 'RUNNING', + SUCCEEDED: 'SUCCEEDED', + FAILED: 'FAILED' +} as const; +export type MatchingStatus = typeof MatchingStatus[keyof typeof MatchingStatus]; + + +export function instanceOfMatchingStatus(value: any): boolean { + for (const key in MatchingStatus) { + if (Object.prototype.hasOwnProperty.call(MatchingStatus, key)) { + if (MatchingStatus[key as keyof typeof MatchingStatus] === value) { + return true; + } + } + } + return false; } export function MatchingStatusFromJSON(json: any): MatchingStatus { diff --git a/typescript/models/PositionsResultType.ts b/typescript/models/PositionsResultType.ts index 7b3047b..d25c690 100644 --- a/typescript/models/PositionsResultType.ts +++ b/typescript/models/PositionsResultType.ts @@ -4,7 +4,7 @@ * Map Matching * With the Map Matching service you can assign GPS positions to road segments on a digital map. * - * The version of the OpenAPI document: 1.6 + * The version of the OpenAPI document: 1.7 * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). @@ -12,17 +12,30 @@ * Do not edit the class manually. */ + /** * * @export - * @enum {string} */ -export enum PositionsResultType { - GEOMETRY = 'GEOMETRY', - SEGMENT_LOCATION_DESCRIPTORS = 'SEGMENT_LOCATION_DESCRIPTORS', - SEGMENT_ATTRIBUTES = 'SEGMENT_ATTRIBUTES', - LOW_EMISSION_ZONES = 'LOW_EMISSION_ZONES', - TOLL = 'TOLL' +export const PositionsResultType = { + GEOMETRY: 'GEOMETRY', + SEGMENT_LOCATION_DESCRIPTORS: 'SEGMENT_LOCATION_DESCRIPTORS', + SEGMENT_ATTRIBUTES: 'SEGMENT_ATTRIBUTES', + LOW_EMISSION_ZONES: 'LOW_EMISSION_ZONES', + TOLL: 'TOLL' +} as const; +export type PositionsResultType = typeof PositionsResultType[keyof typeof PositionsResultType]; + + +export function instanceOfPositionsResultType(value: any): boolean { + for (const key in PositionsResultType) { + if (Object.prototype.hasOwnProperty.call(PositionsResultType, key)) { + if (PositionsResultType[key as keyof typeof PositionsResultType] === value) { + return true; + } + } + } + return false; } export function PositionsResultTypeFromJSON(json: any): PositionsResultType { diff --git a/typescript/models/SegmentAttributes.ts b/typescript/models/SegmentAttributes.ts index 1b55410..6b2a6c2 100644 --- a/typescript/models/SegmentAttributes.ts +++ b/typescript/models/SegmentAttributes.ts @@ -4,7 +4,7 @@ * Map Matching * With the Map Matching service you can assign GPS positions to road segments on a digital map. * - * The version of the OpenAPI document: 1.6 + * The version of the OpenAPI document: 1.7 * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). @@ -12,7 +12,7 @@ * Do not edit the class manually. */ -import { exists, mapValues } from '../runtime'; +import { mapValues } from '../runtime'; /** * Describes the attributes of a segment. Not all attributes are available for all segments. * @export @@ -24,73 +24,80 @@ export interface SegmentAttributes { * @type {boolean} * @memberof SegmentAttributes */ - bridge?: boolean | null; + bridge?: boolean; /** * Indicates that the segment is part of a tunnel. * @type {boolean} * @memberof SegmentAttributes */ - tunnel?: boolean | null; + tunnel?: boolean; /** * Indicates that the segment is part of a ramp. * @type {boolean} * @memberof SegmentAttributes */ - ramp?: boolean | null; + ramp?: boolean; /** * Indicates that the segment is part of a frontage road. * @type {boolean} * @memberof SegmentAttributes */ - frontage?: boolean | null; + frontage?: boolean; /** * Indicates that the segment is part of a road with a solid surface (made of concrete, asphalt, cobblestone etc.). * @type {boolean} * @memberof SegmentAttributes */ - paved?: boolean | null; + paved?: boolean; /** * Indicates that the segment is part of a road which is only suitable for vehicles with four-wheel drive. * @type {boolean} * @memberof SegmentAttributes */ - requiresFourWheelDrive?: boolean | null; + requiresFourWheelDrive?: boolean; /** * Indicates that the segment is part of a road which is privately held or maintained. * @type {boolean} * @memberof SegmentAttributes */ - privatelyManaged?: boolean | null; + privatelyManaged?: boolean; /** * Indicates that the segment is part of a road which is publicly accessible. * @type {boolean} * @memberof SegmentAttributes */ - publicAccess?: boolean | null; + publicAccess?: boolean; /** * Indicates that the segment is part of a parking lot. * @type {boolean} * @memberof SegmentAttributes */ - parkingLot?: boolean | null; + parkingLot?: boolean; /** * Indicates that the segment is part of a road where all traffic has priority over the traffic on the incoming roads. * @type {boolean} * @memberof SegmentAttributes */ - priorityRoad?: boolean | null; + priorityRoad?: boolean; /** * Indicates that the segment is part of a road inside the built up area of a city. * @type {boolean} * @memberof SegmentAttributes */ - builtUpArea?: boolean | null; + builtUpArea?: boolean; /** * The legal speed limit on the road to which this segment belongs [km/h]. Speed limits sometimes depend on the driving direction. If there is no direction specified by the heading parameter of the request then the smaller speed value of the two possible directions is provided. * @type {number} * @memberof SegmentAttributes */ - speedLimit?: number | null; + speedLimit?: number; +} + +/** + * Check if a given object implements the SegmentAttributes interface. + */ +export function instanceOfSegmentAttributes(value: object): value is SegmentAttributes { + return true; } export function SegmentAttributesFromJSON(json: any): SegmentAttributes { @@ -98,47 +105,44 @@ export function SegmentAttributesFromJSON(json: any): SegmentAttributes { } export function SegmentAttributesFromJSONTyped(json: any, ignoreDiscriminator: boolean): SegmentAttributes { - if ((json === undefined) || (json === null)) { + if (json == null) { return json; } return { - 'bridge': !exists(json, 'bridge') ? undefined : json['bridge'], - 'tunnel': !exists(json, 'tunnel') ? undefined : json['tunnel'], - 'ramp': !exists(json, 'ramp') ? undefined : json['ramp'], - 'frontage': !exists(json, 'frontage') ? undefined : json['frontage'], - 'paved': !exists(json, 'paved') ? undefined : json['paved'], - 'requiresFourWheelDrive': !exists(json, 'requiresFourWheelDrive') ? undefined : json['requiresFourWheelDrive'], - 'privatelyManaged': !exists(json, 'privatelyManaged') ? undefined : json['privatelyManaged'], - 'publicAccess': !exists(json, 'publicAccess') ? undefined : json['publicAccess'], - 'parkingLot': !exists(json, 'parkingLot') ? undefined : json['parkingLot'], - 'priorityRoad': !exists(json, 'priorityRoad') ? undefined : json['priorityRoad'], - 'builtUpArea': !exists(json, 'builtUpArea') ? undefined : json['builtUpArea'], - 'speedLimit': !exists(json, 'speedLimit') ? undefined : json['speedLimit'], + 'bridge': json['bridge'] == null ? undefined : json['bridge'], + 'tunnel': json['tunnel'] == null ? undefined : json['tunnel'], + 'ramp': json['ramp'] == null ? undefined : json['ramp'], + 'frontage': json['frontage'] == null ? undefined : json['frontage'], + 'paved': json['paved'] == null ? undefined : json['paved'], + 'requiresFourWheelDrive': json['requiresFourWheelDrive'] == null ? undefined : json['requiresFourWheelDrive'], + 'privatelyManaged': json['privatelyManaged'] == null ? undefined : json['privatelyManaged'], + 'publicAccess': json['publicAccess'] == null ? undefined : json['publicAccess'], + 'parkingLot': json['parkingLot'] == null ? undefined : json['parkingLot'], + 'priorityRoad': json['priorityRoad'] == null ? undefined : json['priorityRoad'], + 'builtUpArea': json['builtUpArea'] == null ? undefined : json['builtUpArea'], + 'speedLimit': json['speedLimit'] == null ? undefined : json['speedLimit'], }; } export function SegmentAttributesToJSON(value?: SegmentAttributes | null): any { - if (value === undefined) { - return undefined; - } - if (value === null) { - return null; + if (value == null) { + return value; } return { - 'bridge': value.bridge, - 'tunnel': value.tunnel, - 'ramp': value.ramp, - 'frontage': value.frontage, - 'paved': value.paved, - 'requiresFourWheelDrive': value.requiresFourWheelDrive, - 'privatelyManaged': value.privatelyManaged, - 'publicAccess': value.publicAccess, - 'parkingLot': value.parkingLot, - 'priorityRoad': value.priorityRoad, - 'builtUpArea': value.builtUpArea, - 'speedLimit': value.speedLimit, + 'bridge': value['bridge'], + 'tunnel': value['tunnel'], + 'ramp': value['ramp'], + 'frontage': value['frontage'], + 'paved': value['paved'], + 'requiresFourWheelDrive': value['requiresFourWheelDrive'], + 'privatelyManaged': value['privatelyManaged'], + 'publicAccess': value['publicAccess'], + 'parkingLot': value['parkingLot'], + 'priorityRoad': value['priorityRoad'], + 'builtUpArea': value['builtUpArea'], + 'speedLimit': value['speedLimit'], }; } diff --git a/typescript/models/SegmentLocationDescriptors.ts b/typescript/models/SegmentLocationDescriptors.ts index f81341f..74fd55b 100644 --- a/typescript/models/SegmentLocationDescriptors.ts +++ b/typescript/models/SegmentLocationDescriptors.ts @@ -4,7 +4,7 @@ * Map Matching * With the Map Matching service you can assign GPS positions to road segments on a digital map. * - * The version of the OpenAPI document: 1.6 + * The version of the OpenAPI document: 1.7 * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). @@ -12,7 +12,7 @@ * Do not edit the class manually. */ -import { exists, mapValues } from '../runtime'; +import { mapValues } from '../runtime'; /** * Describes the location of a segment. Not all descriptors are available for all segments. * @export @@ -24,25 +24,32 @@ export interface SegmentLocationDescriptors { * @type {string} * @memberof SegmentLocationDescriptors */ - countryName?: string | null; + countryName?: string; /** * The city to which the segment belongs. * @type {string} * @memberof SegmentLocationDescriptors */ - city?: string | null; + city?: string; /** * The postal code of the city to which the segment belongs to. * @type {string} * @memberof SegmentLocationDescriptors */ - postalCode?: string | null; + postalCode?: string; /** * The name or number of the road to which the segment belongs. The string may consist of several number entries divided by "/". * @type {string} * @memberof SegmentLocationDescriptors */ - street?: string | null; + street?: string; +} + +/** + * Check if a given object implements the SegmentLocationDescriptors interface. + */ +export function instanceOfSegmentLocationDescriptors(value: object): value is SegmentLocationDescriptors { + return true; } export function SegmentLocationDescriptorsFromJSON(json: any): SegmentLocationDescriptors { @@ -50,31 +57,28 @@ export function SegmentLocationDescriptorsFromJSON(json: any): SegmentLocationDe } export function SegmentLocationDescriptorsFromJSONTyped(json: any, ignoreDiscriminator: boolean): SegmentLocationDescriptors { - if ((json === undefined) || (json === null)) { + if (json == null) { return json; } return { - 'countryName': !exists(json, 'countryName') ? undefined : json['countryName'], - 'city': !exists(json, 'city') ? undefined : json['city'], - 'postalCode': !exists(json, 'postalCode') ? undefined : json['postalCode'], - 'street': !exists(json, 'street') ? undefined : json['street'], + 'countryName': json['countryName'] == null ? undefined : json['countryName'], + 'city': json['city'] == null ? undefined : json['city'], + 'postalCode': json['postalCode'] == null ? undefined : json['postalCode'], + 'street': json['street'] == null ? undefined : json['street'], }; } export function SegmentLocationDescriptorsToJSON(value?: SegmentLocationDescriptors | null): any { - if (value === undefined) { - return undefined; - } - if (value === null) { - return null; + if (value == null) { + return value; } return { - 'countryName': value.countryName, - 'city': value.city, - 'postalCode': value.postalCode, - 'street': value.street, + 'countryName': value['countryName'], + 'city': value['city'], + 'postalCode': value['postalCode'], + 'street': value['street'], }; } diff --git a/typescript/models/Toll.ts b/typescript/models/Toll.ts index bc13875..59dec11 100644 --- a/typescript/models/Toll.ts +++ b/typescript/models/Toll.ts @@ -4,7 +4,7 @@ * Map Matching * With the Map Matching service you can assign GPS positions to road segments on a digital map. * - * The version of the OpenAPI document: 1.6 + * The version of the OpenAPI document: 1.7 * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). @@ -12,7 +12,7 @@ * Do not edit the class manually. */ -import { exists, mapValues } from '../runtime'; +import { mapValues } from '../runtime'; /** * Describes the toll properties of a road segment. * @export @@ -29,30 +29,34 @@ export interface Toll { vehicleCategories?: Array; } +/** + * Check if a given object implements the Toll interface. + */ +export function instanceOfToll(value: object): value is Toll { + return true; +} + export function TollFromJSON(json: any): Toll { return TollFromJSONTyped(json, false); } export function TollFromJSONTyped(json: any, ignoreDiscriminator: boolean): Toll { - if ((json === undefined) || (json === null)) { + if (json == null) { return json; } return { - 'vehicleCategories': !exists(json, 'vehicleCategories') ? undefined : json['vehicleCategories'], + 'vehicleCategories': json['vehicleCategories'] == null ? undefined : json['vehicleCategories'], }; } export function TollToJSON(value?: Toll | null): any { - if (value === undefined) { - return undefined; - } - if (value === null) { - return null; + if (value == null) { + return value; } return { - 'vehicleCategories': value.vehicleCategories, + 'vehicleCategories': value['vehicleCategories'], }; } diff --git a/typescript/models/Track.ts b/typescript/models/Track.ts index 8d953c3..aa524e8 100644 --- a/typescript/models/Track.ts +++ b/typescript/models/Track.ts @@ -4,7 +4,7 @@ * Map Matching * With the Map Matching service you can assign GPS positions to road segments on a digital map. * - * The version of the OpenAPI document: 1.6 + * The version of the OpenAPI document: 1.7 * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). @@ -12,9 +12,9 @@ * Do not edit the class manually. */ -import { exists, mapValues } from '../runtime'; +import { mapValues } from '../runtime'; +import type { TrackPosition } from './TrackPosition'; import { - TrackPosition, TrackPositionFromJSON, TrackPositionFromJSONTyped, TrackPositionToJSON, @@ -34,12 +34,20 @@ export interface Track { positions: Array; } +/** + * Check if a given object implements the Track interface. + */ +export function instanceOfTrack(value: object): value is Track { + if (!('positions' in value) || value['positions'] === undefined) return false; + return true; +} + export function TrackFromJSON(json: any): Track { return TrackFromJSONTyped(json, false); } export function TrackFromJSONTyped(json: any, ignoreDiscriminator: boolean): Track { - if ((json === undefined) || (json === null)) { + if (json == null) { return json; } return { @@ -49,15 +57,12 @@ export function TrackFromJSONTyped(json: any, ignoreDiscriminator: boolean): Tra } export function TrackToJSON(value?: Track | null): any { - if (value === undefined) { - return undefined; - } - if (value === null) { - return null; + if (value == null) { + return value; } return { - 'positions': ((value.positions as Array).map(TrackPositionToJSON)), + 'positions': ((value['positions'] as Array).map(TrackPositionToJSON)), }; } diff --git a/typescript/models/TrackPosition.ts b/typescript/models/TrackPosition.ts index 32f0dd5..d59ef20 100644 --- a/typescript/models/TrackPosition.ts +++ b/typescript/models/TrackPosition.ts @@ -4,7 +4,7 @@ * Map Matching * With the Map Matching service you can assign GPS positions to road segments on a digital map. * - * The version of the OpenAPI document: 1.6 + * The version of the OpenAPI document: 1.7 * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). @@ -12,7 +12,7 @@ * Do not edit the class manually. */ -import { exists, mapValues } from '../runtime'; +import { mapValues } from '../runtime'; /** * Describes a position which belongs to a track with additional track related attributes. * @export @@ -36,13 +36,28 @@ export interface TrackPosition { * @type {number} * @memberof TrackPosition */ - heading?: number | null; + heading?: number; /** * The travel distance [m] from the previous position to this position. This value can be provided to improve the quality of the track matching. * @type {number} * @memberof TrackPosition */ - distanceFromPreviousPosition?: number | null; + distanceFromPreviousPosition?: number; + /** + * Time defined according to [RFC 3339](https://tools.ietf.org/html/rfc3339) when the input position was passed. This value has to be set either for all input positions or none. If set they must have an ascending order. A time zone has to be set explicitly. + * @type {Date} + * @memberof TrackPosition + */ + timestamp?: Date; +} + +/** + * Check if a given object implements the TrackPosition interface. + */ +export function instanceOfTrackPosition(value: object): value is TrackPosition { + if (!('latitude' in value) || value['latitude'] === undefined) return false; + if (!('longitude' in value) || value['longitude'] === undefined) return false; + return true; } export function TrackPositionFromJSON(json: any): TrackPosition { @@ -50,31 +65,30 @@ export function TrackPositionFromJSON(json: any): TrackPosition { } export function TrackPositionFromJSONTyped(json: any, ignoreDiscriminator: boolean): TrackPosition { - if ((json === undefined) || (json === null)) { + if (json == null) { return json; } return { 'latitude': json['latitude'], 'longitude': json['longitude'], - 'heading': !exists(json, 'heading') ? undefined : json['heading'], - 'distanceFromPreviousPosition': !exists(json, 'distanceFromPreviousPosition') ? undefined : json['distanceFromPreviousPosition'], + 'heading': json['heading'] == null ? undefined : json['heading'], + 'distanceFromPreviousPosition': json['distanceFromPreviousPosition'] == null ? undefined : json['distanceFromPreviousPosition'], + 'timestamp': json['timestamp'] == null ? undefined : (new Date(json['timestamp'])), }; } export function TrackPositionToJSON(value?: TrackPosition | null): any { - if (value === undefined) { - return undefined; - } - if (value === null) { - return null; + if (value == null) { + return value; } return { - 'latitude': value.latitude, - 'longitude': value.longitude, - 'heading': value.heading, - 'distanceFromPreviousPosition': value.distanceFromPreviousPosition, + 'latitude': value['latitude'], + 'longitude': value['longitude'], + 'heading': value['heading'], + 'distanceFromPreviousPosition': value['distanceFromPreviousPosition'], + 'timestamp': value['timestamp'] == null ? undefined : ((value['timestamp']).toISOString()), }; } diff --git a/typescript/models/Vehicle.ts b/typescript/models/Vehicle.ts index 455cf11..cb8d828 100644 --- a/typescript/models/Vehicle.ts +++ b/typescript/models/Vehicle.ts @@ -4,7 +4,7 @@ * Map Matching * With the Map Matching service you can assign GPS positions to road segments on a digital map. * - * The version of the OpenAPI document: 1.6 + * The version of the OpenAPI document: 1.7 * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). @@ -12,9 +12,9 @@ * Do not edit the class manually. */ -import { exists, mapValues } from '../runtime'; +import { mapValues } from '../runtime'; +import type { EmissionStandard } from './EmissionStandard'; import { - EmissionStandard, EmissionStandardFromJSON, EmissionStandardFromJSONTyped, EmissionStandardToJSON, @@ -54,10 +54,18 @@ export interface Vehicle { emissionStandards?: Array; /** * Additional attributes that describe this vehicle. For example: min_total_weight, max_total_weight - * @type {{ [key: string]: object; }} + * @type {{ [key: string]: any; }} * @memberof Vehicle */ - vehicleAttributes?: { [key: string]: object; }; + vehicleAttributes?: { [key: string]: any; }; +} + +/** + * Check if a given object implements the Vehicle interface. + */ +export function instanceOfVehicle(value: object): value is Vehicle { + if (!('vehicleCategory' in value) || value['vehicleCategory'] === undefined) return false; + return true; } export function VehicleFromJSON(json: any): Vehicle { @@ -65,33 +73,30 @@ export function VehicleFromJSON(json: any): Vehicle { } export function VehicleFromJSONTyped(json: any, ignoreDiscriminator: boolean): Vehicle { - if ((json === undefined) || (json === null)) { + if (json == null) { return json; } return { 'vehicleCategory': json['vehicleCategory'], - 'timeRestrictions': !exists(json, 'timeRestrictions') ? undefined : json['timeRestrictions'], - 'fuelTypes': !exists(json, 'fuelTypes') ? undefined : json['fuelTypes'], - 'emissionStandards': !exists(json, 'emissionStandards') ? undefined : ((json['emissionStandards'] as Array).map(EmissionStandardFromJSON)), - 'vehicleAttributes': !exists(json, 'vehicleAttributes') ? undefined : json['vehicleAttributes'], + 'timeRestrictions': json['timeRestrictions'] == null ? undefined : json['timeRestrictions'], + 'fuelTypes': json['fuelTypes'] == null ? undefined : json['fuelTypes'], + 'emissionStandards': json['emissionStandards'] == null ? undefined : ((json['emissionStandards'] as Array).map(EmissionStandardFromJSON)), + 'vehicleAttributes': json['vehicleAttributes'] == null ? undefined : json['vehicleAttributes'], }; } export function VehicleToJSON(value?: Vehicle | null): any { - if (value === undefined) { - return undefined; - } - if (value === null) { - return null; + if (value == null) { + return value; } return { - 'vehicleCategory': value.vehicleCategory, - 'timeRestrictions': value.timeRestrictions, - 'fuelTypes': value.fuelTypes, - 'emissionStandards': value.emissionStandards === undefined ? undefined : ((value.emissionStandards as Array).map(EmissionStandardToJSON)), - 'vehicleAttributes': value.vehicleAttributes, + 'vehicleCategory': value['vehicleCategory'], + 'timeRestrictions': value['timeRestrictions'], + 'fuelTypes': value['fuelTypes'], + 'emissionStandards': value['emissionStandards'] == null ? undefined : ((value['emissionStandards'] as Array).map(EmissionStandardToJSON)), + 'vehicleAttributes': value['vehicleAttributes'], }; } diff --git a/typescript/models/Warning.ts b/typescript/models/Warning.ts index 542b22b..344c3ff 100644 --- a/typescript/models/Warning.ts +++ b/typescript/models/Warning.ts @@ -4,7 +4,7 @@ * Map Matching * With the Map Matching service you can assign GPS positions to road segments on a digital map. * - * The version of the OpenAPI document: 1.6 + * The version of the OpenAPI document: 1.7 * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). @@ -12,7 +12,7 @@ * Do not edit the class manually. */ -import { exists, mapValues } from '../runtime'; +import { mapValues } from '../runtime'; /** * * @export @@ -39,10 +39,19 @@ export interface Warning { warningCode: string; /** * Additional properties specific to this class of warnings. - * @type {{ [key: string]: object; }} + * @type {{ [key: string]: any; }} * @memberof Warning */ - details?: { [key: string]: object; }; + details?: { [key: string]: any; }; +} + +/** + * Check if a given object implements the Warning interface. + */ +export function instanceOfWarning(value: object): value is Warning { + if (!('description' in value) || value['description'] === undefined) return false; + if (!('warningCode' in value) || value['warningCode'] === undefined) return false; + return true; } export function WarningFromJSON(json: any): Warning { @@ -50,29 +59,26 @@ export function WarningFromJSON(json: any): Warning { } export function WarningFromJSONTyped(json: any, ignoreDiscriminator: boolean): Warning { - if ((json === undefined) || (json === null)) { + if (json == null) { return json; } return { 'description': json['description'], 'warningCode': json['warningCode'], - 'details': !exists(json, 'details') ? undefined : json['details'], + 'details': json['details'] == null ? undefined : json['details'], }; } export function WarningToJSON(value?: Warning | null): any { - if (value === undefined) { - return undefined; - } - if (value === null) { - return null; + if (value == null) { + return value; } return { - 'description': value.description, - 'warningCode': value.warningCode, - 'details': value.details, + 'description': value['description'], + 'warningCode': value['warningCode'], + 'details': value['details'], }; } diff --git a/typescript/runtime.ts b/typescript/runtime.ts index 5113025..192de6c 100644 --- a/typescript/runtime.ts +++ b/typescript/runtime.ts @@ -4,7 +4,7 @@ * Map Matching * With the Map Matching service you can assign GPS positions to road segments on a digital map. * - * The version of the OpenAPI document: 1.6 + * The version of the OpenAPI document: 1.7 * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). @@ -15,16 +15,86 @@ export const BASE_PATH = "https://api.myptv.com/mapmatch/v1".replace(/\/+$/, ""); -const isBlob = (value: any) => typeof Blob !== 'undefined' && value instanceof Blob; +export interface ConfigurationParameters { + basePath?: string; // override base path + fetchApi?: FetchAPI; // override for fetch implementation + middleware?: Middleware[]; // middleware to apply before/after fetch requests + queryParamsStringify?: (params: HTTPQuery) => string; // stringify function for query strings + username?: string; // parameter for basic security + password?: string; // parameter for basic security + apiKey?: string | Promise | ((name: string) => string | Promise); // parameter for apiKey security + accessToken?: string | Promise | ((name?: string, scopes?: string[]) => string | Promise); // parameter for oauth2 security + headers?: HTTPHeaders; //header params we want to use on every request + credentials?: RequestCredentials; //value for the credentials param we want to use on each request +} + +export class Configuration { + constructor(private configuration: ConfigurationParameters = {}) {} + + set config(configuration: Configuration) { + this.configuration = configuration; + } + + get basePath(): string { + return this.configuration.basePath != null ? this.configuration.basePath : BASE_PATH; + } + + get fetchApi(): FetchAPI | undefined { + return this.configuration.fetchApi; + } + + get middleware(): Middleware[] { + return this.configuration.middleware || []; + } + + get queryParamsStringify(): (params: HTTPQuery) => string { + return this.configuration.queryParamsStringify || querystring; + } + + get username(): string | undefined { + return this.configuration.username; + } + + get password(): string | undefined { + return this.configuration.password; + } + + get apiKey(): ((name: string) => string | Promise) | undefined { + const apiKey = this.configuration.apiKey; + if (apiKey) { + return typeof apiKey === 'function' ? apiKey : () => apiKey; + } + return undefined; + } + + get accessToken(): ((name?: string, scopes?: string[]) => string | Promise) | undefined { + const accessToken = this.configuration.accessToken; + if (accessToken) { + return typeof accessToken === 'function' ? accessToken : async () => accessToken; + } + return undefined; + } + + get headers(): HTTPHeaders | undefined { + return this.configuration.headers; + } + + get credentials(): RequestCredentials | undefined { + return this.configuration.credentials; + } +} + +export const DefaultConfig = new Configuration(); /** * This is the base class for all generated API classes. */ export class BaseAPI { + private static readonly jsonRegex = new RegExp('^(:?application\/json|[^;/ \t]+\/[^;/ \t]+[+]json)[ \t]*(:?;.*)?$', 'i'); private middleware: Middleware[]; - constructor(protected configuration = new Configuration()) { + constructor(protected configuration = DefaultConfig) { this.middleware = configuration.middleware; } @@ -44,16 +114,33 @@ export class BaseAPI { return this.withMiddleware(...middlewares); } - protected async request(context: RequestOpts, initOverrides?: RequestInit): Promise { - const { url, init } = this.createFetchParams(context, initOverrides); + /** + * Check if the given MIME is a JSON MIME. + * JSON MIME examples: + * application/json + * application/json; charset=UTF8 + * APPLICATION/JSON + * application/vnd.company+json + * @param mime - MIME (Multipurpose Internet Mail Extensions) + * @return True if the given MIME is JSON, false otherwise. + */ + protected isJsonMime(mime: string | null | undefined): boolean { + if (!mime) { + return false; + } + return BaseAPI.jsonRegex.test(mime); + } + + protected async request(context: RequestOpts, initOverrides?: RequestInit | InitOverrideFunction): Promise { + const { url, init } = await this.createFetchParams(context, initOverrides); const response = await this.fetchApi(url, init); - if (response.status >= 200 && response.status < 300) { + if (response && (response.status >= 200 && response.status < 300)) { return response; } - throw response; + throw new ResponseError(response, 'Response returned an error code'); } - private createFetchParams(context: RequestOpts, initOverrides?: RequestInit) { + private async createFetchParams(context: RequestOpts, initOverrides?: RequestInit | InitOverrideFunction) { let url = this.configuration.basePath + context.path; if (context.query !== undefined && Object.keys(context.query).length !== 0) { // only add the querystring to the URL if there are query parameters. @@ -61,18 +148,46 @@ export class BaseAPI { // do not handle correctly sometimes. url += '?' + this.configuration.queryParamsStringify(context.query); } - const body = ((typeof FormData !== "undefined" && context.body instanceof FormData) || context.body instanceof URLSearchParams || isBlob(context.body)) - ? context.body - : JSON.stringify(context.body); const headers = Object.assign({}, this.configuration.headers, context.headers); - const init = { + Object.keys(headers).forEach(key => headers[key] === undefined ? delete headers[key] : {}); + + const initOverrideFn = + typeof initOverrides === "function" + ? initOverrides + : async () => initOverrides; + + const initParams = { method: context.method, - headers: headers, - body, + headers, + body: context.body, credentials: this.configuration.credentials, - ...initOverrides }; + + const overriddenInit: RequestInit = { + ...initParams, + ...(await initOverrideFn({ + init: initParams, + context, + })) + }; + + let body: any; + if (isFormData(overriddenInit.body) + || (overriddenInit.body instanceof URLSearchParams) + || isBlob(overriddenInit.body)) { + body = overriddenInit.body; + } else if (this.isJsonMime(headers['Content-Type'])) { + body = JSON.stringify(overriddenInit.body); + } else { + body = overriddenInit.body; + } + + const init: RequestInit = { + ...overriddenInit, + body + }; + return { url, init }; } @@ -86,7 +201,29 @@ export class BaseAPI { }) || fetchParams; } } - let response = await (this.configuration.fetchApi || fetch)(fetchParams.url, fetchParams.init); + let response: Response | undefined = undefined; + try { + response = await (this.configuration.fetchApi || fetch)(fetchParams.url, fetchParams.init); + } catch (e) { + for (const middleware of this.middleware) { + if (middleware.onError) { + response = await middleware.onError({ + fetch: this.fetchApi, + url: fetchParams.url, + init: fetchParams.init, + error: e, + response: response ? response.clone() : undefined, + }) || response; + } + } + if (response === undefined) { + if (e instanceof Error) { + throw new FetchError(e, 'The request failed and the interceptors did not return an alternative response'); + } else { + throw e; + } + } + } for (const middleware of this.middleware) { if (middleware.post) { response = await middleware.post({ @@ -112,8 +249,30 @@ export class BaseAPI { } }; +function isBlob(value: any): value is Blob { + return typeof Blob !== 'undefined' && value instanceof Blob; +} + +function isFormData(value: any): value is FormData { + return typeof FormData !== "undefined" && value instanceof FormData; +} + +export class ResponseError extends Error { + override name: "ResponseError" = "ResponseError"; + constructor(public response: Response, msg?: string) { + super(msg); + } +} + +export class FetchError extends Error { + override name: "FetchError" = "FetchError"; + constructor(public cause: Error, msg?: string) { + super(msg); + } +} + export class RequiredError extends Error { - name: "RequiredError" = "RequiredError"; + override name: "RequiredError" = "RequiredError"; constructor(public field: string, msg?: string) { super(msg); } @@ -128,78 +287,16 @@ export const COLLECTION_FORMATS = { export type FetchAPI = WindowOrWorkerGlobalScope['fetch']; -export interface ConfigurationParameters { - basePath?: string; // override base path - fetchApi?: FetchAPI; // override for fetch implementation - middleware?: Middleware[]; // middleware to apply before/after fetch requests - queryParamsStringify?: (params: HTTPQuery) => string; // stringify function for query strings - username?: string; // parameter for basic security - password?: string; // parameter for basic security - apiKey?: string | ((name: string) => string); // parameter for apiKey security - accessToken?: string | Promise | ((name?: string, scopes?: string[]) => string | Promise); // parameter for oauth2 security - headers?: HTTPHeaders; //header params we want to use on every request - credentials?: RequestCredentials; //value for the credentials param we want to use on each request -} - -export class Configuration { - constructor(private configuration: ConfigurationParameters = {}) {} - - get basePath(): string { - return this.configuration.basePath != null ? this.configuration.basePath : BASE_PATH; - } - - get fetchApi(): FetchAPI | undefined { - return this.configuration.fetchApi; - } - - get middleware(): Middleware[] { - return this.configuration.middleware || []; - } - - get queryParamsStringify(): (params: HTTPQuery) => string { - return this.configuration.queryParamsStringify || querystring; - } - - get username(): string | undefined { - return this.configuration.username; - } - - get password(): string | undefined { - return this.configuration.password; - } - - get apiKey(): ((name: string) => string) | undefined { - const apiKey = this.configuration.apiKey; - if (apiKey) { - return typeof apiKey === 'function' ? apiKey : () => apiKey; - } - return undefined; - } - - get accessToken(): ((name?: string, scopes?: string[]) => string | Promise) | undefined { - const accessToken = this.configuration.accessToken; - if (accessToken) { - return typeof accessToken === 'function' ? accessToken : async () => accessToken; - } - return undefined; - } - - get headers(): HTTPHeaders | undefined { - return this.configuration.headers; - } - - get credentials(): RequestCredentials | undefined { - return this.configuration.credentials; - } -} - export type Json = any; export type HTTPMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'OPTIONS' | 'HEAD'; export type HTTPHeaders = { [key: string]: string }; -export type HTTPQuery = { [key: string]: string | number | null | boolean | Array | HTTPQuery }; +export type HTTPQuery = { [key: string]: string | number | null | boolean | Array | Set | HTTPQuery }; export type HTTPBody = Json | FormData | URLSearchParams; +export type HTTPRequestInit = { headers?: HTTPHeaders; method: HTTPMethod; credentials?: RequestCredentials; body?: HTTPBody }; export type ModelPropertyNaming = 'camelCase' | 'snake_case' | 'PascalCase' | 'original'; +export type InitOverrideFunction = (requestContext: { init: HTTPRequestInit, context: RequestOpts }) => Promise + export interface FetchParams { url: string; init: RequestInit; @@ -213,33 +310,33 @@ export interface RequestOpts { body?: HTTPBody; } -export function exists(json: any, key: string) { - const value = json[key]; - return value !== null && value !== undefined; -} - export function querystring(params: HTTPQuery, prefix: string = ''): string { return Object.keys(params) - .map((key) => { - const fullKey = prefix + (prefix.length ? `[${key}]` : key); - const value = params[key]; - if (value instanceof Array) { - const multiValue = value.map(singleValue => encodeURIComponent(String(singleValue))) - .join(`&${encodeURIComponent(fullKey)}=`); - return `${encodeURIComponent(fullKey)}=${multiValue}`; - } - if (value instanceof Date) { - return `${encodeURIComponent(fullKey)}=${encodeURIComponent(value.toISOString())}`; - } - if (value instanceof Object) { - return querystring(value as HTTPQuery, fullKey); - } - return `${encodeURIComponent(fullKey)}=${encodeURIComponent(String(value))}`; - }) + .map(key => querystringSingleKey(key, params[key], prefix)) .filter(part => part.length > 0) .join('&'); } +function querystringSingleKey(key: string, value: string | number | null | undefined | boolean | Array | Set | HTTPQuery, keyPrefix: string = ''): string { + const fullKey = keyPrefix + (keyPrefix.length ? `[${key}]` : key); + if (value instanceof Array) { + const multiValue = value.map(singleValue => encodeURIComponent(String(singleValue))) + .join(`&${encodeURIComponent(fullKey)}=`); + return `${encodeURIComponent(fullKey)}=${multiValue}`; + } + if (value instanceof Set) { + const valueAsArray = Array.from(value); + return querystringSingleKey(key, valueAsArray, keyPrefix); + } + if (value instanceof Date) { + return `${encodeURIComponent(fullKey)}=${encodeURIComponent(value.toISOString())}`; + } + if (value instanceof Object) { + return querystring(value as HTTPQuery, fullKey); + } + return `${encodeURIComponent(fullKey)}=${encodeURIComponent(String(value))}`; +} + export function mapValues(data: any, fn: (item: any) => any) { return Object.keys(data).reduce( (acc, key) => ({ ...acc, [key]: fn(data[key]) }), @@ -257,7 +354,7 @@ export function canConsumeForm(consumes: Consume[]): boolean { } export interface Consume { - contentType: string + contentType: string; } export interface RequestContext { @@ -273,9 +370,18 @@ export interface ResponseContext { response: Response; } +export interface ErrorContext { + fetch: FetchAPI; + url: string; + init: RequestInit; + error: unknown; + response?: Response; +} + export interface Middleware { pre?(context: RequestContext): Promise; post?(context: ResponseContext): Promise; + onError?(context: ErrorContext): Promise; } export interface ApiResponse {