Click or drag to resize

LoyaltyProductClientInsertProduct Method

Syntax
C#
public Result InsertProduct(
	ManagementGroupRequestOfProduct request
)

Parameters

request
Type: LoyaltyServiceManagementGroupRequestOfProduct

Return Value

Type: Result
Examples
C#
using (var svc = new LoyaltyService.LoyaltyProductClient())
{
  var request = new LoyaltyService.ManagementGroupRequestOfProduct();
  request.Token = "Token";//Required - Token returned from AccountService.ManagementGroupLogin
  request.ManagementGroup = "Management group";//Required - ManagementGroup supplied when calling AccountService.ManagementGroupLogin

  var productRSN = Guid.NewGuid();
  var product = new LoyaltyService.Product();
  product.RSN = productRSN;
  product.DisplayValue = "Reg bag"; //Required
  product.Active = true;//Optional
  product.ActiveFrom = DateTime.Now;//Optional
  product.ActiveTo = DateTime.Now.AddDays(7); //Optional
  product.NonFinancialMaxPoints_PerCalendarYear = 0;//Optional
  product.NonFinancialMaxPoints_PerDay = 0; //Optional
  product.NonFinancialMaxPoints_PerJoinedYear = 0; //Optional
  product.NonFinancialMaxPoints_PerMonth = 0; //Optional
  product.NonFinancialMaxPoints_PerWeek = 0; //Optional
  product.ProductBrand = "Bag Makers"; //Optional
  product.ProductCode = "RB_001"; //Optional
  product.ProductDescription = "Luxury red bag"; //Optional
  product.ProductName = "Red bag";//Optional
  product.ProductType = "NONFINANICAL";//Optional - Valid values are : 'LOYALTYCARD', 'EVENT', 'SUBSCRIPTIONMEMBERSHIP', 'AWARDENTRY', 'EDUCATION', 'SPONSORSHIP', 'EXHIBITION', 'PIECERATE', 'POLICY' or 'NONFINANICAL'

  var document = new LoyaltyService.Document();
  document.RSN = Guid.NewGuid(); //Required
  document.DisplayValue = "Size guide"; //Required
  document.Entity_RSN = productRSN; //Required - RSN of product
  document.BinaryData_RSN = new Guid("713992b1-d107-4bb0-af1d-536002869510");; //Required
  document.CreatedBy_RSN = new Guid("bfcf5cd9-ca61-4111-8dcc-fbfc79e2ca0a");; //Optional
  product.Documents = new LoyaltyService.Document[] { document }; //Optional

  var image = new LoyaltyService.GalleryImage();
  image.DisplayValue = "red_bag.jpg";//Required
  image.Entity_RSN = productRSN;//Required - RSN of product
  image.PrimaryImage_RSN = new Guid("d01600dd-d843-49fc-9e45-5759bd660df5");;//Required
  image.SourceImage_RSN = new Guid("5323f2ee-ce69-4e5b-8805-3ea938bdfaa0");;//Required
  image.ThumbnailImage_RSN = new Guid("b9e78ef5-9600-45e7-8cf6-18e5b0192b95");;//Required
  image.FeaturedImage = false; //Optional
  image.DisplayOrder = 1;//Optional
  product.GalleryImages = new LoyaltyService.GalleryImage[] { image }; //Optional

  var category = new LoyaltyService.ProductCategory();
  category.RSN = new Guid("585b8030-39e3-4fc8-a89f-035182210744");; //Required
  product.ProductCategories = new LoyaltyService.ProductCategory[] { category }; //Optional - Must belong to supplied department. Only first category used

  var department = new LoyaltyService.ProductDepartment();
  department.RSN = new Guid("3af3c2c8-eb31-4da1-8d32-7d026358da75");; //Required
  product.ProductDepartments = new LoyaltyService.ProductDepartment[] { department }; //Optional - Required if product category supplied. Only first department used

  request.Value = product;//Required 

  LoyaltyService.Result result = svc.InsertProduct(request);

  if (result.FaultCode == 0)
  {
    //Request succeeded
  }
  else
  {
    //Request failed
    throw new Exception(result.FaultDescription);
  }
}
See Also