Wrapper for the '/products' and '/sales' API. Please note that the Sales APIs. NB! Product service might not be present in all servers
List of all options:
Catalog management
Code Block |
---|
|
from trivoreid.utils.criteria import Filter
from trivoreid.models.salesproducts import Catalog
# get page with first five catalogs with the ownerId '1234'
f = Filter(Filter.EQUALS, 'ownerId', '1234')
page = api.salesproduct_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.salesproduct_service.create_catalog(catalog)
# update catalog
catalog.name = "Catalog Example"
catalog = api.salesproduct_service.update_catalog(catalog)
# get catalog
catalog = api.salesproduct_service.get_catalog(catalog.id)
#delete catalog
api.salesproduct_service.delete_catalog(catalog.id) |
Pricing plan management
Code Block |
---|
|
from trivoreid.utils.criteria import Filter
from trivoreid.models.salesproducts import PricingPlan
# get page with first five pricing plans that are enabled
f = Filter(Filter.EQUALS, 'enabled', 'true')
page = api.salesproduct_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.salesproduct_service.create_pricing_plan(pricingPlan)
# update pricing plan
pricingPlan .title = "pricing plan Example"
pricingPlan = api.salesproduct_service.update_pricing_plan(pricingPlan)
# get pricing plan
pricingPlan = api.salesproduct_service.get_pricing_plan(pricingPlan .id)
#delete pricing plan
api.salesproduct_service.delete_pricing_plan(pricingPlan.id) |
Product management
Code Block |
---|
|
from trivoreid.utils.criteria import Filter
from trivoreid.models.salesproducts import Product
# get page with first five pricing plans that have ownerId of '1234'
f = Filter(Filter.EQUALS, 'ownerId', '1234')
page = api.salesproduct_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.salesproduct_service.create_product(product)
# update product
product.sku = 'C12'
product = api.salesproduct_service.update_product(product)
# get product
product = api.salesproduct_service.get_product(product.id)
#delete product
api.salesproduct_service.delete_product(product.id) |
Catalog and Item details
Code Block |
---|
|
# 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=['priceDiscountCode1', 'priceDiscountCode2'],
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
/wiki/spaces/TISpubdoc/pages/20515259
...