static void Main(string[] args) { // Ongoing WMS is a Warehouse Management System based in Sweden. // This file demonstrates one way of integrating with the WMS' REST API. // For more information, please see: // https://developer.ongoingwarehouse.com/REST/v1/index.html // https://www.ongoingwarehouse.com/ // These are the credentials and other information which are required to connect to the API. // Ask the warehouse to generate them for you - https://docs.ongoingwarehouse.com/Manuals/API-Access var userName = "******"; var password = "******"; var baseUrl = "https://api.ongoingsystems.se/apidemo/"; var goodsOwnerId = 162; // Set up all the client objects. var client = new System.Net.Http.HttpClient(); client.DefaultRequestHeaders.Add("Authorization", "Basic " + Convert.ToBase64String(Encoding.UTF8.GetBytes($"{userName}:{password}"))); var articlesClient = new ArticlesClient(client) { BaseUrl = baseUrl }; var ordersClient = new OrdersClient(client) { BaseUrl = baseUrl }; var purchaseOrderClient = new PurchaseOrdersClient(client) { BaseUrl = baseUrl }; var inventoryAdjustmentsClient = new InventoryAdjustmentsClient(client) { BaseUrl = baseUrl }; var transporterContractsClient = new TransporterContractsClient(client) { BaseUrl = baseUrl }; // Run the tests. TestArticles(goodsOwnerId, articlesClient); TestOrders(goodsOwnerId, ordersClient); TestPurchaseOrders(goodsOwnerId, purchaseOrderClient); TestInventoryAdjustments(goodsOwnerId, inventoryAdjustmentsClient); TestTransporterContracts(goodsOwnerId, transporterContractsClient); Console.WriteLine("Press Enter to exit."); Console.Read(); }
private static void TestArticles(int goodsOwnerId, ArticlesClient articlesClient) { Console.WriteLine("Running article examples..."); Console.WriteLine(""); // Define a new article. var article = new PostArticleModel() { GoodsOwnerId = goodsOwnerId, ArticleNumber = "12345", ArticleName = "Test article", Weight = 1.7m, // Unit is kilograms. BarCodeInfo = new PostArticleBarCodeInfo() { BarCode = "733123" } }; // Send the new article to the warehouse, thus creating it. var createResponse = articlesClient.Put3(article); // Update the barcode to something else. article.BarCodeInfo.BarCode = "507543"; var updateResponse = articlesClient.Put3(article); // You may query for articles using various ways. The response will include various article data (including stock balances). var getArticleByArticleSystemId = articlesClient.Get(createResponse.ArticleSystemId.Value); var getArticleByArticleNumber = articlesClient.GetAll(goodsOwnerId, "12345", null, null); // If you have a file (such as an image), you may attach it to the article. var imagePath = @"C:\WMS\12345.png"; if (System.IO.File.Exists(imagePath)) { var fileBase64 = Convert.ToBase64String(System.IO.File.ReadAllBytes(imagePath)); var file = new PostFileModel() { FileName = "12345.png", FileDataBase64 = fileBase64, MimeType = "image/png" }; articlesClient.Post(createResponse.ArticleSystemId.Value, file); } }
public async static Task UpdateArticles() { ArticlesClient articles = new ArticlesClient(); await articles.UpdateAsync(); }