forma-embedded-view-sdk
Version:
The Forma Embedded View SDK is a JavaScript library for creating custom extensions in Autodesk Forma (previously Spacemaker).
66 lines (65 loc) • 1.84 kB
JavaScript
/**
* Access project-level metadata. See the
* [Forma documentation](https://help.autodeskforma.com/en/articles/7003747-how-to-create-a-new-project)
* for more information.
*
* @remarks
* Available via {@link auto.Forma | Forma}.{@link index.EmbeddedViewSdk.project | project}.
*/
export class ProjectApi {
#iframeMessenger;
/** @hidden */
constructor(iframeMessenger) {
this.#iframeMessenger = iframeMessenger;
}
/**
* Fetch all project metadata.
*
* @returns The project metadata.
*
* @example
* const projectMetadata = await Forma.project.get()
*/
async get() {
return await this.#iframeMessenger.sendRequest("project/get");
}
/**
* Fetch project country code.
*
* @hidden
* @deprecated Use countryCode from {@link get} instead.
*
* @returns Country code for the project.
*
* @example
* const countryCode = await Forma.project.getCountryCode()
*/
async getCountryCode() {
return await this.#iframeMessenger.sendRequest("project/get-country-code");
}
/**
* Fetch project location (latitude and longitude).
*
* @returns Geolocation for the project as [latitude, longitude].
*
* @example
* const [latitude, longitude] = await Forma.project.getGeoLocation()
*/
async getGeoLocation() {
return await this.#iframeMessenger.sendRequest("project/get-geo-location");
}
/**
* Fetch project timezone.
*
* @hidden
* @deprecated Use timezone from {@link get} instead.
*
* @returns Timezone for the project.
*
* @example
* const timezone = await Forma.project.getTimezone()
*/
async getTimezone() {
return await this.#iframeMessenger.sendRequest("project/get-timezone");
}
}