# ember-contentful-delivery-adapter

> This addon gets data from service www.contentful.com

Latest version **0.2.0** (published 2016-07-12) · MIT license · 0 weekly downloads

## Install

```sh
npm install ember-contentful-delivery-adapter
pnpm add ember-contentful-delivery-adapter
yarn add ember-contentful-delivery-adapter
bun add ember-contentful-delivery-adapter
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.0 |
| Published | 2016-07-12 |
| First published | 2016-06-21 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >= 0.10.0 |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Bondarenko Alexey |
| Maintainers | bondarenkoalex |
| Keywords | ember-addon, adapter, serializer, contentful, ember-data |

## Links

- npm: https://www.npmjs.com/package/ember-contentful-delivery-adapter
- Repository: https://github.com/BondarenkoAlex/ember-contentful-delivery-adapter
- Homepage: http://bondarenkoalex.github.io/ember-contentful-delivery-adapter/
- Issues: https://github.com/BondarenkoAlex/ember-contentful-delivery-adapter/issues
- npm.io page: https://npm.io/package/ember-contentful-delivery-adapter

## Dependencies (1)

- [ember-cli-babel](https://npm.io/package/ember-cli-babel.md) ^5.1.6

## Recent versions

- 0.2.0 (latest) — 2016-07-12
- 0.1.1 — 2016-07-06
- 0.1.0 — 2016-06-21

## README

[![Build Status](https://travis-ci.org/BondarenkoAlex/ember-contentful-delivery-adapter.svg?branch=master)](https://travis-ci.org/BondarenkoAlex/ember-contentful-delivery-adapter)

# ember-contentful-delivery-adapter
This is an Ember Data adapter/serializer that uses the READ ONLY  [Content Delivery API](https://www.contentful.com/developers/docs/references/content-delivery-api/) from service [contentful](https://www.contentful.com/)

# DEMO
http://bondarenkoalex.github.io/ember-contentful-delivery-adapter/ 

## Create a New Application

```
ember new simple-contentful-app
cd simple-contentful-app
```

## Installation addon
```
ember install ember-contentful-delivery-adapter
```

## Create account at Contentful

You'll want to get an account at [Contentful login](https://be.contentful.com/login).
After registration adds space. You will have provided key and space.

## Configure your application

After installing the addon, you add Namespace and Access Token in `config/environment.js`
```
APP: {
    // Here you can pass flags/options to your application instance
    // when it is created
    contentful: {
        namespace     : '<YOUR CONTENTFUL SPACE>',
        access_token  : '<YOUR CONTENTFUL ACCESS TOKEN>'
    }
}
```

Contentful account:

`<YOUR CONTENTFUL SPACE> : Contentful account -> APIs -> Content delivery / preview keys -> Website Key -> Space ID`

`<YOUR CONTENTFUL ACCESS TOKEN> : Contentful account -> APIs -> Content delivery / preview keys -> Website Key -> Production`

## Models

Addon has added models:
```
// addon/models/
space,
asset,
content-type,
entry
```

All new models should inherit "entry" model. This model contains the default fields, such as 
```
// addon/models/entry.js
import DS from 'ember-data';

export default DS.Model.extend({
  sysCreatedAt: DS.attr('date'),
  sysUpdatedAt: DS.attr('date'),
  sysRevision : DS.attr('number'),
  sysLocale: DS.attr('string'),
  sysSpace: DS.belongsTo('space')
});
```
Example model:
```
// models/course.js
import DS from 'ember-data';
import Entry from 'ember-contentful-delivery-adapter/models/entry';

export default Entry.extend({
  title: DS.attr('string'),
  description: DS.attr('string'),
  objectives: DS.attr(),
  unit: DS.belongsTo('unit-course'),
  image: DS.belongsTo('asset')
});
```

### Naming Models
The new models names as ID "content model".
`Contentful account -> APIs -> Content model explorer -> <content model (IDENTIFIER)>`

Example:

| content model (IDENTIFIER)  | Name model          |
| --------------------------- | ------------------- |
| course                      | course              |
| calendarEvent               | calendar-event      |
| unitCourseSimple            | unit-course-simple  |

## Usage
Your application should have configured setting `config/environment.js` and created models.
You can use the requests, such as: `findRecord, findAll` and `query`.
Example:
```
// app/routes/<file>.js
model() {
  return this.store.findAll('course');
}
```
or
```
// app/routes/<file>.js
model() {
  return this.store.findRecord('course', <Id of Resource>);
}
```
or
```
// app/routes/<file>.js
model() {
  return this.store.query('course', { 'sys.id':<Id of Resource> } );
}
```
`query` param sees ["search parameters"](https://www.contentful.com/developers/docs/references/content-delivery-api/#/reference/search-parameters/query-entries?console=1)

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