public async Task UpdateSupplierInvoiceExternalUrlConnectionTest()
        {
            var id            = 1;
            var createdEntity = await CreateEntity(id);

            var request = new FortnoxApiRequest(this.connectionSettings.AccessToken, this.connectionSettings.ClientSecret);
            var supplierInvoiceExternalURLConnection = new SupplierInvoiceExternalURLConnection
            {
                Id = createdEntity.Id,
                SupplierInvoiceNumber = id,
                ExternalURLConnection = "http://changed.com"
            };

            var updatedSupplierInvoiceExternalURLConnection = await SupplierInvoiceExternalURLConnectionsService
                                                              .UpdateSupplierInvoiceExternalURLConnectionsAsync(
                request,
                supplierInvoiceExternalURLConnection
                );

            await DeleteEntity(createdEntity.Id);

            Assert.AreEqual("http://changed.com", updatedSupplierInvoiceExternalURLConnection.ExternalURLConnection);
            Assert.AreEqual(createdEntity.Id, updatedSupplierInvoiceExternalURLConnection.Id);
            Assert.AreEqual(id, updatedSupplierInvoiceExternalURLConnection.SupplierInvoiceNumber);
        }
        public static async Task <SupplierInvoiceExternalURLConnection> UpdateSupplierInvoiceExternalURLConnectionsAsync(
            FortnoxApiRequest request,
            SupplierInvoiceExternalURLConnection supplierInvoiceExternalURLConnection)
        {
            var apiRequest = new FortnoxApiClientRequest <
                SingleResource <SupplierInvoiceExternalURLConnection>
                >(
                HttpMethod.Put,
                request.AccessToken,
                request.ClientSecret,
                $"{ApiEndpoints.SupplierInvoiceExternalURLConnections}/{supplierInvoiceExternalURLConnection.Id}/")
            {
                Data = new SingleResource <SupplierInvoiceExternalURLConnection>
                {
                    Data = supplierInvoiceExternalURLConnection
                }
            };

            return((await FortnoxAPIClient.CallAsync(apiRequest)).Data);
        }
        public void Test_SupplierInvoiceExternalURLConnection_CRUD()
        {
            #region Arrange
            var tmpSupplier = new SupplierConnector().Create(new Supplier()
            {
                Name = "TmpSupplier"
            });
            var tmpArticle = new ArticleConnector().Create(new Article()
            {
                Description = "TmpArticle", PurchasePrice = 100
            });
            var tmpSpplierInvoice = new SupplierInvoiceConnector().Create(new SupplierInvoice()
            {
                SupplierNumber      = tmpSupplier.SupplierNumber,
                Comments            = "InvoiceComments",
                InvoiceDate         = new DateTime(2020, 1, 1),
                DueDate             = new DateTime(2020, 2, 1),
                SalesType           = SalesType.Stock,
                OCR                 = "123456789",
                Total               = 5000,
                SupplierInvoiceRows = new List <SupplierInvoiceRow>()
                {
                    new SupplierInvoiceRow()
                    {
                        ArticleNumber = tmpArticle.ArticleNumber, Quantity = 10, Price = 100
                    },
                    new SupplierInvoiceRow()
                    {
                        ArticleNumber = tmpArticle.ArticleNumber, Quantity = 20, Price = 100
                    },
                    new SupplierInvoiceRow()
                    {
                        ArticleNumber = tmpArticle.ArticleNumber, Quantity = 20, Price = 100
                    }
                }
            });
            #endregion Arrange

            ISupplierInvoiceExternalURLConnectionConnector connector = new SupplierInvoiceExternalURLConnectionConnector();

            #region CREATE
            var newSupplierInvoiceExternalURLConnection = new SupplierInvoiceExternalURLConnection()
            {
                SupplierInvoiceNumber = (int?)tmpSpplierInvoice.GivenNumber,
                ExternalURLConnection = @"http://example.com/image.jpg"
            };

            var createdSupplierInvoiceExternalURLConnection = connector.Create(newSupplierInvoiceExternalURLConnection);
            MyAssert.HasNoError(connector);
            Assert.AreEqual("http://example.com/image.jpg", createdSupplierInvoiceExternalURLConnection.ExternalURLConnection);

            #endregion CREATE

            #region UPDATE

            createdSupplierInvoiceExternalURLConnection.ExternalURLConnection = "http://example.com/image.png";

            var updatedSupplierInvoiceExternalURLConnection = connector.Update(createdSupplierInvoiceExternalURLConnection);
            MyAssert.HasNoError(connector);
            Assert.AreEqual("http://example.com/image.png", updatedSupplierInvoiceExternalURLConnection.ExternalURLConnection);

            #endregion UPDATE

            #region READ / GET

            var retrievedSupplierInvoiceExternalURLConnection = connector.Get(createdSupplierInvoiceExternalURLConnection.Id);
            MyAssert.HasNoError(connector);
            Assert.AreEqual("http://example.com/image.png", retrievedSupplierInvoiceExternalURLConnection.ExternalURLConnection);

            #endregion READ / GET

            #region DELETE

            connector.Delete(createdSupplierInvoiceExternalURLConnection.Id);
            MyAssert.HasNoError(connector);

            retrievedSupplierInvoiceExternalURLConnection = connector.Get(createdSupplierInvoiceExternalURLConnection.Id);
            Assert.AreEqual(null, retrievedSupplierInvoiceExternalURLConnection, "Entity still exists after Delete!");

            #endregion DELETE

            #region Delete arranged resources
            new ArticleConnector().Delete(tmpArticle.ArticleNumber);
            new SupplierConnector().Delete(tmpSupplier.SupplierNumber);
            #endregion Delete arranged resources
        }
    public async Task Test_SupplierInvoiceExternalURLConnection_CRUD()
    {
        #region Arrange
        var tmpSupplier = await FortnoxClient.SupplierConnector.CreateAsync(new Supplier()
        {
            Name = "TmpSupplier"
        });

        var tmpArticle = await FortnoxClient.ArticleConnector.CreateAsync(new Article()
        {
            Description = "TmpArticle", PurchasePrice = 100
        });

        var tmpSpplierInvoice = await FortnoxClient.SupplierInvoiceConnector.CreateAsync(new SupplierInvoice()
        {
            SupplierNumber      = tmpSupplier.SupplierNumber,
            Comments            = "InvoiceComments",
            InvoiceDate         = new DateTime(2020, 1, 1),
            DueDate             = new DateTime(2020, 2, 1),
            SalesType           = SalesType.Stock,
            OCR                 = "123456789",
            Total               = 5000,
            SupplierInvoiceRows = new List <SupplierInvoiceRow>()
            {
                new SupplierInvoiceRow()
                {
                    ArticleNumber = tmpArticle.ArticleNumber, Quantity = 10, Price = 100
                },
                new SupplierInvoiceRow()
                {
                    ArticleNumber = tmpArticle.ArticleNumber, Quantity = 20, Price = 100
                },
                new SupplierInvoiceRow()
                {
                    ArticleNumber = tmpArticle.ArticleNumber, Quantity = 20, Price = 100
                }
            }
        });

        #endregion Arrange

        var connector = FortnoxClient.SupplierInvoiceExternalURLConnectionConnector;

        #region CREATE
        var newSupplierInvoiceExternalURLConnection = new SupplierInvoiceExternalURLConnection()
        {
            SupplierInvoiceNumber = (int?)tmpSpplierInvoice.GivenNumber,
            ExternalURLConnection = @"http://example.com/image.jpg"
        };

        var createdSupplierInvoiceExternalURLConnection = await connector.CreateAsync(newSupplierInvoiceExternalURLConnection);

        Assert.AreEqual("http://example.com/image.jpg", createdSupplierInvoiceExternalURLConnection.ExternalURLConnection);

        #endregion CREATE

        #region UPDATE

        createdSupplierInvoiceExternalURLConnection.ExternalURLConnection = "http://example.com/image.png";

        var updatedSupplierInvoiceExternalURLConnection = await connector.UpdateAsync(createdSupplierInvoiceExternalURLConnection);

        Assert.AreEqual("http://example.com/image.png", updatedSupplierInvoiceExternalURLConnection.ExternalURLConnection);

        #endregion UPDATE

        #region READ / GET

        var retrievedSupplierInvoiceExternalURLConnection = await connector.GetAsync(createdSupplierInvoiceExternalURLConnection.Id);

        Assert.AreEqual("http://example.com/image.png", retrievedSupplierInvoiceExternalURLConnection.ExternalURLConnection);

        #endregion READ / GET

        #region DELETE

        await connector.DeleteAsync(createdSupplierInvoiceExternalURLConnection.Id);

        await Assert.ThrowsExceptionAsync <FortnoxApiException>(
            async() => await connector.GetAsync(createdSupplierInvoiceExternalURLConnection.Id),
            "Entity still exists after Delete!");

        #endregion DELETE

        #region Delete arranged resources
        await FortnoxClient.SupplierInvoiceConnector.CancelAsync(tmpSpplierInvoice.GivenNumber);

        await FortnoxClient.ArticleConnector.DeleteAsync(tmpArticle.ArticleNumber);

        await FortnoxClient.SupplierConnector.DeleteAsync(tmpSupplier.SupplierNumber);

        #endregion Delete arranged resources
    }