Skip to content

Commit

Permalink
Merge pull request #107 from VincentVrijburg/hotfix/custom-field-id
Browse files Browse the repository at this point in the history
Release version 0.13.3
  • Loading branch information
VincentVrijburg authored Jul 5, 2024
2 parents 51486fb + 55424a5 commit 8a3b1d9
Show file tree
Hide file tree
Showing 16 changed files with 62 additions and 58 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Changelog

## 0.13.3 | 2024-07-05
* Fix deserialization for id in CustomFieldAttribute entity.

## 0.13.2 | 2024-06-26
* Fix deserialization for sales_invoice in `CustomFieldSource` enum.

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System.Collections.Generic;
using System.Text.Json.Serialization;
using Moneybird.Net.Entities.Contacts;
using Moneybird.Net.Entities.CustomFields;
using Moneybird.Net.Misc;

namespace Moneybird.Net.Endpoints.Contacts.Models
Expand Down Expand Up @@ -101,7 +102,7 @@ public class ContactCreateItem
public bool? DirectDebit { get; set; }

[JsonPropertyName("custom_fields_attributes")]
public List<ContactCustomFieldsAttribute> CustomFieldsAttributes { get; set; }
public List<CustomFieldAttribute> CustomFieldsAttributes { get; set; }

[JsonPropertyName("create_event")]
public bool? CreateEvent { get; set; }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System.Collections.Generic;
using System.Text.Json.Serialization;
using Moneybird.Net.Entities.Contacts;
using Moneybird.Net.Entities.CustomFields;
using Moneybird.Net.Misc;

namespace Moneybird.Net.Endpoints.Contacts.Models
Expand Down Expand Up @@ -101,6 +102,6 @@ public class ContactUpdateItem
public bool? DirectDebit { get; set; }

[JsonPropertyName("custom_fields_attributes")]
public List<ContactCustomFieldsAttribute> CustomFieldsAttributes { get; set; }
public List<CustomFieldAttribute> CustomFieldsAttributes { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Text.Json.Serialization;
using Moneybird.Net.Entities.CustomFields;
using Moneybird.Net.Entities.SalesInvoices;

namespace Moneybird.Net.Endpoints.SalesInvoices.Models
Expand Down Expand Up @@ -70,6 +71,6 @@ public class SalesInvoiceCreate
public IReadOnlyList<SalesInvoiceCreateDetail> DetailsAttributes { get; set; }

[JsonPropertyName("custom_fields_attributes")]
public IReadOnlyList<SalesInvoiceCustomField> CustomFieldsAttributes { get; set; }
public IReadOnlyList<CustomFieldAttribute> CustomFieldsAttributes { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Text.Json.Serialization;
using Moneybird.Net.Entities.CustomFields;
using Moneybird.Net.Entities.SalesInvoices;

namespace Moneybird.Net.Endpoints.SalesInvoices.Models
Expand Down Expand Up @@ -76,6 +77,6 @@ public class SalesInvoiceUpdate
public IReadOnlyList<SalesInvoiceUpdateDetail> DetailsAttributes { get; set; }

[JsonPropertyName("custom_fields_attributes")]
public IReadOnlyList<SalesInvoiceCustomField> CustomFieldsAttributes { get; set; }
public IReadOnlyList<CustomFieldAttribute> CustomFieldsAttributes { get; set; }
}
}
3 changes: 2 additions & 1 deletion src/Moneybird.Net/Entities/Contacts/Contact.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Text.Json.Serialization;
using Moneybird.Net.Entities.CustomFields;
using Moneybird.Net.Misc;

namespace Moneybird.Net.Entities.Contacts
Expand Down Expand Up @@ -140,7 +141,7 @@ public class Contact : IMoneybirdEntity
public List<ContactNote> Notes { get; set; }

[JsonPropertyName("custom_fields")]
public List<ContactCustomFieldsAttribute> CustomFields { get; set; }
public List<CustomFieldAttribute> CustomFields { get; set; }

[JsonPropertyName("contact_people")]
public List<ContactPerson> ContactPeople { get; set; }
Expand Down

This file was deleted.

17 changes: 17 additions & 0 deletions src/Moneybird.Net/Entities/CustomFields/CustomFieldAttribute.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using System.Text.Json.Serialization;

namespace Moneybird.Net.Entities.CustomFields
{
public class CustomFieldAttribute
{
[JsonPropertyName("id")]
public string Id { get; set; }

[JsonPropertyName("name")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public string Name { get; set; }

[JsonPropertyName("value")]
public string Value { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Text.Json.Serialization;
using Moneybird.Net.Entities.Contacts;
using Moneybird.Net.Entities.CustomFields;
using Moneybird.Net.Entities.Payments;
using Moneybird.Net.Entities.SalesInvoices;

Expand Down Expand Up @@ -101,7 +102,7 @@ public class ExternalSalesInvoice : IMoneybirdEntity
public string PaymentUrl { get; set; }

[JsonPropertyName("custom_fields")]
public List<ExternalSalesInvoiceCustomField> CustomFields { get; set; }
public List<CustomFieldAttribute> CustomFields { get; set; }

[JsonPropertyName("tax_totals")]
public List<SalesInvoiceTaxTotal> TaxTotals { get; set; }
Expand Down

This file was deleted.

3 changes: 2 additions & 1 deletion src/Moneybird.Net/Entities/SalesInvoices/SalesInvoice.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Text.Json.Serialization;
using Moneybird.Net.Entities.Contacts;
using Moneybird.Net.Entities.CustomFields;
using Moneybird.Net.Entities.Payments;

namespace Moneybird.Net.Entities.SalesInvoices
Expand Down Expand Up @@ -165,7 +166,7 @@ public class SalesInvoice : IMoneybirdEntity
public string PaymentUrl { get; set; }

[JsonPropertyName("custom_fields")]
public List<SalesInvoiceCustomField> CustomFields { get; set; }
public List<CustomFieldAttribute> CustomFields { get; set; }

[JsonPropertyName("tax_totals")]
public List<SalesInvoiceTaxTotal> TaxTotals { get; set; }
Expand Down

This file was deleted.

4 changes: 2 additions & 2 deletions src/Moneybird.Net/Moneybird.Net.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<TargetFramework>netstandard2.0</TargetFramework>
<LangVersion>9</LangVersion>
<PackageId>Moneybird.Net</PackageId>
<Version>0.13.2</Version>
<Version>0.13.3</Version>
<Authors>Vincent Vrijburg</Authors>
<Description>A wrapper for the Moneybird API.</Description>
<Copyright>Copyright © Vincent Vrijburg 2021</Copyright>
Expand All @@ -13,7 +13,7 @@
<PackageTags>dotnet dotnet-core dotnet-standard client wrapper moneybird</PackageTags>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
<PackageVersion>0.13.2</PackageVersion>
<PackageVersion>0.13.3</PackageVersion>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using Moneybird.Net.Endpoints.Contacts;
using Moneybird.Net.Endpoints.Contacts.Models;
using Moneybird.Net.Entities.Contacts;
using Moneybird.Net.Entities.CustomFields;
using Moneybird.Net.Http;
using Moneybird.Net.Misc;
using Moq;
Expand Down Expand Up @@ -257,7 +258,14 @@ public async void CreateContactAsync_ByAccessToken_Returns_NewContact()
SiIdentifierTypeType = null,
CreateEvent = true,
DirectDebit = false,
CustomFieldsAttributes = null
CustomFieldsAttributes = new List<CustomFieldAttribute>
{
new ()
{
Id = "343816698630643114",
Value = "Custom field test value"
}
}
}
};

Expand All @@ -269,6 +277,7 @@ public async void CreateContactAsync_ByAccessToken_Returns_NewContact()

var contact = JsonSerializer.Deserialize<Contact>(contactJson, _config.SerializerOptions);
Assert.NotNull(contact);
Assert.NotNull(contact.CustomFields.First().Name);

var actualContact = await _contactEndpoint.CreateAsync(AdministrationId, contactCreateOptions, AccessToken);
Assert.NotNull(actualContact);
Expand Down Expand Up @@ -315,11 +324,11 @@ public async void UpdateContactAsync_ByAccessToken_Returns_UpdatedContact()
SiIdentifier = "",
SiIdentifierTypeType = null,
DirectDebit = false,
CustomFieldsAttributes = new List<ContactCustomFieldsAttribute>
CustomFieldsAttributes = new List<CustomFieldAttribute>
{
new ()
{
Id = 1,
Id = "1",
Value = "Custom contact field"
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using FluentAssertions;
using Moneybird.Net.Endpoints.SalesInvoices;
using Moneybird.Net.Endpoints.SalesInvoices.Models;
using Moneybird.Net.Entities.CustomFields;
using Moneybird.Net.Entities.SalesInvoices;
using Moneybird.Net.Http;
using Moq;
Expand Down Expand Up @@ -155,9 +156,9 @@ public async void CreateSalesInvoiceAsync_ByAccessToken_Returns_NewSalesInvoice(
Discount = 0,
CustomFieldsAttributes = new []
{
new SalesInvoiceCustomField
new CustomFieldAttribute
{
Id = 1,
Id = "1",
Value = "Custom field value"
}
}
Expand Down Expand Up @@ -227,14 +228,14 @@ public async void UpdateSalesInvoiceAsync_ByAccessToken_Returns_UpdatedSalesInvo
},
CustomFieldsAttributes = new []
{
new SalesInvoiceCustomField
new CustomFieldAttribute
{
Id = 1,
Id = "1",
Value = "Custom field value"
},
new SalesInvoiceCustomField
new CustomFieldAttribute
{
Id = 2,
Id = "2",
Value = "Second custom field value"
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,13 @@
"version": 1640619493,
"sales_invoices_url": "https://moneybird.com/322056713748350877/sales_invoices/6af2bbb86743f70b85c9371911a7ce22686d04069a3c858d6817c2cc3e5c8c4b/all",
"notes": [],
"custom_fields": [],
"custom_fields": [
{
"id": "343816698630643114",
"name": "Test field",
"value": "Custom field test value"
}
],
"contact_people": [],
"events": []
}

0 comments on commit 8a3b1d9

Please sign in to comment.