0.1.17 • Published 3 years ago

@yuriyempty/blesta-api-provider v0.1.17

Weekly downloads
66
License
MIT
Repository
-
Last release
3 years ago

blesta-api-provider

NPM Version NPM Downloads Node.js Version

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

NameTypeDefaultDescription
urlstringnoneCompany URL
userstringnoneBlesta API user
keystringnoneBlesta API key
ignoreSSLbooleanfalseIgnore https certificate or not
responseFormatenum - json, php, xmljsonResponse data format
timeoutnumber30000Request timeout

Available Methods

  • get(model, method, params)
  • post(model, method, params)
  • delete(model, method, params)

Params Description

NameTypeDefaultDescription
modelstringnoneBlesta model name
methodstringnoneModel method name
paramsobjectobjectMethod params
0.1.16

3 years ago

0.1.17

3 years ago

0.1.10

3 years ago

0.1.11

3 years ago

0.1.12

3 years ago

0.1.13

3 years ago

0.1.14

3 years ago

0.1.15

3 years ago

0.1.8

3 years ago

0.1.7

3 years ago

0.1.9

3 years ago

0.1.6

3 years ago

0.1.4

3 years ago

0.1.5

3 years ago

0.1.2

3 years ago

0.1.1

3 years ago

0.1.0

3 years ago