Models

Product Model

Product represents a good or service that can be sold.

If you are implementing a Product model, make sure you pass productId to the Price model. This way, you can associate a price with a product.

Type

Depending on your app's architecture, products can belong to a Family or be standalone entities. In both cases, you can start by implementing a standalone Product model, and later refactor it to add families support.

If you implement a family-based product, you will need to create a Families controller and set the familyId property on the product.

Properties

idstring
required

Unique identifier of the product

typeenum
required
Possible values

'standalone' 'family'

Type of the product. All products should have a same type.

namestring
required

Customer-facing name.

descriptionstring
optional

Customer-facing description.

unitLabelstring
optional

Label for the unit of the product. For example, 'GB' for data plans.

familyIdstring
optional

ID of the family this product belongs to. type should be set to 'family'

Code Example

import { Integrator } from '@churnkey/sdk'

// export class Product extends Integrator.Product.Family {
export class Product extends Integrator.Product.Standalone {
    constructor(product: YourProduct) {
        super({
            id: product.id,
            ... // map other properties
        })
    }
}