Skip to main content

Product Service

Wrapper for the '/products' and '/sales' APIs. NB! Product service might not be present in all servers

Catalog management

from trivoreid.utils.criteria import Filter
from trivoreid.models.products import Catalog

# get page with first five catalogs with the ownerId '1234'
f = Filter(Filter.EQUALS, 'ownerId', '1234')
page = api.product_service.get_all_catalogs(f, start_index=0, count=5)

# create new catalog
catalog = Catalog()
catalog.ownerId = '1234'
catalog.name = "Example Catalog"

# the function returns catalog object with the generated id
catalog = api.product_service.create_catalog(catalog)

# update catalog
catalog.name = "Catalog Example"
catalog = api.product_service.update_catalog(catalog)

# get catalog
catalog = api.product_service.get_catalog(catalog.id)

#delete catalog
api.product_service.delete_catalog(catalog.id)

Pricing plan management

from trivoreid.utils.criteria import Filter
from trivoreid.models.products import PricingPlan

# get page with first five pricing plans that are enabled
f = Filter(Filter.EQUALS, 'enabled', 'true')
page = api.product_service.get_all_pricing_plans(f, start_index=0, count=5)

# create new pricing plan
pricingPlan = PricingPlan()
pricingPlan.description = 'New pricing plan'
pricingPlan.title = 'Pricing plan'
pricingPlan.ownerID = '1234'

# the function returns pricing plan object with the generated id
pricingPlan = api.product_service.create_pricing_plan(pricingPlan)

# update pricing plan
pricingPlan .title = "pricing plan Example"
pricingPlan = api.product_service.update_pricing_plan(pricingPlan)

# get pricing plan
pricingPlan = api.product_service.get_pricing_plan(pricingPlan .id)

#delete pricing plan
api.product_service.delete_pricing_plan(pricingPlan.id)

Product management

from trivoreid.utils.criteria import Filter
from trivoreid.models.products import Product

# get page with first five pricing plans that have ownerId of '1234'
f = Filter(Filter.EQUALS, 'ownerId', '1234')
page = api.product_service.get_all_products(f, start_index=0, count=5)

# create new pricing plan
product = Product()
product.sku = 'B12'
product.ownerID = '1234'

# the function returns product object with the generated id
product = api.product_service.create_product(product)

# update product
product.sku = 'C12'
product = api.product_service.update_product(product)

# get product
product = api.product_service.get_product(product.id)

#delete product
api.product_service.delete_product(product.id)

Catalog and Item details

# get all accessible catalogs and their product item details.
# this method will return AllCatalogs object with the list of catalogs' details
all_catalogs = api.product_service.get_all_catalogs_and_items()

# apply parameters
all_catalogs = api.product_service.get_all_catalogs_and_items(locale='en',
currency='EUR',
customerSegment=['segmentId'],
atTime='2020-12-03T10:15:30.00Z')


# get catalog and its product item details
# this method will return CatalogDetails object
catalogId = all_catalogs.catalogs[0].catalogId
catalog_details = api.product_service.get_catalog_details(catalogId)

# apply parameters
catalog_details = api.product_service.get_catalog_details(catalogId,
locale='en',
currency='GBP',
code=['discountCode1', 'discountCode2'],
volume=3)

# get product details
# this method will return ProductDetails object
productId = catalog_details.products[0].productId
product_details = api.product_service.get_product_details(catalogId, productId)

# apply parameters
product_details = api.product_service.get_product_details(catalogId,
productId,
locale='fi',
volume=5)

Service models

Catalog

CatalogItem

PricingPlan

Pricing

CodeDiscount

CustomerSegementDiscount

PaymentMethodDiscount

VariableDiscount

VolumeDiscount

Product

Validity

AllCatalogs

CatalogDetails

ProductDetails

PriceEvaluation

DiscountInfo

LocalisedDescription