npm package: @frontender-magazine/fm-article
Description: SDK for article service api
Author: Anton Nemtsev
Latest version: 1.6.1

# Documentation

<!-- Generated by documentation.js. Update this documentation by updating the source code. -->

### Table of Contents

-   [ArticleService](#articleservice)
    -   [Parameters](#parameters)
    -   [messages](#messages)
    -   [get](#get)
        -   [Parameters](#parameters-1)
        -   [Examples](#examples)
    -   [getByReponame](#getbyreponame)
        -   [Parameters](#parameters-2)
        -   [Examples](#examples-1)
    -   [getById](#getbyid)
        -   [Parameters](#parameters-3)
        -   [Examples](#examples-2)
    -   [post](#post)
        -   [Parameters](#parameters-4)
        -   [Examples](#examples-3)
    -   [put](#put)
        -   [Parameters](#parameters-5)
        -   [Examples](#examples-4)
    -   [patch](#patch)
        -   [Parameters](#parameters-6)
        -   [Examples](#examples-5)
    -   [details](#details)
        -   [Parameters](#parameters-7)
        -   [Examples](#examples-6)
    -   [delete](#delete)
        -   [Parameters](#parameters-8)
        -   [Examples](#examples-7)
-   [null-null](#null-null)
    -   [Properties](#properties)
-   [Array](#array)
    -   [Properties](#properties-1)
-   [Article](#article)
    -   [Properties](#properties-2)
-   [Contributor](#contributor)
    -   [Properties](#properties-3)

## ArticleService

Article Service API

### Parameters

-   `url` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** service url
-   `token` **([string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String) | null)** user access tocken if available (optional, default `null`)

### messages

Object with class service messages

Type: [Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)

### get

Get Articles list

#### Parameters

-   `null-null` **SearchParams** Object with search params

#### Examples

Read articles list


```javascript
(async () => {
  const Article = new ArticleService('https://article.frontender.info/');
  const list = await Article.get();
})();
```

Returns **ArticleList** array of posts

### getByReponame

Get Article connected to this repository name

#### Parameters

-   `null-null` **SearchParams** Object with search params

#### Examples

Read articles list


```javascript
(async () => {
  const Article = new ArticleService('https://article.frontender.info/');
  const list = await Article.getByReponame('the-art-of-html-semantics-pt1');
})();
```

Returns **ArticleList** array of posts

### getById

Get Article connected to this repository name

#### Parameters

-   `null-null` **SearchParams** Object with search params

#### Examples

Read articles list


```javascript
(async () => {
  const Article = new ArticleService('https://article.frontender.info/');
  const list = await Article.getById('5a04f3ee3d3c231d5d8e009d');
})();
```

Returns **ArticleList** array of posts

### post

Create article

#### Parameters

-   `null-null` **[Article](#article)** user object

#### Examples

Create article


```javascript
(async () => {
  const Article = new ArticleService('https://article.frontender.info/');
  const details = await Article.post({
   "url":"http://hansmuller-webkit.blogspot.ru/2013/02/padding-rounded-rectangle.html",
   "domain":"blogspot.ru",
   "title":"Padding the Rounded Rectangle",
   "published": new Date("2013-02-28"),
   "lang":"eng"
  });
})();
```

Returns **[Article](#article)** created user

### put

Replace article

#### Parameters

-   `null-null` **[Article](#article)** updated article object with \_id included

#### Examples

Replace article


```javascript
(async () => {
  const Article = new ArticleService('https://article.frontender.info/');
  const details = await Article.put({
   "url":"http://hansmuller-webkit.blogspot.ru/2013/02/padding-rounded-rectangle.html",
   "domain":"blogspot.ru",
   "title":"Padding the Rounded Rectangle",
   "published": new Date("2013-02-28"),
   "lang":"eng",
   "_id": "59e11e3bbce79c073e548a9a"
  });
})();
```

Returns **[Article](#article)** created article

### patch

Update article

#### Parameters

-   `null-null` **[Article](#article)** updated article object with \_id included

#### Examples

Patch article


```javascript
(async () => {
  const Article = new ArticleService('https://article.frontender.info/');
  const details = await Article.patch({
   "_id": "59e11e3bbce79c073e548a9a",
   "title": "New article title"
  });
})();
```

Returns **[Article](#article)** updated article

### details

Read specific users details

#### Parameters

-   `id` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** user id

#### Examples

Get article


```javascript
(async () => {
  const Article = new ArticleService('https://article.frontender.info/');
  const details = await Article.details('59e11e3bbce79c073e548a9a');
})();
```

Returns **[Article](#article)** article details

### delete

Delete article by id

#### Parameters

-   `id` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** article id

#### Examples

Delete article by id


```javascript
(async () => {
  const Article = new ArticleService('https://article.frontender.info/');
  await Article.delete('59e11e3bbce79c073e548a9a');
})();
```

## null-null

Search params

Type: SearchParams

### Properties

-   `page` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** page number
-   `perPage` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** articles per page
-   `s` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** keyword to search in domain and title

## Array

Article list object

Type: ArticleList

### Properties

-   `null-null` **[Array](#array)&lt;[Article](#article)>** array of articles

## Article

Article object

Type: [Article](#article)

### Properties

-   `url` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** article url
-   `domain` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** article domain
-   `title` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** article title
-   `lang` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** 3 character lang code
-   `published` **[Date](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date)** publication timestamp
-   `characters` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** characters count
-   `author` **[Array](#array)&lt;[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)>** article with user id's
-   `contributors` **[Array](#array)&lt;[Contributor](#contributor)>** array of contributors
-   `tags` **[Array](#array)&lt;[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)>** array of article tags
-   `team` **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** is user part of the team
-   `core` **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** is user part of the core team
-   `translator` **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** is user translator
-   `editor` **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** is user editor
-   `developer` **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** is user developer
-   `author` **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** is user author
-   `salary` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** salary, if user part of the core team
-   `reponame` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** name of repository with translation, if applyable
-   `translations` **[Article](#article)&lt;[Article](#article)>** array of translations of this articles

## Contributor

Contributor object

Type: [Contributor](#contributor)

### Properties

-   `name` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** contributor name or login if no name available
-   `url` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** url to contributor resource