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