Skip to content

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

ClassEndpoint familyNotes
Nimbu.CustomerCustomersCustomer accounts and sessions.
Nimbu.ProductProductsProducts, variants, and sub-products.
Nimbu.OrderOrdersOrders and current cart helpers.
Nimbu.PagePagesPages and editable page items.
Nimbu.RoleRolesCustomer role relations and ACL targets.
Nimbu.CouponCouponsCoupon records.
Nimbu.DeviceDevicesDevice records.
Nimbu.PushDevices/pushPush 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 });

Part of Nimbu, built by Zenjoy.