Receiving
GET
using System;
using System.Threading.Tasks;
using Wdcs.Wip.Api;
using Wdcs.Wip.Client;
using Wdcs.Wip.Model;
namespace wip_project.Api
{
public partial class ReceivingService : IGetApi
{
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 api = new ReceivingOrderApi(config);
// Get all not exported orders
var apiResponse = await api.GetAsync(authorization: authorization, exportStatus: 0 );
// Get all orders from this request
foreach( var order in apiResponse.Results)
{
// Get all Details on this request
Console.WriteLine($"Order {order.PurchaseOrder} Vendor: {order.Vendor.Name}");
foreach( var detail in order.Detail)
{
Console.WriteLine($"\t Item {detail.ItemId} : {detail.ActualQuantity}/{detail.OrderedQuantity}");
}
}
Console.ReadKey();
}
}
}
PUT
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Wdcs.Wip.Api;
using Wdcs.Wip.Client;
using Wdcs.Wip.Model;
namespace wip_project.Api
{
public partial class ReceivingService : IPutApi
{
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;
var warehouseId = "01";
var orderId = "R-001";
var payload = new ReceivingOrder(
warehouseId: warehouseId,
purchaseOrder: orderId,
orderDate: DateTime.Now,
dueDate: DateTime.Now.AddDays(20),
assignedTo: "adda",
vendorId: "000001")
{
Detail = new List<ReceivingDetail>
{
new ReceivingDetail(
warehouseId: warehouseId,
purchaseOrder: orderId,
lineNumber: 1,
itemId: "A00001",
uomWeight: "LBS",
orderedWeight: 0 ,
orderedQuantity: 100,
uomId: "EACH"
)
{
}
}
};
var api = new ReceivingOrderApi(config);
await api.PutAsync(authorization, payload);
}
}
}