ws-dottie
Version:
Your friendly TypeScript companion for Washington State transportation APIs - WSDOT and WSF data with smart caching and React Query integration
35 lines • 1.78 kB
TypeScript
/**
* @fileoverview URL Builder for WS-Dottie API Requests
*
* This module processes complete URL templates for WS-Dottie API requests,
* including parameter encoding, template parameter replacement, and API key injection.
* The complete URLs are pre-constructed from API definitions before being passed to this module.
*
* Key features:
* - Template parameter replacement (e.g., {terminalId} -> actual value)
* - Automatic date conversion to .NET format for WSDOT APIs
* - API key injection with correct parameter names per service
* - URL cleanup to remove empty parameters
* - Support for both WSDOT (/traffic/) and WSF (/ferries/) endpoints
*/
/**
* Builds a complete API URL with template parameter replacement and API key injection
*
* This function processes a complete URL template by splitting it into path and query parts,
* replacing placeholders like {id} in the path with provided values, adding remaining
* parameters as query parameters, and injecting the appropriate API key based on the service type.
*
* @param urlTemplate - The complete API URL template with optional placeholders (e.g., "https://example.com/api/endpoint/{paramId}")
* @param params - Optional parameters for template replacement and query string construction
* @returns Complete URL string ready for API requests
* @example
* ```typescript
* buildCompleteUrl("https://www.wsdot.wa.gov/ferries/api/schedule/rest/schedule/{tripDate}/{routeId}", {
* tripDate: "2024-01-01",
* routeId: 1,
* });
* // Returns: "https://www.wsdot.wa.gov/ferries/api/schedule/rest/schedule/2024-01-01/1?apiaccesscode=YOUR_API_KEY"
* ```
*/
export declare const buildCompleteUrl: <TInput = never>(urlTemplate: string, params?: TInput) => string;
//# sourceMappingURL=buildUrl.d.ts.map