using System;
using com.ultracart.admin.v2.Api;
using com.ultracart.admin.v2.Client;
using NUnit.Framework;
namespace SdkSample
{
[TestFixture]
public class EditAutoOrderTest
{
[Test]
public void EditAutoOrder()
{
// See https://secure.ultracart.com/merchant/configuration/apiManagementApp.do
const string simpleKey = "508052342b482a015d85c69048030a0005a9da7cea5afe015d85c69048030a00";
Configuration.Default.ApiKey.Add("x-ultracart-simple-key", simpleKey);
Configuration.Default.DefaultHeader.Add("X-UltraCart-Api-Version", "2017-03-01");
var api = new AutoOrderApi();
var autoOrderOid = 2078718; // this is found either by looping through auto orders, or from the back end.
var autoOrderResponse = api.GetAutoOrder(autoOrderOid, "items");
if (autoOrderResponse.Error?.DeveloperMessage != null)
{
// TODO handle this elegantly as needed
Console.WriteLine(autoOrderResponse.Error.DeveloperMessage);
return;
}
var autoOrder = autoOrderResponse.AutoOrder;
autoOrder.Items[0].ArbitraryQuantity = 4;
autoOrderResponse = api.UpdateAutoOrder(autoOrder, autoOrderOid);
if (autoOrderResponse.Error != null && autoOrderResponse.Error.DeveloperMessage != null)
{
Console.WriteLine(autoOrderResponse.Error.DeveloperMessage);
}
}
}
}