# @elateral/brandgility-embedded-api

> Brandgility embedded mode library

Latest version **1.0.1** (published 2020-07-10) · UNLICENSED license · 0 weekly downloads

## Install

```sh
npm install @elateral/brandgility-embedded-api
pnpm add @elateral/brandgility-embedded-api
yarn add @elateral/brandgility-embedded-api
bun add @elateral/brandgility-embedded-api
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2020-07-10 |
| First published | 2019-06-10 |
| Weekly downloads | 0 |
| License | UNLICENSED |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=14.5.0 |
| Dependencies | 0 |
| Unpacked size | 10.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Maintainers | alex_k, aliaksandr_khatsko, andrei_iarmoshuk, artem_synytsin, artsem, balov_bohdan, bmorozov, bressepam, cheekytinker, davesykes, dhaneshwar241, eamonn.doherty.elateral, elateralltd, fedir_sencha, hhastekin, hvedinich, matt-best-elateral, oleksandr_dziuban, robert.atkinson.elateral, robin.landsbert, serhieieva, simonwilbert, sunstory, viacheslav_lubenets, viktar_dzmitryieu, yuriy1988 |

## Links

- npm: https://www.npmjs.com/package/@elateral/brandgility-embedded-api
- Repository: https://github.com/ElateralLtd/brandgility-embedded-api
- npm.io page: https://npm.io/package/@elateral/brandgility-embedded-api

## Recent versions

- 1.0.1 (latest) — 2020-07-10
- 1.0.0 — 2020-07-10
- 0.2.0 — 2020-06-30
- 0.1.2 — 2019-07-16
- 0.1.1 — 2019-06-11
- 0.1.0 — 2019-06-10

## README

# How to embed Brandgility's configurator into an iframe:
- get the id of template to be configured from Brandgility application
- To open an asset for customization, copy and paste below code into your page/component, replace `:id` in `src` attribute with your template's id:
```html
<iframe src="<BRANDGILITY_ENDPOINT>/embedded-template-configure/{new|edit}/:id?action=DRAFT_TEMPLATE_CONFIGURATION_START&eid=:id&embedded=true" />
```
- To configure an already saved template customization, copy and paste below code into your page/component, replace `:id` in `src` attribute with your saved template customization id:
```html
<iframe src="<BRANDGILITY_ENDPOINT>/embedded-template-configure/{new|edit}/:id?action=DRAFT_TEMPLATE_CONFIGURATION_EDIT&eid=:id&embedded=true" />
```

# API library
*Brandgility embedded api library allows you to issue commands to Brandgility configurator in embedded mode*

## Methods

| method | description | parameters |
|:-----:|:-----:|:-----:|
| `on` | subscribes to event | eventName: <`string`>, argument: <`function`> |
| `emit` | triggers an event | eventName: <`string`>, argument: <serializable, see [The structured clone algorithm](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm)> |

*****

## Events to listen
### To subscribe on event use `on` method:
```js
brandgilityEmbeddedApi.on('load', () => console.info('loaded'));
```

| event | description | arguments |
|:-----:|-----|:-----:|
| `load` | load event | entity { `type`: <`string`> , id: <`string`> } |
| `save` | success save event | id of saved item <`string`> |
| `error` | error event | error { `message`: <`string`> } |

*****

## Events to trigger
### To trigger an event use `emit` method:
```js
brandgilityEmbeddedApi.emit('save');
```

| event | description | parameters |
|:-----:|-----|:-----:|
| `save` | saves a current version of template | - |
| `saveAs` | creates a new saved customization from an existing saved customization | new item { `name`: <`string`>, `comments`: <`string`> } |

---
_Source: https://npm.io/package/@elateral/brandgility-embedded-api · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
