SBProductVariant

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

ParameterDescriptionTypeRequired
firstNameFirst name of the product-variantstringrequired
lastNameLast name of the product-variantstringrequired
localeLocale the product-variantstringrequired
emailEmail of the product-variantstringrequired if no phone
phonePhone of the product-variantstringrequired if no email
ProductVariantCreateRequest
{
    "firstName": "John",
    "lastName": "Doe",
    "email": "[email protected]",
    "taxExempt": true,
    "phone": "(555) 555-5555",
	"locale": "fr-CA",
	"acceptsMarketing": true,
}

Response

Returns a SBProductVariant

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

ParameterDescriptionTypeRequired
productIdID of the productlongrequired
idID of the product-variant to retrievelongrequired

Response

Returns a SBProductVariant

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

ParameterDescriptionTypeRequiredDefault
pageCurrent pagelongrequired1
pageSizeNumber of records to returnlongrequired100
orderByOrder the results by a key of SBProductVariantkeyof SBProductVariantcreatedAt
sortOrderOrder of the sortasc or descdesc
ProductVariantListRequest
{
    "page": 1,
    "pageSize": 100,
	"orderBy": "createdAt",
	"sortOrder": "desc",
}

Response

Returns a SBList<SBProductVariant>

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

ParameterDescriptionTypeRequired
idID of the product-variant to updatelongrequired

Body parameters

Requires a body of type ProductVariantUpdateRequest

ParameterDescriptionTypeRequired
firstNameFirst name of the product-variantstringrequired
lastNameLast name of the product-variantstringrequired
emailEmail of the product-variantstringrequired
phonePhone of the product-variantstringrequired
localeLocale the product-variantstringrequired
ProductVariantUpdateRequest
{
    "firstName": "John",
    "lastName": "Doe",
    "email": "[email protected]",
    "taxExempt": true,
    "phone": "(555) 555-5555",
	"locale": "fr-CA",
	"acceptsMarketing": true,
}

Response

Returns a SBProductVariant

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

ParameterDescriptionTypeRequired
productIdID of the productlongrequired
idID of the product-variant to retrievelongrequired

Response

Returns a SBProductVariant

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);