Product Variants
This object represents a product variant of your business. Use it to track receipts that belong to the same product-variant.
product-variants:create
product-variants:read
product-variants:delete
product-variants:update
Core principles
A product-variant should be unique by email or by phone number.
SBProductVariant
Create a product variant
Create a new product-variant. Requires scope product-variants:create
POST https://api.smartbills.io/v1/product/:productId/variants
Request Body
Requires body of type ProductVariantCreateRequest
ProductVariantCreateRequest
Parameter | Description | Type | Required |
---|---|---|---|
firstName | First name of the product-variant | string | required |
lastName | Last name of the product-variant | string | required |
locale | Locale the product-variant | string | required |
email | Email of the product-variant | string | required if no phone |
phone | Phone of the product-variant | string | required if no email |
{
"firstName": "John",
"lastName": "Doe",
"email": "[email protected]",
"taxExempt": true,
"phone": "(555) 555-5555",
"locale": "fr-CA",
"acceptsMarketing": true,
}
Response
Returns a SBProductVariant
{
"id": 1,
"firstName": "John",
"lastName": "Doe",
"email": "[email protected]",
"taxExempt": true,
"phone": "(555) 555-5555",
"locale": "fr-CA",
"acceptsMarketing": true,
}
Code example
import { SBClient, SBProductVariant, ProductVariantCreateRequest} from "@smartbills/sdk"
const client: SBClient = new SBClient();
const request: ProductVariantCreateRequest = {
"firstName": "John",
"lastName": "Doe",
"email": "[email protected]",
"taxExempt": true,
"phone": "(555) 555-5555",
"locale": "fr-CA",
"acceptsMarketing": true,
};
const productVariant: SBProductVariant = await client.product-variant.create(request);
Retrieve a product variant
Retrieve a product variant by ID. Requires scope product-variants:read
GET https://api.smartbills.io/v1/product/:productId/variants/:id
Path parameters
Parameter | Description | Type | Required |
---|---|---|---|
productId | ID of the product | long | required |
id | ID of the product-variant to retrieve | long | required |
Response
Returns a SBProductVariant
{
"id": 1,
"firstName": "John",
"lastName": "Doe",
"email": "[email protected]",
"taxExempt": true,
"phone": "(555) 555-5555",
"locale": "fr-CA",
"acceptsMarketing": true,
}
Code example
import { SBClient, SBProductVariant, ProductVariantCreateRequest} from "@smartbills/sdk"
const client:SBClient = new SBClient();
const productVariant: SBProductVariant = await client.product-variant.getByIdAsync(1);
List product-variants
Retrieve a list of product variants. Requires scope product-variants:read
GET https://api.smartbills.io/v1/product/:productId/variants?page=1&pageSize=100
Query parameters
Requires query parameters of type ProductVariantListRequest
Parameter | Description | Type | Required | Default |
---|---|---|---|---|
page | Current page | long | required | 1 |
pageSize | Number of records to return | long | required | 100 |
orderBy | Order the results by a key of SBProductVariant | keyof SBProductVariant | createdAt | |
sortOrder | Order of the sort | asc or desc | desc |
{
"page": 1,
"pageSize": 100,
"orderBy": "createdAt",
"sortOrder": "desc",
}
Response
Returns a SBList<SBProductVariant>
{
"data": [{
"id": 1,
"firstName": "John",
"lastName": "Doe",
"email": "[email protected]",
"taxExempt": true,
"phone": "(555) 555-5555",
"locale": "fr-CA",
"acceptsMarketing": true,
}],
"metadata": {
"page":1,
"pageSize":100,
"totalPages":1,
"count":1,
},
}
Code example
import { SBClient, SBProductVariant, SBList, ProductVariantListRequest} from "@smartbills/sdk"
const client = new SBClient();
const request: ProductVariantListRequest = {
"page": 1,
"pageSize": 100,
"orderBy": "createdAt",
"sortOrder": "desc",
};
const productVariant-variants: SBList<SBProductVariant> = await client.product-variant.list(request);
Update a product variant
Update information about a product variant. Requires scope product-variants:update
PUT https://api.smartbills.io/v1/product/:productId/variants/:id
Path parameters
Parameter | Description | Type | Required |
---|---|---|---|
id | ID of the product-variant to update | long | required |
Body parameters
Requires a body of type ProductVariantUpdateRequest
Parameter | Description | Type | Required |
---|---|---|---|
firstName | First name of the product-variant | string | required |
lastName | Last name of the product-variant | string | required |
email | Email of the product-variant | string | required |
phone | Phone of the product-variant | string | required |
locale | Locale the product-variant | string | required |
{
"firstName": "John",
"lastName": "Doe",
"email": "[email protected]",
"taxExempt": true,
"phone": "(555) 555-5555",
"locale": "fr-CA",
"acceptsMarketing": true,
}
Response
Returns a SBProductVariant
{
"id": 1,
"firstName": "John",
"lastName": "Doe",
"email": "[email protected]",
"taxExempt": true,
"phone": "(555) 555-5555",
"locale": "fr-CA",
"acceptsMarketing": true,
}
Code example
import { SBClient, SBProductVariant, ProductVariantUpdateRequest} from "@smartbills/sdk"
const client:SBClient = new SBClient();
const request: ProductVariantUpdateRequest = {
"firstName": "John",
"lastName": "Doe",
"email": "[email protected]",
"taxExempt": true,
"phone": "(555) 555-5555",
"locale": "fr-CA",
"acceptsMarketing": true,
}
const productVariant:SBProductVariant = await client.product-variants.updateAsync(1, request);
Delete a product variant
Delete a product variant. Requires scope product-variants:delete
DELETE https://api.smartbills.io/v1/product/:productId/variants/:id
Path parameters
Parameter | Description | Type | Required |
---|---|---|---|
productId | ID of the product | long | required |
id | ID of the product-variant to retrieve | long | required |
Response
Returns a SBProductVariant
{
"id": 1,
"firstName": "John",
"lastName": "Doe",
"email": "[email protected]",
"taxExempt": true,
"phone": "(555) 555-5555",
"locale": "fr-CA",
"acceptsMarketing": true,
}
Code example
import { SBClient, SBProductVariant} from "@smartbills/sdk"
const client:SBClient = new SBClient();
const productVariant:SBProductVariant = await client.product-variants.deleteAsync(1);