# payrex-js-sdk-base

> Payrex Javascript SDK Base class

Latest version **1.2.2** (published 2018-02-26) · MIT license · 0 weekly downloads

## Install

```sh
npm install payrex-js-sdk-base
pnpm add payrex-js-sdk-base
yarn add payrex-js-sdk-base
bun add payrex-js-sdk-base
```

## 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.2.2 |
| Published | 2018-02-26 |
| First published | 2018-01-24 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 41.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | payrex |
| Maintainers | devprex |

## Links

- npm: https://www.npmjs.com/package/payrex-js-sdk-base
- Repository: https://github.com/payrex/js-sdk-base
- Homepage: https://github.com/payrex/js-sdk-base#readme
- Issues: https://github.com/payrex/js-sdk-base/issues
- npm.io page: https://npm.io/package/payrex-js-sdk-base

## Dependencies (1)

- [whatwg-url](https://npm.io/package/whatwg-url.md) ^6.4.0

## Recent versions

- 1.2.2 (latest) — 2018-02-26
- 1.2.1 — 2018-02-26
- 1.2.0 — 2018-02-26
- 1.1.7 — 2018-02-12
- 1.1.6 — 2018-02-07
- 1.1.5 — 2018-02-07
- 1.1.4 — 2018-02-06
- 1.1.3 — 2018-01-26
- 1.1.2 — 2018-01-26
- 1.1.1 — 2018-01-25
- 1.1.0 — 2018-01-25
- 1.0.3 — 2018-01-24
- 1.0.1 — 2018-01-24
- 1.0.0 — 2018-01-24

## README

PAYREX-JS-SDK-BASE
==================

[![Build Status](https://travis-ci.org/payrex/js-sdk-base.svg?branch=master)](https://travis-ci.org/payrex/js-sdk-base)
[![codecov](https://codecov.io/gh/payrex/js-sdk-base/branch/master/graph/badge.svg)](https://codecov.io/gh/payrex/js-sdk-base)

Base class for Payrex JS SDK.
Don't use this repo directly, you should use
[payrex/js-sdk-node](https://github.com/payrex/js-sdk-node) instead.


Install
-------

```bash
npm install --save payrex-js-sdk-base
```


Usage
-----

```javascript
const PayrexSdkBase = require('payrex-js-sdk-base');

const options = {/* ... options ... */};
const sdkBase = new PayrexSdkBase(options);
```

| Option | Type | Usage | Description |
|--------|------|-------|-------------|
| credentials | string | *optional* | API secret key |
| baseUrl | string | *optional* | API base url (default "http://localhost:3000/") |
| fetch | function | *required* | [Fetch function](https://fetch.spec.whatwg.org/) |
| Headers | function | *required* | [Fetch Headers](https://fetch.spec.whatwg.org/) |
| Url | object | *required* | [Url class](https://url.spec.whatwg.org/) |


### get(`path, [options]`)

Make HTTP-GET request to API.

| Param | Type | Description |
|-------|------|-------------|
| path | **string** | Path (ex. "/users" or "/users/1") |
| options | **object** | Options |
| options.queryParams | **object** | Additional query params to merge |

```js
sdkBase
  .get('/users?status=ACTIVE')
  .then(response => { /* ... */})
  .catch(err => {/* Process error */})
```

### post(`path, body, [options]`)

Make HTTP-POST request to API.

| Param | Type | Description |
|-------|------|-------------|
| path | **string** | Path (ex. "/users" or "/users/1") |
| body | **object** | Body data |
| options | **object** | Options |
| options.queryParams | **object** | Additional query params to merge |

```js
sdkBase
  .post('/users', {
    name: 'John Doe',
    status: 'ACTIVE'
  })
  .then(response => { /* ... */})
  .catch(err => {/* Process error */})
```

### put(`path, body, [options]`)

Make HTTP-PUT request to API.

| Param | Type | Description |
|-------|------|-------------|
| path | **string** | Path (ex. "/users" or "/users/1") |
| body | **object** | Body data |
| options | **object** | Options |
| options.queryParams | **object** | Additional query params to merge |

```js
sdkBase
  .put('/users', {
    name: 'Johnny Doe'
  })
  .then(response => { /* ... */})
  .catch(err => {/* Process error */})
```

### remove(`path, [options]`)

Make HTTP-DELETE request to API.

| Param | Type | Description |
|-------|------|-------------|
| path | **string** | Path (ex. "/users" or "/users/1") |
| options | **object** | Options |
| options.queryParams | **object** | Additional query params to merge |

```js
sdkBase
  .remove('/users/1')
  .then(response => { /* ... */})
  .catch(err => {/* Process error */})
```

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