mapwize-ui-react-native
Version:
Fully featured and ready to use UI to add Mapwize Indoor Maps and Navigation in your React Native app.
114 lines (80 loc) • 4.41 kB
JavaScript
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
export class ApiService {
constructor(options, mapwizeApi) {
_defineProperty(this, "options", void 0);
_defineProperty(this, "mapwizeApi", void 0);
this.options = options;
this.mapwizeApi = mapwizeApi;
}
async search(searchParamsJS) {
var _this$mapwizeApi;
//Compatibility work around with js store
const searchParamsRN = { ...searchParamsJS,
objectClass: 'SearchParams'
};
return (_this$mapwizeApi = this.mapwizeApi) === null || _this$mapwizeApi === void 0 ? void 0 : _this$mapwizeApi.search(this.mergeSearchParams(searchParamsRN, this.options));
}
async getMainSearches(venue) {
var _this$mapwizeApi2;
return venue && ((_this$mapwizeApi2 = this.mapwizeApi) === null || _this$mapwizeApi2 === void 0 ? void 0 : _this$mapwizeApi2.getMainSearches(venue));
}
async getMainFroms(venue) {
var _this$mapwizeApi3;
return venue && ((_this$mapwizeApi3 = this.mapwizeApi) === null || _this$mapwizeApi3 === void 0 ? void 0 : _this$mapwizeApi3.getMainFroms(venue));
}
async getPlace(place) {
var _this$mapwizeApi4;
return (_this$mapwizeApi4 = this.mapwizeApi) === null || _this$mapwizeApi4 === void 0 ? void 0 : _this$mapwizeApi4.getPlace(place._id);
}
async getPlaceWithId(placeId) {
var _this$mapwizeApi5;
return (_this$mapwizeApi5 = this.mapwizeApi) === null || _this$mapwizeApi5 === void 0 ? void 0 : _this$mapwizeApi5.getPlace(placeId);
}
async getPlaceDetails(place) {
var _this$mapwizeApi6;
return (_this$mapwizeApi6 = this.mapwizeApi) === null || _this$mapwizeApi6 === void 0 ? void 0 : _this$mapwizeApi6.getPlaceDetails(place._id);
}
async getPlaceDetailsWithId(placeId) {
var _this$mapwizeApi7;
return (_this$mapwizeApi7 = this.mapwizeApi) === null || _this$mapwizeApi7 === void 0 ? void 0 : _this$mapwizeApi7.getPlaceDetails(placeId);
}
async getDirection(directionParams) {
var _directionParams$from, _directionParams$to, _this$mapwizeApi10;
let from = { ...(directionParams === null || directionParams === void 0 ? void 0 : directionParams.from)
};
let to = { ...(directionParams === null || directionParams === void 0 ? void 0 : directionParams.to)
};
if ((directionParams === null || directionParams === void 0 ? void 0 : (_directionParams$from = directionParams.from) === null || _directionParams$from === void 0 ? void 0 : _directionParams$from.objectClass) === 'PlaceDetails') {
var _this$mapwizeApi8;
from = await ((_this$mapwizeApi8 = this.mapwizeApi) === null || _this$mapwizeApi8 === void 0 ? void 0 : _this$mapwizeApi8.getPlace(from._id));
}
if ((directionParams === null || directionParams === void 0 ? void 0 : (_directionParams$to = directionParams.to) === null || _directionParams$to === void 0 ? void 0 : _directionParams$to.objectClass) === 'PlaceDetails') {
var _this$mapwizeApi9;
to = await ((_this$mapwizeApi9 = this.mapwizeApi) === null || _this$mapwizeApi9 === void 0 ? void 0 : _this$mapwizeApi9.getPlace(to._id));
}
return (_this$mapwizeApi10 = this.mapwizeApi) === null || _this$mapwizeApi10 === void 0 ? void 0 : _this$mapwizeApi10.getDirection(from, to, directionParams.mode); //TODO check direction options
}
async getPlacelist(placelist) {
var _this$mapwizeApi11;
return (_this$mapwizeApi11 = this.mapwizeApi) === null || _this$mapwizeApi11 === void 0 ? void 0 : _this$mapwizeApi11.getPlacelist(placelist._id);
}
async getPlacesForPlacelist(placelist) {
var _this$mapwizeApi12;
return (_this$mapwizeApi12 = this.mapwizeApi) === null || _this$mapwizeApi12 === void 0 ? void 0 : _this$mapwizeApi12.getPlacesForPlacelist(placelist);
}
mergeSearchParams(seachParams, options) {
const merged = { ...seachParams
};
if (options.restrictContentToVenueId) {
merged.venueId = options.restrictContentToVenueId;
}
if (options.restrictContentToVenueIds) {
merged.venueIds = options.restrictContentToVenueIds;
}
if (options.restrictContentToOrganizationId) {
merged.organizationId = options.restrictContentToOrganizationId;
}
return merged;
}
}
//# sourceMappingURL=apiService.js.map