Item
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 ItemService : IGetApi
{
/// <summary>
/// Calls Item Api
/// </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;
var apiResponse = await new ItemsApi(config).GetAsync(authorization);
foreach (var item in apiResponse.Results)
{
Console.WriteLine(String.Format("Item: {0} - Description {1}", item.ItemId, item.Description));
}
}
}
}
POST
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 ItemService : IPostApi
{
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;
var payload = new Item(
warehouseId: "01",
itemId: "I0001",
description: "Item by Each",
usesSerial: 0,
uomType: 0,
upc: "I0001",
expirationOffset: 0,
fullPalletQty: 50,
uomDesc: "EACH",
weight: 0,
minWeight: 0,
maxWeight: 0,
minAvailableQuantity: 100,
minAvailableWeight: 0,
reqLot: 0,
reqPallet: 0,
reqExpDate: 0,
reqProdDate: 0,
validExpDays: 0,
itemUnitOfMeasure:
new List<ItemUnitOfMeasure> { new ItemUnitOfMeasure(
warehouseId: "01",
itemId: "I0001",
uomId: "EACH",
eachCount: 1,
type: "A"
),
new ItemUnitOfMeasure(
warehouseId: "01",
itemId: "I0001",
uomId: "CASE",
eachCount: 12,
type: "A"
)
}
);
// Call api
var itemsApi = new ItemsApi(config);
await itemsApi.PostAsync(authorization, payload);
}
}
}
PUT
using System.Collections.Generic;
using System.Threading.Tasks;
using Wdcs.Wip.Api;
using Wdcs.Wip.Client;
using Wdcs.Wip.Model;
namespace wip_project.Api
{
partial class ItemService : 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 payload = new Item(
warehouseId: "01",
itemId: "I0001-2",
description: "Item by Each",
usesSerial: 0,
uomType: 0,
upc: "I0001",
expirationOffset: 0,
fullPalletQty: 50,
uomDesc: "EACH",
weight: 0,
minWeight: 0,
maxWeight: 0,
minAvailableQuantity: 100,
minAvailableWeight: 0,
reqLot: 0,
reqPallet: 0,
reqExpDate: 0,
reqProdDate: 0,
validExpDays: 0,
itemUnitOfMeasure:
new List<ItemUnitOfMeasure> { new ItemUnitOfMeasure(
warehouseId: "01",
itemId: "I0001-2",
uomId: "EACH",
eachCount: 1,
type: "A"
),
new ItemUnitOfMeasure(
warehouseId: "01",
itemId: "I0001-2",
uomId: "CASE",
eachCount: 12,
type: "A"
)
}
);
var itemsApi = new ItemsApi(config);
await itemsApi.PutAsync(authorization, payload);
}
}
}