System Resources
Several SDK classes represent built-in Nimbu resources. Most extend Nimbu.Object but use dedicated API endpoints. Nimbu.Push is a helper namespace for push sends.
Resource Classes
| Class | Endpoint family | Notes |
|---|---|---|
Nimbu.Customer | Customers | Customer accounts and sessions. |
Nimbu.Product | Products | Products, variants, and sub-products. |
Nimbu.Order | Orders | Orders and current cart helpers. |
Nimbu.Page | Pages | Pages and editable page items. |
Nimbu.Role | Roles | Customer role relations and ACL targets. |
Nimbu.Coupon | Coupons | Coupon records. |
Nimbu.Device | Devices | Device records. |
Nimbu.Push | Devices/push | Push send helper. |
Products
js
const product = await new Nimbu.Query(Nimbu.Product).get(productId);
if (product.hasVariants()) {
const variants = product.getVariants();
}Sub-products:
js
product.addSubProduct(baseProduct, variantProduct);
await product.save();Orders
js
const currentOrder = Nimbu.Order.current();
await currentOrder.add(product, 2, {
note: 'Gift wrap'
});
const items = currentOrder.getItems();Remove an item:
js
await currentOrder.remove(item);Pages
Fetch by id or path:
js
const page = await Nimbu.Page.get('/about');
const hero = page.getItem('hero');Page items delegate save back to the parent page:
js
hero.set('title', 'About us');
await hero.save();Roles
js
const role = new Nimbu.Role('members', new Nimbu.ACL());
role.getCustomers().add(customer);
await role.save();Role helpers:
js
role.getName();
role.setName('editors');
role.getCustomers();
role.getRoles();
role.getChildren();
role.getParents();Push
js
await Nimbu.Push.send({
where: new Nimbu.Query(Nimbu.Device).equalTo('platform', 'ios'),
data: {
title: 'New message',
body: 'You have an update'
}
});Custom Channels With Reserved Names
If a custom channel is named like a system resource, pass forceChannel: true to stay on the channel endpoint.
js
const productEntry = new Nimbu.Object('products', { id });
await productEntry.fetch({ forceChannel: true });