Skip to content

Commit

Permalink
docs: add documentation for trembita usage on plugins.
Browse files Browse the repository at this point in the history
  • Loading branch information
syllerim authored and oleg-koval committed Jun 28, 2018
1 parent 9359176 commit 1e94db5
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,45 @@ yarn add trembita
## Usage
Trembita is not supposed to be used directly, rather than to develop plugins.

In order you can use a third party service by implementing your plugin, make sure you fill the next requeriments:

- Extend Trembita module.
- Construct the plugin by implementing the properties inherited from trembita module.
- Define the methods that contains the logic that expose third party library logic you want to use.

One example of usage would be:

```js
const clientOptions = {
headers: {
header1: 'xxx',
header2: 'yyy'
},
endpoint: 'http://serviceapi.com'
};

const MyAPIClient = class MyAPIClient extends Trembita {
constructor(options) {
super(...arguments);

this.getData = paramsQueryString => {
const params = {
url: `api/path/`,
qs: paramsQueryString,
expectedCodes: [200, 401, 403, 404],
headers: {
'header1': this.header1,
'header2': this.header2
}
};
return this.request(params);
}
}
}

const client = new MyAPIClient(clientOptions);
```

## Contribute

See [the contribute file](CONTRIBUTING.md)!
Expand Down

0 comments on commit 1e94db5

Please sign in to comment.