/
Product Service (python)
NOTE: Trivore ID Documentation has moved to https://trivoreid.com
The content on this site IS OUT OF DATE!
This space has been archived!
Please go ahead to the new site!
Product Service (python)
Wrapper for the '/products' and '/sales' APIs. NB! Product service might not be present in all servers
List of all options:
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)