Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Wrapper for the '/salesproducts' API. Please note that the Sales service might not be present in all servers.

List of all options:

Table of Contents

Initialize service

Code Block
languagejava
TrivoreID sdk = TrivoreID.mgmtApiClient();
SalesServiceImplProductsServiceImpl salesServiceproductsService = new SalesServiceImplProductsServiceImpl(sdk.salesServiceproductsService());

Catalog management

Code Block
languagejava
// get page with first five catalogs with the ownerId '1234'
Filter filter = Filter.equal("ownedId", "1234");
Page<Catalog> page = salesServiceproductsService.getAllCatalogs(new Criteria(filter, 0, 5));

// create new catalog
Catalog catalog = new Catalog();
catalog.setOwnerId("1234");
catalog.setName("Example Catalog");

// the function returns catalog object with the generated id
catalog = salesServiceproductsService.createCatalog(catalog);

// update catalog
catalog.getCustomFields().put("key1", "value");
catalog.getCustomFields().put("key2", 2);
catalog = salesServiceproductsService.updateCatalog(catalog);

// get catalog
catalog = salesServiceproductsService.getCatalog(catalog.getId());

// delete catalog
salesServiceproductsService.deleteCatalog(catalog.getId());

Pricing plan management

Code Block
languagejava
// get page with first five pricing plans that are enabled
Filter filter = Filter.equal("enabled", true);
Page<PricingPlan> page = salesServiceproductsService.getAllPricingPlans(new Criteria(filter, 0, 5));

// create new pricing plan
PricingPlan pricingPlan = new PricingPlan();
pricingPlan.setOwnerId("1234");
pricingPlan.setTitle("Example Title");

// the function returns pricing plan object with the generated id
pricingPlan = salesServiceproductsService.createPricingPlan(pricingPlan);

// update pricing plan
pricingPlan.getCustomFields().put("key1", "value");
pricingPlan.getCustomFields().put("key2", 2);
pricingPlan = salesServiceproductsService.updatePricingPlan(pricingPlan);

// get pricing plan
pricingPlan = salesServiceproductsService.getPricingPlan(pricingPlan.getId());

// delete pricing plan
salesServiceproductsService.deletePricingPlan(pricingPlan.getId());

Product management

Code Block
languagejava
// get page with first five products with the ownerId '1234'
Filter filter = Filter.equal("enabled", true);
Page<Product> page = salesServiceproductsService.getAllProducts(new Criteria(filter, 0, 5));

// create new product
Product product = new Product();
product.setOwnerId("1234");
product.setSku("C12");

// the function returns product object with the generated id
product = salesServiceproductsService.createProduct(product);

// update product
product.getCustomFields().put("key1", "value");
product.getCustomFields().put("key2", 2);
product = salesServiceproductsService.updateProduct(product);

// get product
product = salesServiceproductsService.getProduct(product.getId());

// delete product
salesServiceproductsService.deleteProduct(product.getId());

Catalog and Item details

Code Block
languagejava
// get all accessible catalogs and their product item details.
AllCatalogs allCatalogs = productService.getAllCatalogsAndItems();

// apply parameters
allCatalogs = productService.getAllCatalogsAndItems("fi", "EUR", null,
		new String[] { "segmentId1", "segmentId2" }, "2020-12-03T10:15:30.00Z");

// get catalog and its product item details
String catalogId = allCatalogs.getCatalogs().get(0).getCatalogId();
CatalogDetails details = productService.getCatalogDetails(catalogId);

// apply parameters
details = productService.getCatalogDetails(catalogId, "en", "GBP", null, null, null, 2, null);

// get product details
String productId = details.getProducts().get(0).getProductId()
ProductDetails productDetails = productService.getProductDetails(catalogId, productId);

// apply parameters
productDetails = productService.getProductDetails(catalogId, productId, "en", null, null,
				new String[] { "discountCode1", "discountCode1" }, null, 5, null);

Service models

Catalog

CatalogItemLocalisedDescription

PricingPlan

Pricing

CodeDiscount

CustomerSegementDiscount

PaymentMethodDiscount

VariableDiscount

VolumeDiscount

Product

Validity

AllCatalogs

CatalogDetails

ProductDetails

PriceEvaluation

DiscountInfo

LocalisedDescription