@yuriyempty/blesta-api-provider
v0.1.17
Published
Provider for working with "Blesta " framework
Downloads
4
Maintainers
Readme
blesta-api-provider
Description
Provider for interaction with the Blesta framework using the API.
P.S - Official documentation for integration is here.
Example
First we must initialize a provider
JS import
const BlestaApi = require("@yuriyempty/blesta-api-provider").BlestaApi;
Typescript import
import { BlestaApi } from "@yuriyempty/blesta-api-provider";
const blestaApi = new BlestaApi({
url: "https://mydomain.com/api",
user: "username",
key: "api-key-xxxxxxxxxxxxxxxxx"
})
Then we can send requests
async function getPackages() {
let response = await blestaApi.get({
model: "packages",
method: "getAll",
params: {
company_id: 1,
order: {
name: "DESC"
}
}
})
if(response.isError) {
// handle response error.
// Param "original" - is interface AxiosResponse or AxiosError
throw Error(response.original);
}
// code of http response
console.log(response.code)
// response from blesta
console.log(response.data)
}
Options
| Name | Type | Default | Description | | ----------------------- |:--------------------------:|:--------:| ------------------------------- | | url | string | none | Company URL | | user | string | none | Blesta API user | | key | string | none | Blesta API key | | ignoreSSL | boolean | false | Ignore https certificate or not | | responseFormat | enum - json, php, xml | json | Response data format | | timeout | number | 30000 | Request timeout |
Available Methods
- get(model, method, params)
- post(model, method, params)
- delete(model, method, params)
Params Description
| Name | Type | Default | Description | | ----------------------- |:--------------------------:|:-------:| ------------------------------- | | model | string | none | Blesta model name | | method | string | none | Model method name | | params | object | object | Method params |