1.2.2 • Published 8 years ago
payrex-js-sdk-base v1.2.2
PAYREX-JS-SDK-BASE
Base class for Payrex JS SDK. Don't use this repo directly, you should use payrex/js-sdk-node instead.
Install
npm install --save payrex-js-sdk-baseUsage
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 |
| Headers | function | required | Fetch Headers |
| Url | object | required | Url class |
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 |
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 |
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 |
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 |
sdkBase
.remove('/users/1')
.then(response => { /* ... */})
.catch(err => {/* Process error */})