@cubekit-cloud/cubekit-sdk-js
v1.0.51
Published
@cubekit-cloud/cubekit-sdk-js - the library for working with auto generated API from cubekit.com
Readme
Cubekit Client SDK
@cubekit-cloud/cubekit-sdk-js - the library for working with auto generated API from cubekit.com. This SDK uses axios to send requests.
Table of Contents
CubekitOrmClient
// CubekitOrmClient is needed for working with auto generated ORM API
import { IOrmClientConfig, CubekitOrmClient } from '@cubekit-cloud/cubekit-sdk-js';
// You can get your configuration from your application page.
const config: IOrmClientConfig = {
baseUrl: 'url';
serviceKey: 'key';
};
const ormClient = new CubekitOrmClient(config);
ormClient.send({...});Kind: global class
- CubekitOrmClient
- ~setConfig(config)
- ~setAuthorizationHeader(value)
- ~send(params) ⇒ Promise.<AxiosResponse.<IResponse.<T2>, any>>
CubekitOrmClient~setConfig(config)
Set new configuration
Kind: inner method of CubekitOrmClient
| Param | Type | Description | | --- | --- | --- | | config | IOrmClientConfig | an object with new configuration |
Example
const config: IOrmClientConfig = {
baseUrl: '/';
serviceKey: 'xxxx-xxxx-xxxx-xxxx';
}
ormClient.setConfig(config);CubekitOrmClient~setAuthorizationHeader(value)
Set authorization header
Kind: inner method of CubekitOrmClient
| Param | Type | Description | | --- | --- | --- | | value | string | a string with auth data |
Example
ormClient.setAuthorizationHeader('Basic YWxhZGRpbjpvcGVuc2VzYW1l');CubekitOrmClient~send(params) ⇒ Promise.<AxiosResponse.<IResponse.<T2>, any>>
Send request to API cubkit.com with params.
Kind: inner method of CubekitOrmClient
| Param | Type | Description | | --- | --- | --- | | params | IOrmRequestParameter.<T> | A generic object containing all the necessary parameters for successful request. | | params.path | string | Path to a exactly model in your application. It can be got from documentation on main page of your application. | | params.method | RequestOrmMethodsEnum | Request type. | | params.options | ISearchOptions.<T> | IGetByIdOptions.<T> | ICreateOptions.<T> | IUpdateOptions.<T> | IDeleteOptions | Data to be sent. |
Example
interface A {
id: string;
}
interface B extends A {
name: string;
}
ormClient.send<A, A>({
}).then((response) => {...}) //response.data.data can be able to string | A | A[]
ormClient.send<A, B>({
}).then((response) => {...}) //response.data.data can be able to string | B | B[]CubekitStorageClient
// CubekitStorageClient is needed for working with auto generated Storage API
import { IStorageClientConfig, CubekitStorageClient } from '@cubekit-cloud/cubekit-sdk-js';
// You can get your configuration from your application page.
const config: IStorageClientConfig = {
baseUrl: 'url';
serviceKey: 'key';
storageId: 'id';
};
const storageClient = new CubekitStorageClient(config);
storageClient.upload({...});Kind: global class
CubekitStorageClient.setConfig(config)
Set new configuration
Kind: static method of CubekitStorageClient
| Param | Type | Description | | --- | --- | --- | | config | IStorageClientConfig | an object with new configuration |
Example
const config: IStorageClientConfig = {
baseUrl: '/';
serviceKey: 'xxxx-xxxx-xxxx-xxxx';
storageId: 'xxxx-xxxx-xxxx-xxxx';
}
storageClient.setConfig(config);