using System;
using System.Collections.Generic;
using com.ultracart.admin.v2.Api;
using com.ultracart.admin.v2.Model;
using NUnit.Framework;
namespace SdkSample
{
// This sample uses NUnit Framework
[TestFixture]
public class CreateCustomerTest
{
[Test]
public void CreateCustomer()
{
// See https://ultracart.atlassian.net/wiki/spaces/ucdoc/pages/158597140/C+SDK+Sample+Initializing+Routine
UltraCartInit.Init();
var api = new CustomerApi();
var random = new Random();
var i = random.Next();
Customer customer = new Customer
{
Email = "sample" + i + "@ultracart.com",
Password = "change_me"
};
var billing = new List<CustomerBilling>();
billing.Add(new CustomerBilling()
{
FirstName = "John"
});
customer.Billing = billing;
CustomerResponse response = api.InsertCustomer(customer);
if (response.Success == true)
{
Console.WriteLine(response.Customer);
}
else
{
Console.WriteLine(response.Error.ErrorCode);
Console.WriteLine(response.Error.DeveloperMessage);
Console.WriteLine(response.Error.UserMessage);
Console.WriteLine(response.Error.MoreInfo);
}
}
}
}