# mm-integration

> Wrapper around Schibsted multimedia integrations

Latest version **1.0.0** (published 2020-09-17) · MIT license · 0 weekly downloads

## Install

```sh
npm install mm-integration
pnpm add mm-integration
yarn add mm-integration
bun add mm-integration
```

## Health

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

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2020-09-17 |
| First published | 2018-09-21 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 25.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Philipp Bock/Bergens Tidende |
| Maintainers | bt-pbock |

## Links

- npm: https://www.npmjs.com/package/mm-integration
- npm.io page: https://npm.io/package/mm-integration

## Dependencies (1)

- [isomorphic-fetch](https://npm.io/package/isomorphic-fetch.md) ^2.2.1

## Recent versions

- 1.0.0 (latest) — 2020-09-17
- 0.1.1 — 2018-11-01
- 0.1.0 — 2018-09-21

## README

# mm-integration

A wrapper around Schibsted's Multimedia integrations for use in the browser and on the server.

```js
const Integration = require('mm-integration')
Integration.defaults.auth = {
  username: process.env['MM_API_PROD_USERNAME'],
  password: process.env['MM_API_PROD_PASSWORD'],
}

// Creating an integration
const myIntegration = new Integration('<p>Hello world!</p>')
await myIntegration.save()
console.log('Integration created at', myIntegration.url)

// Updating an integration
myIntegration.title = 'Hello world!'
await myIntegration.save()
console.log('Integration updated')

// Deleting an integration
await myIntegration.delete()
console.log('Integration deleted')
```
<a name="Integration"></a>

### Integration
**Kind**: global class

* [Integration](#Integration)
    * [new Integration([opts])](#new_Integration_new)
    * _instance_
        * [.save()](#Integration+save) ⇒ <code>Promise</code>
        * [.delete()](#Integration+delete) ⇒ <code>Promise</code>
    * _static_
        * [.defaults](#Integration.defaults)

<a name="new_Integration_new"></a>

#### new Integration([opts])
Create an instance representing an MM integration


| Param | Type | Default | Description |
| --- | --- | --- | --- |
| [opts] | <code>String</code> \| <code>Object</code> |  | Can be a string representing the integration's html body or  an object of options |
| [opts.id] | <code>String</code> |  | The server-side id of the integration |
| [opts.url] | <code>String</code> |  | The URL from which the CMS will fetch the integration. If you want   to programmatically update an existing integration, you will need to provide *both* the `id`   and the `url`. This is unexpected and not ideal, but unfortunately the Content API provides   no way to access the URL of an integration, given its ID. |
| [opts.html] | <code>String</code> | <code>&#x27;&#x27;</code> | The HTML body of the integration. |
| [opts.author] | <code>String</code> | <code>&#x27;&#x27;</code> | Author name to be associated with the integration. |
| [opts.title] | <code>String</code> | <code>&#x27;&#x27;</code> | Title to be associated with the integration. |
| [opts.base] | <code>String</code> | <code>&#x27;https://enrichment.api.plan3.se/proxy/content/v3/publication/bt/multimedias&#x27;</code> | The base URL of the API, without a trailing slash. |
| [opts.auth] | <code>String</code> | <code>{username: &#x27;&#x27;, password: &#x27;&#x27;}</code> | An object with your credentials for   the multimedia API, containing `username` and `password` properties. All options can also be set and changed by setting the instance properties. |

<a name="Integration+save"></a>

#### integration.save() ⇒ <code>Promise</code>
Saves the integration to the server, either creating a new one or updating an existing one
as appropriate

**Kind**: instance method of [<code>Integration</code>](#Integration)
**Returns**: <code>Promise</code> - A promise as returned by `fetch()`
<a name="Integration+delete"></a>

#### integration.delete() ⇒ <code>Promise</code>
Requests the server to delete an existing integration

**Kind**: instance method of [<code>Integration</code>](#Integration)
**Returns**: <code>Promise</code> - A promise as returned by `fetch()`
<a name="Integration.defaults"></a>

#### Integration.defaults
You can globally set the defaults for *all* new `Integration`s by modifying the
`Integration.defaults` static object. This can contain the same options as the `opts` object
you can pass into `new Integration(opts)`.

Note that while you *can* globally set the `id` or `url` properties, this is almost certainly
a bad idea.

To get a fresh objects with the "default defaults", you can call `Integration.getDefaults()`.

**Kind**: static property of [<code>Integration</code>](#Integration)
**Example**
```js
// Reset the global defaults:
Integration.defaults = Integration.getDefaults()
```

---
_Source: https://npm.io/package/mm-integration · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
