wix-twix
Version:
A simple library for managing server and web Wix clients built on top of Wix SDK.
58 lines (57 loc) • 1.57 kB
JavaScript
import { locations as r, siteProperties as l } from "@wix/business-tools";
import { WixServerClient as u } from "../wixServerClient.js";
import { WixBusinessLocation as n } from "./wixBusinessLocation.js";
class f extends u {
constructor() {
super({ locations: r, siteProperties: l });
}
async getLocationById(o) {
const t = await this.client.locations.getLocation(o);
return new n(this.client, t);
}
async getLocations() {
const { locations: o } = await this.client.locations.listLocations();
return o.map((t) => new n(this.client, t));
}
async getDefaultLocation() {
const t = (await this.client.locations.queryLocations().eq("default", !0).find()).items[0];
if (!t)
throw new Error("No default location found");
return new n(this.client, t);
}
get onLocationUpdate() {
return this.client.locations.onLocationCreated;
}
get onLocationCreate() {
return this.client.locations.onLocationCreated;
}
get onLocationArchive() {
return this.client.locations.onLocationArchiveStatus;
}
get onLocationSetDefault() {
return this.client.locations.onLocationSetDefaultLocation;
}
async createLocation({
name: o,
description: t,
email: i,
phone: e,
fax: c,
timeZone: a
}) {
const s = await this.client.locations.createLocation({
name: o,
description: t,
email: i,
phone: e,
fax: c,
timeZone: a,
address: {}
});
return new n(this.client, s);
}
}
export {
f as WixBusiness
};
//# sourceMappingURL=wixBusiness.js.map