1.0.25 • Published 4 months ago
salesbit-api-client v1.0.25
Build
npm install
npm run build
npm pack --pack-destination builds/
Quick start
Install
npm install salesbit-api-client
Import
import { APIClient } from "salesbit-api-client";
Create instance
const client = new APIClient(url, token);
where url: string like this 'https://api.site.com' (no trailing slash)
token: string 'prjX-....'
Get all categories in tree like mode
client.getCategories(): CategoryNode[]
Get list of categories
client.listCategories(listRequest);
Get category by id
client.getCategory(id);
Get list of products
client.listProducts(listRequest);
Get product by id
client.getProduct(id);
Checkout process
const iframe = client.createCheckout(
document.querySelector("#checkout"),
[{ uid: String(product.id), amount: 1 }],
{ layout: { ".fields .label": { textDecoration: "underline" } } },
(order: Order) => {
console.log("created order", order);
iframe;
}
);
signature
public createCheckout(
app: HTMLElement,
items: Item[],
options: { layout?: { [key: string]: any } },
success: (order: Order) => {}
): HTMLIFrameElement {/* ... */}
Types
interface ListRequest {
Search?: string;
Filter?: {
[key: string]: string;
};
Start?: number;
Length?: number;
Sort?: {
[key: string]: string;
};
}
interface ListResponse {
Data: any[];
Page: number;
Filtered: number;
Total: number;
}
export interface Category {
id: number;
enabled: boolean;
created_at: Date;
name: string;
label: string;
description?: string;
media?: Media;
media_id?: number;
parent_id?: number;
updated_at: Date;
}
export interface CategoryNode extends Category {
children?: CategoryNode[];
}
export interface Product {
id: number;
enabled: boolean;
created_at: Date;
name: string;
label: string;
description?: string;
note?: string;
sku?: string;
width: number;
height: number;
depth: number;
weight: number;
volume: number;
media?: Media;
media_id?: number;
medias: Media[];
price: number;
on_sale?: boolean;
sale_price?: number;
updated_at: Date;
}
export interface Media {
id?: number;
created_at: Date;
name: string;
path: string;
label?: string;
description?: string;
content_type: string;
extension?: string;
size: number;
last_modified: Date;
public_url?: string;
project_id?: number;
updated_at?: Date;
}
1.0.25
4 months ago
1.0.24
4 months ago
1.0.23
4 months ago
1.0.19
4 months ago
1.0.18
4 months ago
1.0.17
4 months ago
1.0.16
4 months ago
1.0.22
4 months ago
1.0.21
4 months ago
1.0.20
4 months ago
1.0.11
4 months ago
1.0.15
4 months ago
1.0.14
4 months ago
1.0.13
4 months ago
1.0.12
4 months ago
1.0.9
4 months ago
1.0.8
4 months ago
1.0.7
4 months ago
1.0.10
4 months ago
1.0.2
4 months ago
1.0.1
4 months ago
1.0.4
4 months ago
0.3.2
4 months ago
0.3.0
4 months ago
0.2.1
4 months ago
0.3.1
4 months ago
0.1.2
4 months ago
0.1.1
5 months ago
0.0.1
5 months ago