private static void TestPurchaseOrders(int goodsOwnerId, PurchaseOrdersClient purchaseOrdersClient)
        {
            Console.WriteLine("Running purchase order examples...");
            Console.WriteLine("");

            var purchaseOrderNumber = "PO123"; // A unique number for the purchase order.

            // Define a new purchase order.
            var purchaseOrder = new PostPurchaseOrderModel()
            {
                GoodsOwnerId        = goodsOwnerId,
                PurchaseOrderNumber = purchaseOrderNumber,
                InDate             = new DateTimeOffset(new DateTime(2019, 11, 1)), // Expected in date.
                PurchaseOrderLines = new List <PostPurchaseOrderLine>()
                {
                    new PostPurchaseOrderLine()
                    {
                        RowNumber = "PORow1", ArticleNumber = "1234", NumberOfItems = 10
                    },                                                                                          // Each purchase order line must have a unique row number.
                    new PostPurchaseOrderLine()
                    {
                        RowNumber = "PORow2", ArticleNumber = "7897", NumberOfItems = 25
                    },
                }
            };

            // Send the new purchase order to the warehouse, thus creating it.
            var createResponse = purchaseOrdersClient.Put2(purchaseOrder);

            // If we send in the same purchase order number again, the system will try to update the order.
            // It is possible to update a purchase order as long as the warehouse has not started working on it.
            purchaseOrder.PurchaseOrderLines.Add(new PostPurchaseOrderLine()
            {
                RowNumber = "PORow3", ArticleNumber = "5943", NumberOfItems = 17
            });
            var updateResponse = purchaseOrdersClient.Put2(purchaseOrder);

            // You may query for purchase orders using various ways.
            // For instance using purchaseOrderId:
            var getPurchaseOrderByPurchaseOrderId = purchaseOrdersClient.Get(createResponse.PurchaseOrderId.Value);

            // Or by purchase order number:
            var getPurchaseOrderByPurchaseOrderNumber = purchaseOrdersClient.GetAll(goodsOwnerId, purchaseOrderNumber, null, null, null, null, null, null, null);

            // Or get all orders which have been received during a period:
            var from = new DateTimeOffset(new DateTime(2019, 11, 1, 12, 0, 0));
            var to   = new DateTimeOffset(new DateTime(2019, 11, 1, 13, 0, 0));
            var getPurchaseOrdersByReceiveTime = purchaseOrdersClient.GetAll(goodsOwnerId, null, from, to, null, null, null, null, null);

            foreach (var receivedPurchaseOrder in getPurchaseOrdersByReceiveTime)
            {
                // Handle "receivedPurchaseOrder" somehow.
            }
        }
        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();
        }