@goteborgco/open-api-js-client
Version:
Official JavaScript client for the Göteborg & Co GraphQL API
55 lines (54 loc) • 1.71 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Location = void 0;
class Location {
constructor(data) {
this.address = data.address;
this.lat = data.lat;
this.lng = data.lng;
this.zoom = data.zoom;
this.place_id = data.place_id;
this.name = data.name;
this.street_number = data.street_number;
this.street_name = data.street_name;
this.state = data.state;
this.post_code = data.post_code;
this.country = data.country;
this.country_short = data.country_short;
}
/**
* Get coordinates as a lat/lng object
* @returns Object containing lat and lng or undefined if coordinates are not set
*/
getCoordinates() {
if (!this.lat || !this.lng)
return undefined;
return { lat: this.lat, lng: this.lng };
}
/**
* Get formatted address string
* @returns Formatted address string or undefined if no address components exist
*/
getFormattedAddress() {
const parts = [
this.street_name,
this.street_number,
this.post_code,
this.state,
this.country
].filter(Boolean);
return parts.length > 0 ? parts.join(', ') : undefined;
}
/**
* Get short formatted address (just street and number)
* @returns Short address string or undefined if no street components exist
*/
getShortAddress() {
const parts = [
this.street_name,
this.street_number
].filter(Boolean);
return parts.length > 0 ? parts.join(' ') : undefined;
}
}
exports.Location = Location;