Contact me!
Eric Håård
+46 (0) 73 375 86 06

Supplier Service

C# code snippets for the Supplier Service

ImportSupplierProduct

Used to insert new or updated supplier products in Storm Commerce, required keys are:

  • SupplierId – Specified in header, references ID of supplier in Storm Commerce
  • SupplierPartNo – Unique part number for supplier SKU
  • Manufacturer – Manufacturer Code in Storm Commerce
  • ManufacturerPartNo – Combination of ManufacturerCode and ManufacturerPartNo must be unique to be able to resolve product in Storm Commerce
  • WarehouseCode – Used to resolve correct supplier warehouse in Storm Commerce
  • LocationCode – Used to resolve correct supplier warehouse location in Storm Commerce
  • PriceListCode – Used to resolve correct supplier price list in Storm Commerce

Example code:

static void Main()
{
    var serviceUrl = "https://stormstage.enferno.se/StormConnect/4.0/api/";
    var applicationId = 0;
    var secretKey = Guid.NewGuid();

    var job = ImportSupplierProduct(serviceUrl, applicationId, secretKey);
}

public static JobDto ImportSupplierProduct(string serviceUrl, int applicationId, Guid secretKey)
{
    const int accountId = 0;
    const int supplierId = 0; // Supplier ID in Storm

    var productHeader = new SupplierProductHeader()
    {
        AccountId = accountId,
        SupplierId = supplierId,
        FullFile = false,
        FieldsThatAreSet = new List<SupplierProductField>()
        {
            SupplierProductField.SupplierPartNo,
            SupplierProductField.ProductName,
            SupplierProductField.CategoryCode,
            SupplierProductField.Manufacturer,
            SupplierProductField.ManufacturerPartNo
        },
        OnhandFieldsThatAreSet = new List<SupplierOnHandField>
        {
            SupplierOnHandField.Value
        },
        PriceFieldsThatAreSet = new List<SupplierPriceField>
        {
            SupplierPriceField.CostPurchase
        }
    };

    var requestUri = new Uri(new Uri(serviceUrl), "supplier/ImportProducts");
    var myRequest = new MyRequest<SupplierProductHeader, SupplierProduct>(
        productHeader, GetSupplierProducts());
    return RestHelper.SendStreamedData<JobDto, SupplierProductHeader, SupplierProduct>(
        requestUri.AbsoluteUri, applicationId, secretKey, myRequest);
}

private static IEnumerable<SupplierProduct> GetSupplierProducts()
{
    //NOTE Format and map your data to the StormConnect standard here
    return new List<SupplierProduct>
    {
        new SupplierProduct
        {
            SupplierPartNo = "SupplierPartNo123", // NOTE Required key
            ProductName = "TestArticle 123",
            CategoryCode = "SupplierCategory01",
            Manufacturer = "Manufacturer01", // NOTE Required key
            ManufacturerPartNo = "TESTMFRPARTNO01", // NOTE Required key
            OnHand = new List<SupplierOnHand>
                            {
                                new SupplierOnHand
                                {
                                    WarehouseCode = "Standard", // Part of onhand key
                                    LocationCode = "Standard", // Part of onhand key
                                    Value = 12M // Available qty
                                }
                            },
            PriceList = new List<SupplierPrice>
                            {
                                new SupplierPrice
                                {
                                    PriceListCode = "STD1", // Price key
                                    CurrencyCode = "SEK",
                                    CostPurchase = 125.00M // Excl. VAT
                                }
                            }
        }
    };
}

Related:
Querying job status