0.4.0 • Published 2 years ago
@atlasrfidsolutions/avancir-sdk v0.4.0
Avancir SDK
Avancir API wrapper for convenience in NodeJS implementations.
Usage in Node-RED Function Nodes
Setup:
- Double-click on the function node to open its details.
- Select the "Setup" tab.
- Click the "+ add" button at the bottom-left of the detail panel.
- Enter
@atlasrfidsolutions/avancir-sdk
as the module name. - Enter
avancir
(for example) as the "Import as" name. - Select the "On Message" tab.
Create AvancirClient
const { AvancirClient } = avancir;
const api = new AvancirClient("https://dev.avancir.net/api/v1");
Note: Node-RED handles the require/import statements behind the scenes.
Make API Calls
get
and getAll
async get(
resource: string,
queryParams?: Record<string, any>,
headers?: Record<string, string>
): Promise<ApiResponse>
post
async post(
resource: string,
body: any,
queryParams?: Record<string, any>,
headers: Record<string, string> = {}
): Promise<ApiResponse>
put
async put(
resource: string,
body: any,
queryParams?: Record<string, any>,
headers: Record<string, string> = {}
): Promise<ApiResponse>
patch
async patch(
resource: string,
body: any,
queryParams?: Record<string, any>,
headers: Record<string, string> = {}
): Promise<ApiResponse>
delete
async delete(
resource: string,
queryParams?: Record<string, any>,
headers: Record<string, string> = {}
): Promise<ApiResponse>
All API calls return a response that uses the following interface:
ApiResponse
interface ApiResponse {
hasError: boolean;
data: any;
metadata: any;
}
Examples
const resLogin = await api.post('/auth/login', {
"identifier": "...username...",
"password": "...password..."
});
let defaultHeaders = {
"x-session-token": resLogin.data.idToken
};
// Establish current account for users with multi-account access:
await api.get('/users/me', {
"accountKey": "demo"
}, defaultHeaders);
// get(...) return the first page of data
const resGetAccessLevels = await api.get('/items', {
"type": "access_levels",
"workspaceKey": "default"
}, defaultHeaders);
// getAll(...) returns all pages of data
const resGetAllAccessLevels = await api.getAll('/items', {
"type": "access_levels",
"workspaceKey": "default"
}, defaultHeaders);
// post(...) to create an item record
const resCreateItem = await api.post('/items', {
"name": "Item 001",
"type": {...TypeRef...},
"status": {...StatusRef...}
}, {
"workspaceKey": "default"
}, defaultHeaders);
0.4.0
2 years ago
0.3.1
2 years ago
0.3.0
2 years ago
0.2.2
2 years ago
0.2.1
2 years ago
0.2.0
2 years ago
0.1.0
2 years ago
0.0.15
2 years ago
0.0.14
2 years ago
0.0.13
2 years ago
0.0.12
2 years ago
0.0.11
2 years ago
0.0.10
2 years ago
0.0.9
2 years ago
0.0.8
2 years ago
0.0.7
2 years ago
0.0.6
2 years ago
0.0.5
2 years ago
0.0.4
2 years ago
0.0.3
2 years ago
0.0.2
2 years ago
0.0.1
2 years ago