/** * Geolocation API SDK * Auto-generated — v1.0 */ class GeolocationClient { constructor(token, baseUrl = 'https://api.aikdata.com/v1/geo') { this.token = token; this.baseUrl = baseUrl.replace(/\/$/, ''); } // ── Geocoding ── /** * Convert address to coordinates */ async geocodeAddress(query = {}) { return this._request('GET', `/geocode`, query); } /** * Convert coordinates to address */ async reverseGeocode(query = {}) { return this._request('GET', `/reverse`, query); } // ── HTTP helper ── async _request(method, path, query = {}, body = null) { const url = new URL(this.baseUrl + path); Object.entries(query).forEach(([k, v]) => { if (v !== undefined && v !== null) url.searchParams.set(k, v); }); const opts = { method, headers: { 'Authorization': `Bearer ${this.token}`, 'Content-Type': 'application/json', 'Accept': 'application/json', }, }; if (body && ['POST', 'PUT', 'PATCH'].includes(method)) { opts.body = JSON.stringify(body); } const res = await fetch(url.toString(), opts); return { status: res.status, data: await res.json() }; } } module.exports = { GeolocationClient };