Customer Bill To
GET
using System.Threading.Tasks;
using Wdcs.Wip.Api;
using Wdcs.Wip.Client;
using Wdcs.Wip.Model;
namespace wip_project.Api
{
public partial class CustomerBillToService : IGetApi
{
/// <summary>
/// Gets a CustomerBillTo from server filter by a criteria
/// Entity can be filtered by any of the fields in the entity
/// </summary>
/// <param name="apiUrl"></param>
/// <param name="username"></param>
/// <param name="password"></param>
/// <returns></returns>
public async Task GetAsync(string apiUrl, string username, string password)
{
var config = new Configuration()
{
BasePath = apiUrl
};
var tokenRequest = new TokenApi(config);
// Get the Token
var response = tokenRequest.Create(new TokenUser(username, password));
var authorization = "Bearer " + response.AuthToken;
// Instantiate API
var billToApi = new CustomerBillToApi(config);
// Do a get from the server filtering where customerId = "001"
await billToApi.GetAsync(authorization: authorization, customerId: "001");
}
}
}
POST
using System.Threading.Tasks;
using Wdcs.Wip.Api;
using Wdcs.Wip.Client;
using Wdcs.Wip.Model;
namespace wip_project.Api
{
public partial class CustomerBillToService : IPostApi
{
/// <summary>
/// A post creates a new record in the system
/// If a CustomerBillTo with same CustomerId does not exists
/// </summary>
/// <param name="apiUrl"></param>
/// <param name="username"></param>
/// <param name="password"></param>
/// <returns></returns>
public async Task PostAsync(string apiUrl, string username, string password)
{
var config = new Configuration()
{
BasePath = apiUrl
};
var tokenRequest = new TokenApi(config);
// Get the Token
var response = tokenRequest.Create(new TokenUser(username, password));
var authorization = "Bearer " + response.AuthToken;
// Create a new Entity for Customer Bill To
var payload = new CustomerBillTo(
address1: "Bld 1 Street 1",
address2: "Home Building",
city: "San Juan",
companyName: "Company Name 2",
customer: "001",
country: "Cloud",
contact: "Rick Jr. Sample",
customerId: "C-01",
faxPhone: "555-555-5555",
inventoryHandling: "FIFO",
locGroup: "G01",
note: "",
payTerms: "",
route: "Route1",
state: "CLD",
zipcode: "00918"
);
// Post to database
var billToApi = new CustomerBillToApi(config);
await billToApi.PostAsync(authorization, payload);
}
}
}
PUT
using System.Threading.Tasks;
using Wdcs.Wip.Api;
using Wdcs.Wip.Client;
using Wdcs.Wip.Model;
namespace wip_project.Api
{
public partial class CustomerBillToService : IPutApi
{
/// <summary>
/// Creates or edit a CutomerBillTo
/// </summary>
/// <param name="apiUrl">https://api.[company_name].devzone.multisystems.com</param>
/// <param name="username"></param>
/// <param name="password"></param>
/// <remarks>User must have Wip Read/Write access</remarks>
public async Task PutAsync(string apiUrl, string username, string password)
{
var config = new Configuration()
{
BasePath = apiUrl
};
var tokenRequest = new TokenApi(config);
// Get the Token
var response = tokenRequest.Create(new TokenUser(username, password));
var authorization = "Bearer " + response.AuthToken;
// Create a new Entity for Customer Bill To
var payload = new CustomerBillTo(
address1: "Bld 1 Street 1",
address2: "Home Building",
city: "San Juan",
companyName: "Company Name 2",
customer: "001",
country: "Cloud",
contact: "Rick Jr. Sample",
customerId: "C-01",
faxPhone: "555-555-5555",
inventoryHandling: "FIFO",
locGroup: "G01",
note: "",
payTerms: "",
route: "Route1",
state: "CLD",
zipcode: "00918"
);
// Post to database
var billToApi = new CustomerBillToApi(config);
await billToApi.PutAsync(authorization, payload);
}
}
}