From 31f553dd8f7c764fac7a781edf2179b0c141c97b Mon Sep 17 00:00:00 2001 From: fern-api <115122769+fern-api[bot]@users.noreply.github.com> Date: Mon, 8 Jul 2024 02:28:40 +0000 Subject: [PATCH] Release 0.4.5 --- src/Mercoa.Client.sln | 20 +- .../Entity/Invoice/InvoiceClient.cs | 4 - .../Requests/EntityGetInvoicesRequest.cs | 5 - .../EntityGroup/EntityGroupClient.cs | 129 ++++++++++++ .../EntityGroup/Invoice/InvoiceClient.cs | 183 ++++++++++++++++++ .../Requests/EntityGetInvoicesRequest.cs | 88 +++++++++ .../Requests/GroupInvoiceMetricsRequest.cs | 78 ++++++++ .../Requests/EntityGroupFindRequest.cs | 11 ++ .../EntityGroupTypesClient.cs | 15 ++ .../Types/EntityGroupFindResponse.cs | 18 ++ .../Types/EntityGroupRequest.cs | 11 ++ .../Types/EntityGroupResponse.cs | 15 ++ .../Requests/UploadDocumentRequest.cs | 2 +- src/Mercoa.Client/Invoice/InvoiceClient.cs | 18 +- .../Invoice/Requests/GetAllInvoicesRequest.cs | 5 - .../Invoice/Requests/GetInvoice.cs | 9 - .../Types/InvoiceCreationRequest.cs | 2 +- .../InvoiceTypes/Types/InvoiceRequestBase.cs | 2 +- .../Types/InvoiceUpdateRequest.cs | 2 +- src/Mercoa.Client/Mercoa.Client.csproj | 2 +- src/Mercoa.Client/Mercoa.cs | 9 +- src/Mercoa.Client/Ocr/Types/OcrRequest.cs | 2 +- .../Webhooks/Types/CounterpartyWebhook.cs | 7 + .../Webhooks/Types/EntityWebhook.cs | 6 + .../Types/InvoiceStatusChangedWebhook.cs | 6 + .../Webhooks/Types/InvoiceWebhook.cs | 6 + .../Webhooks/Types/PaymentMethodWebhook.cs | 6 + 27 files changed, 605 insertions(+), 56 deletions(-) create mode 100644 src/Mercoa.Client/EntityGroup/EntityGroupClient.cs create mode 100644 src/Mercoa.Client/EntityGroup/Invoice/InvoiceClient.cs create mode 100644 src/Mercoa.Client/EntityGroup/Invoice/Requests/EntityGetInvoicesRequest.cs create mode 100644 src/Mercoa.Client/EntityGroup/Invoice/Requests/GroupInvoiceMetricsRequest.cs create mode 100644 src/Mercoa.Client/EntityGroup/Requests/EntityGroupFindRequest.cs create mode 100644 src/Mercoa.Client/EntityGroupTypes/EntityGroupTypesClient.cs create mode 100644 src/Mercoa.Client/EntityGroupTypes/Types/EntityGroupFindResponse.cs create mode 100644 src/Mercoa.Client/EntityGroupTypes/Types/EntityGroupRequest.cs create mode 100644 src/Mercoa.Client/EntityGroupTypes/Types/EntityGroupResponse.cs delete mode 100644 src/Mercoa.Client/Invoice/Requests/GetInvoice.cs diff --git a/src/Mercoa.Client.sln b/src/Mercoa.Client.sln index 16ede5e..ec1275e 100644 --- a/src/Mercoa.Client.sln +++ b/src/Mercoa.Client.sln @@ -3,9 +3,9 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 17 VisualStudioVersion = 17.0.31903.59 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mercoa.Client", "Mercoa.Client\Mercoa.Client.csproj", "{4B9D18DD-2426-4F06-90AA-AC0332BE8084}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mercoa.Client", "Mercoa.Client\Mercoa.Client.csproj", "{E45AFEF3-BB0F-4EAC-84AE-C320336989B5}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mercoa.Client.Test", "Mercoa.Client.Test\Mercoa.Client.Test.csproj", "{18880AA2-0C2F-46CD-9FF9-FEC138FC41D6}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mercoa.Client.Test", "Mercoa.Client.Test\Mercoa.Client.Test.csproj", "{158C4704-85C7-4A11-B7FB-FA0FB33AABC1}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -16,13 +16,13 @@ Global HideSolutionNode = FALSE EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {4B9D18DD-2426-4F06-90AA-AC0332BE8084}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {4B9D18DD-2426-4F06-90AA-AC0332BE8084}.Debug|Any CPU.Build.0 = Debug|Any CPU - {4B9D18DD-2426-4F06-90AA-AC0332BE8084}.Release|Any CPU.ActiveCfg = Release|Any CPU - {4B9D18DD-2426-4F06-90AA-AC0332BE8084}.Release|Any CPU.Build.0 = Release|Any CPU - {18880AA2-0C2F-46CD-9FF9-FEC138FC41D6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {18880AA2-0C2F-46CD-9FF9-FEC138FC41D6}.Debug|Any CPU.Build.0 = Debug|Any CPU - {18880AA2-0C2F-46CD-9FF9-FEC138FC41D6}.Release|Any CPU.ActiveCfg = Release|Any CPU - {18880AA2-0C2F-46CD-9FF9-FEC138FC41D6}.Release|Any CPU.Build.0 = Release|Any CPU + {E45AFEF3-BB0F-4EAC-84AE-C320336989B5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E45AFEF3-BB0F-4EAC-84AE-C320336989B5}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E45AFEF3-BB0F-4EAC-84AE-C320336989B5}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E45AFEF3-BB0F-4EAC-84AE-C320336989B5}.Release|Any CPU.Build.0 = Release|Any CPU + {158C4704-85C7-4A11-B7FB-FA0FB33AABC1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {158C4704-85C7-4A11-B7FB-FA0FB33AABC1}.Debug|Any CPU.Build.0 = Debug|Any CPU + {158C4704-85C7-4A11-B7FB-FA0FB33AABC1}.Release|Any CPU.ActiveCfg = Release|Any CPU + {158C4704-85C7-4A11-B7FB-FA0FB33AABC1}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection EndGlobal diff --git a/src/Mercoa.Client/Entity/Invoice/InvoiceClient.cs b/src/Mercoa.Client/Entity/Invoice/InvoiceClient.cs index 705bd7f..98a2627 100644 --- a/src/Mercoa.Client/Entity/Invoice/InvoiceClient.cs +++ b/src/Mercoa.Client/Entity/Invoice/InvoiceClient.cs @@ -85,10 +85,6 @@ public async Task FindAsync(EntityGetInvoicesRequest reques { _query["status"] = request.Status; } - if (request.IncludeFees != null) - { - _query["includeFees"] = request.IncludeFees; - } var response = await _client.MakeRequestAsync( new RawClient.ApiRequest { diff --git a/src/Mercoa.Client/Entity/Invoice/Requests/EntityGetInvoicesRequest.cs b/src/Mercoa.Client/Entity/Invoice/Requests/EntityGetInvoicesRequest.cs index 55dd1c4..d18cb2b 100644 --- a/src/Mercoa.Client/Entity/Invoice/Requests/EntityGetInvoicesRequest.cs +++ b/src/Mercoa.Client/Entity/Invoice/Requests/EntityGetInvoicesRequest.cs @@ -85,9 +85,4 @@ public class EntityGetInvoicesRequest /// Invoice status to filter on. /// public InvoiceStatus? Status { get; init; } - - /// - /// DEPRECATED. Fees are now included by default in the response. - /// - public bool? IncludeFees { get; init; } } diff --git a/src/Mercoa.Client/EntityGroup/EntityGroupClient.cs b/src/Mercoa.Client/EntityGroup/EntityGroupClient.cs new file mode 100644 index 0000000..fe11e49 --- /dev/null +++ b/src/Mercoa.Client/EntityGroup/EntityGroupClient.cs @@ -0,0 +1,129 @@ +using System.Text.Json; +using Mercoa.Client; +using Mercoa.Client.EntityGroup; + +#nullable enable + +namespace Mercoa.Client.EntityGroup; + +public class EntityGroupClient +{ + private RawClient _client; + + public EntityGroupClient(RawClient client) + { + _client = client; + Invoice = new InvoiceClient(_client); + } + + public InvoiceClient Invoice { get; } + + /// + /// Get all entity groups. If using a JWT, will return all groups the entity is part of. If using an API key, will return all groups for the organization. + /// + public async Task GetAllAsync(EntityGroupFindRequest request) + { + var _query = new Dictionary() { }; + if (request.Limit != null) + { + _query["limit"] = request.Limit; + } + if (request.StartingAfter != null) + { + _query["startingAfter"] = request.StartingAfter; + } + var response = await _client.MakeRequestAsync( + new RawClient.ApiRequest + { + Method = HttpMethod.Get, + Path = "/entityGroups", + Query = _query + } + ); + string responseBody = await response.Raw.Content.ReadAsStringAsync(); + if (response.StatusCode >= 200 && response.StatusCode < 400) + { + return JsonSerializer.Deserialize(responseBody); + } + throw new Exception(responseBody); + } + + /// + /// Create an entity group + /// + public async Task CreateAsync(EntityGroupRequest request) + { + var response = await _client.MakeRequestAsync( + new RawClient.ApiRequest + { + Method = HttpMethod.Post, + Path = "/entityGroup", + Body = request + } + ); + string responseBody = await response.Raw.Content.ReadAsStringAsync(); + if (response.StatusCode >= 200 && response.StatusCode < 400) + { + return JsonSerializer.Deserialize(responseBody); + } + throw new Exception(responseBody); + } + + /// + /// Get an entity group + /// + public async Task GetAsync(string entityGroupId) + { + var response = await _client.MakeRequestAsync( + new RawClient.ApiRequest + { + Method = HttpMethod.Get, + Path = $"/entityGroup/{entityGroupId}" + } + ); + string responseBody = await response.Raw.Content.ReadAsStringAsync(); + if (response.StatusCode >= 200 && response.StatusCode < 400) + { + return JsonSerializer.Deserialize(responseBody); + } + throw new Exception(responseBody); + } + + /// + /// Update an entity group + /// + public async Task UpdateAsync( + string entityGroupId, + EntityGroupRequest request + ) + { + var response = await _client.MakeRequestAsync( + new RawClient.ApiRequest + { + Method = HttpMethod.Post, + Path = $"/entityGroup/{entityGroupId}", + Body = request + } + ); + string responseBody = await response.Raw.Content.ReadAsStringAsync(); + if (response.StatusCode >= 200 && response.StatusCode < 400) + { + return JsonSerializer.Deserialize(responseBody); + } + throw new Exception(responseBody); + } + + /// + /// Delete an entity group + /// + public async void DeleteAsync(string entityGroupId) + { + var response = await _client.MakeRequestAsync( + new RawClient.ApiRequest + { + Method = HttpMethod.Delete, + Path = $"/entityGroup/{entityGroupId}" + } + ); + } +} diff --git a/src/Mercoa.Client/EntityGroup/Invoice/InvoiceClient.cs b/src/Mercoa.Client/EntityGroup/Invoice/InvoiceClient.cs new file mode 100644 index 0000000..43f96bc --- /dev/null +++ b/src/Mercoa.Client/EntityGroup/Invoice/InvoiceClient.cs @@ -0,0 +1,183 @@ +using System.Text.Json; +using Mercoa.Client; +using Mercoa.Client.EntityGroup; + +#nullable enable + +namespace Mercoa.Client.EntityGroup; + +public class InvoiceClient +{ + private RawClient _client; + + public InvoiceClient(RawClient client) + { + _client = client; + } + + /// + /// Get invoices for an entity group with the given filters. + /// + public async Task FindAsync(EntityGetInvoicesRequest request) + { + var _query = new Dictionary() { }; + if (request.ExcludePayables != null) + { + _query["excludePayables"] = request.ExcludePayables; + } + if (request.ExcludeReceivables != null) + { + _query["excludeReceivables"] = request.ExcludeReceivables; + } + if (request.StartDate != null) + { + _query["startDate"] = request.StartDate; + } + if (request.EndDate != null) + { + _query["endDate"] = request.EndDate; + } + if (request.OrderBy != null) + { + _query["orderBy"] = request.OrderBy; + } + if (request.OrderDirection != null) + { + _query["orderDirection"] = request.OrderDirection; + } + if (request.Limit != null) + { + _query["limit"] = request.Limit; + } + if (request.StartingAfter != null) + { + _query["startingAfter"] = request.StartingAfter; + } + if (request.Metadata != null) + { + _query["metadata"] = request.Metadata; + } + if (request.Search != null) + { + _query["search"] = request.Search; + } + if (request.PayerId != null) + { + _query["payerId"] = request.PayerId; + } + if (request.VendorId != null) + { + _query["vendorId"] = request.VendorId; + } + if (request.ApproverId != null) + { + _query["approverId"] = request.ApproverId; + } + if (request.ApproverAction != null) + { + _query["approverAction"] = request.ApproverAction; + } + if (request.InvoiceId != null) + { + _query["invoiceId"] = request.InvoiceId; + } + if (request.Status != null) + { + _query["status"] = request.Status; + } + var response = await _client.MakeRequestAsync( + new RawClient.ApiRequest + { + Method = HttpMethod.Get, + Path = "/invoices", + Query = _query + } + ); + string responseBody = await response.Raw.Content.ReadAsStringAsync(); + if (response.StatusCode >= 200 && response.StatusCode < 400) + { + return JsonSerializer.Deserialize(responseBody); + } + throw new Exception(responseBody); + } + + /// + /// Get invoice metrics for an entity group with the given filters. Invoices will be grouped by currency. If none of excludePayables, excludeReceivables, payerId, vendorId, or invoiceId status filters are provided, excludeReceivables will be set to true. + /// + public async Task> MetricsAsync( + GroupInvoiceMetricsRequest request + ) + { + var _query = new Dictionary() { }; + if (request.Search != null) + { + _query["search"] = request.Search; + } + if (request.ExcludePayables != null) + { + _query["excludePayables"] = request.ExcludePayables; + } + if (request.ExcludeReceivables != null) + { + _query["excludeReceivables"] = request.ExcludeReceivables; + } + if (request.ReturnByDate != null) + { + _query["returnByDate"] = request.ReturnByDate; + } + if (request.PayerId != null) + { + _query["payerId"] = request.PayerId; + } + if (request.VendorId != null) + { + _query["vendorId"] = request.VendorId; + } + if (request.ApproverId != null) + { + _query["approverId"] = request.ApproverId; + } + if (request.InvoiceId != null) + { + _query["invoiceId"] = request.InvoiceId; + } + if (request.Status != null) + { + _query["status"] = request.Status; + } + if (request.DueDateStart != null) + { + _query["dueDateStart"] = request.DueDateStart; + } + if (request.DueDateEnd != null) + { + _query["dueDateEnd"] = request.DueDateEnd; + } + if (request.CreatedDateStart != null) + { + _query["createdDateStart"] = request.CreatedDateStart; + } + if (request.CreatedDateEnd != null) + { + _query["createdDateEnd"] = request.CreatedDateEnd; + } + if (request.Currency != null) + { + _query["currency"] = request.Currency; + } + var response = await _client.MakeRequestAsync( + new RawClient.ApiRequest + { + Method = HttpMethod.Get, + Path = "/invoice-metrics", + Query = _query + } + ); + string responseBody = await response.Raw.Content.ReadAsStringAsync(); + if (response.StatusCode >= 200 && response.StatusCode < 400) + { + return JsonSerializer.Deserialize>(responseBody); + } + throw new Exception(responseBody); + } +} diff --git a/src/Mercoa.Client/EntityGroup/Invoice/Requests/EntityGetInvoicesRequest.cs b/src/Mercoa.Client/EntityGroup/Invoice/Requests/EntityGetInvoicesRequest.cs new file mode 100644 index 0000000..73ada03 --- /dev/null +++ b/src/Mercoa.Client/EntityGroup/Invoice/Requests/EntityGetInvoicesRequest.cs @@ -0,0 +1,88 @@ +using Mercoa.Client; + +#nullable enable + +namespace Mercoa.Client.EntityGroup; + +public class EntityGetInvoicesRequest +{ + /// + /// Return only invoices that are receivable by the entity. + /// + public bool? ExcludePayables { get; init; } + + /// + /// Return only invoices that are payable by the entity. + /// + public bool? ExcludeReceivables { get; init; } + + /// + /// Start date for invoice created on date filter. + /// + public DateTime? StartDate { get; init; } + + /// + /// End date for invoice created date filter. + /// + public DateTime? EndDate { get; init; } + + /// + /// Field to order invoices by. Defaults to CREATED_AT. + /// + public InvoiceOrderByField? OrderBy { get; init; } + + /// + /// Direction to order invoices by. Defaults to asc. + /// + public OrderDirection? OrderDirection { get; init; } + + /// + /// Number of invoices to return. Limit can range between 1 and 100, and the default is 10. + /// + public int? Limit { get; init; } + + /// + /// The ID of the invoice to start after. If not provided, the first page of invoices will be returned. + /// + public string? StartingAfter { get; init; } + + /// + /// Filter invoices by metadata. Each filter will be applied as an AND condition. Duplicate keys will be ignored. + /// + public InvoiceMetadataFilter? Metadata { get; init; } + + /// + /// Find invoices by vendor name, invoice number, or amount. Partial matches are supported. + /// + public string? Search { get; init; } + + /// + /// Filter invoices by payer ID. + /// + public string? PayerId { get; init; } + + /// + /// Filter invoices by vendor ID. + /// + public string? VendorId { get; init; } + + /// + /// Filter invoices by assigned approver user ID. + /// + public string? ApproverId { get; init; } + + /// + /// Filter invoices by approver action. Needs to be used with approverId. For example, if you want to find all invoices that have been approved by a specific user, you would use approverId and approverAction=APPROVE. + /// + public ApproverAction? ApproverAction { get; init; } + + /// + /// Filter invoices by invoice ID. + /// + public string? InvoiceId { get; init; } + + /// + /// Invoice status to filter on. + /// + public InvoiceStatus? Status { get; init; } +} diff --git a/src/Mercoa.Client/EntityGroup/Invoice/Requests/GroupInvoiceMetricsRequest.cs b/src/Mercoa.Client/EntityGroup/Invoice/Requests/GroupInvoiceMetricsRequest.cs new file mode 100644 index 0000000..69cc353 --- /dev/null +++ b/src/Mercoa.Client/EntityGroup/Invoice/Requests/GroupInvoiceMetricsRequest.cs @@ -0,0 +1,78 @@ +using Mercoa.Client; + +#nullable enable + +namespace Mercoa.Client.EntityGroup; + +public class GroupInvoiceMetricsRequest +{ + /// + /// Find invoices by vendor name, invoice number, or amount. Partial matches are supported. + /// + public string? Search { get; init; } + + /// + /// Only return invoices that are not payable by the entity. This will return only invoices that are receivable by the entity. + /// + public bool? ExcludePayables { get; init; } + + /// + /// Only return invoices that are not receivable by the entity. This will return only invoices that are payable by the entity. + /// + public bool? ExcludeReceivables { get; init; } + + /// + /// Return invoice metrics grouped by date. + /// + public InvoiceMetricsPerDateGroupBy? ReturnByDate { get; init; } + + /// + /// Filter invoices by payer ID. + /// + public string? PayerId { get; init; } + + /// + /// Filter invoices by vendor ID. + /// + public string? VendorId { get; init; } + + /// + /// Filter invoices by assigned approver user ID. + /// + public string? ApproverId { get; init; } + + /// + /// Filter invoices by invoice ID. + /// + public string? InvoiceId { get; init; } + + /// + /// Invoice status to filter on + /// + public InvoiceStatus? Status { get; init; } + + /// + /// Start date for invoice dueDate filter. + /// + public DateTime? DueDateStart { get; init; } + + /// + /// End date for invoice dueDate filter. + /// + public DateTime? DueDateEnd { get; init; } + + /// + /// Start date for invoice created on date filter. + /// + public DateTime? CreatedDateStart { get; init; } + + /// + /// End date for invoice created date filter. + /// + public DateTime? CreatedDateEnd { get; init; } + + /// + /// Currency to filter on + /// + public CurrencyCode? Currency { get; init; } +} diff --git a/src/Mercoa.Client/EntityGroup/Requests/EntityGroupFindRequest.cs b/src/Mercoa.Client/EntityGroup/Requests/EntityGroupFindRequest.cs new file mode 100644 index 0000000..10379f5 --- /dev/null +++ b/src/Mercoa.Client/EntityGroup/Requests/EntityGroupFindRequest.cs @@ -0,0 +1,11 @@ +namespace Mercoa.Client.EntityGroup; + +public class EntityGroupFindRequest +{ + /// + /// The maximum number of results to return. Defaults to 1. Max is 10. + /// + public int? Limit { get; init; } + + public string? StartingAfter { get; init; } +} diff --git a/src/Mercoa.Client/EntityGroupTypes/EntityGroupTypesClient.cs b/src/Mercoa.Client/EntityGroupTypes/EntityGroupTypesClient.cs new file mode 100644 index 0000000..902642d --- /dev/null +++ b/src/Mercoa.Client/EntityGroupTypes/EntityGroupTypesClient.cs @@ -0,0 +1,15 @@ +using Mercoa.Client; + +#nullable enable + +namespace Mercoa.Client; + +public class EntityGroupTypesClient +{ + private RawClient _client; + + public EntityGroupTypesClient(RawClient client) + { + _client = client; + } +} diff --git a/src/Mercoa.Client/EntityGroupTypes/Types/EntityGroupFindResponse.cs b/src/Mercoa.Client/EntityGroupTypes/Types/EntityGroupFindResponse.cs new file mode 100644 index 0000000..706c30c --- /dev/null +++ b/src/Mercoa.Client/EntityGroupTypes/Types/EntityGroupFindResponse.cs @@ -0,0 +1,18 @@ +using System.Text.Json.Serialization; +using Mercoa.Client; + +#nullable enable + +namespace Mercoa.Client; + +public class EntityGroupFindResponse +{ + [JsonPropertyName("count")] + public int Count { get; init; } + + [JsonPropertyName("hasMore")] + public bool HasMore { get; init; } + + [JsonPropertyName("data")] + public IEnumerable Data { get; init; } +} diff --git a/src/Mercoa.Client/EntityGroupTypes/Types/EntityGroupRequest.cs b/src/Mercoa.Client/EntityGroupTypes/Types/EntityGroupRequest.cs new file mode 100644 index 0000000..eab721b --- /dev/null +++ b/src/Mercoa.Client/EntityGroupTypes/Types/EntityGroupRequest.cs @@ -0,0 +1,11 @@ +using System.Text.Json.Serialization; + +#nullable enable + +namespace Mercoa.Client; + +public class EntityGroupRequest +{ + [JsonPropertyName("entityIds")] + public IEnumerable EntityIds { get; init; } +} diff --git a/src/Mercoa.Client/EntityGroupTypes/Types/EntityGroupResponse.cs b/src/Mercoa.Client/EntityGroupTypes/Types/EntityGroupResponse.cs new file mode 100644 index 0000000..b4f23c3 --- /dev/null +++ b/src/Mercoa.Client/EntityGroupTypes/Types/EntityGroupResponse.cs @@ -0,0 +1,15 @@ +using System.Text.Json.Serialization; +using Mercoa.Client; + +#nullable enable + +namespace Mercoa.Client; + +public class EntityGroupResponse +{ + [JsonPropertyName("id")] + public string Id { get; init; } + + [JsonPropertyName("entities")] + public IEnumerable Entities { get; init; } +} diff --git a/src/Mercoa.Client/Invoice/Document/Requests/UploadDocumentRequest.cs b/src/Mercoa.Client/Invoice/Document/Requests/UploadDocumentRequest.cs index 9060185..f840bb3 100644 --- a/src/Mercoa.Client/Invoice/Document/Requests/UploadDocumentRequest.cs +++ b/src/Mercoa.Client/Invoice/Document/Requests/UploadDocumentRequest.cs @@ -7,7 +7,7 @@ namespace Mercoa.Client.Invoice; public class UploadDocumentRequest { /// - /// Base64 encoded image or PDF of invoice document. PNG, JPG, and PDF are supported. 10MB max. + /// Base64 encoded image or PDF of invoice document. PNG, JPG, WEBP, and PDF are supported. 10MB max. /// [JsonPropertyName("document")] public string? Document { get; init; } diff --git a/src/Mercoa.Client/Invoice/InvoiceClient.cs b/src/Mercoa.Client/Invoice/InvoiceClient.cs index 759b274..09c53a9 100644 --- a/src/Mercoa.Client/Invoice/InvoiceClient.cs +++ b/src/Mercoa.Client/Invoice/InvoiceClient.cs @@ -93,10 +93,6 @@ public async Task FindAsync(GetAllInvoicesRequest request) { _query["status"] = request.Status; } - if (request.IncludeFees != null) - { - _query["includeFees"] = request.IncludeFees; - } var response = await _client.MakeRequestAsync( new RawClient.ApiRequest { @@ -131,20 +127,10 @@ public async Task CreateAsync(InvoiceCreationRequest request) throw new Exception(responseBody); } - public async Task GetAsync(string invoiceId, GetInvoice request) + public async Task GetAsync(string invoiceId) { - var _query = new Dictionary() { }; - if (request.IncludeFees != null) - { - _query["includeFees"] = request.IncludeFees; - } var response = await _client.MakeRequestAsync( - new RawClient.ApiRequest - { - Method = HttpMethod.Get, - Path = $"/invoice/{invoiceId}", - Query = _query - } + new RawClient.ApiRequest { Method = HttpMethod.Get, Path = $"/invoice/{invoiceId}" } ); string responseBody = await response.Raw.Content.ReadAsStringAsync(); if (response.StatusCode >= 200 && response.StatusCode < 400) diff --git a/src/Mercoa.Client/Invoice/Requests/GetAllInvoicesRequest.cs b/src/Mercoa.Client/Invoice/Requests/GetAllInvoicesRequest.cs index e877867..0d48cf6 100644 --- a/src/Mercoa.Client/Invoice/Requests/GetAllInvoicesRequest.cs +++ b/src/Mercoa.Client/Invoice/Requests/GetAllInvoicesRequest.cs @@ -80,9 +80,4 @@ public class GetAllInvoicesRequest /// Invoice status to filter on /// public InvoiceStatus? Status { get; init; } - - /// - /// DEPRECATED. Fees are now included by default in the response. - /// - public bool? IncludeFees { get; init; } } diff --git a/src/Mercoa.Client/Invoice/Requests/GetInvoice.cs b/src/Mercoa.Client/Invoice/Requests/GetInvoice.cs deleted file mode 100644 index 5184394..0000000 --- a/src/Mercoa.Client/Invoice/Requests/GetInvoice.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace Mercoa.Client.Invoice; - -public class GetInvoice -{ - /// - /// DEPRECATED. Fees are now included by default in the response. - /// - public bool? IncludeFees { get; init; } -} diff --git a/src/Mercoa.Client/InvoiceTypes/Types/InvoiceCreationRequest.cs b/src/Mercoa.Client/InvoiceTypes/Types/InvoiceCreationRequest.cs index d2b43b1..df22ea7 100644 --- a/src/Mercoa.Client/InvoiceTypes/Types/InvoiceCreationRequest.cs +++ b/src/Mercoa.Client/InvoiceTypes/Types/InvoiceCreationRequest.cs @@ -113,7 +113,7 @@ public class InvoiceCreationRequest public string? ForeignId { get; init; } /// - /// Base64 encoded image or PDF of invoice document. PNG, JPG, and PDF are supported. 10MB max. If the invoice already has a document, this will add a new document to the invoice. + /// Base64 encoded image or PDF of invoice document. PNG, JPG, WEBP, and PDF are supported. 10MB max. If the invoice already has a document, this will add a new document to the invoice. /// [JsonPropertyName("document")] public string? Document { get; init; } diff --git a/src/Mercoa.Client/InvoiceTypes/Types/InvoiceRequestBase.cs b/src/Mercoa.Client/InvoiceTypes/Types/InvoiceRequestBase.cs index 62633dc..3126b64 100644 --- a/src/Mercoa.Client/InvoiceTypes/Types/InvoiceRequestBase.cs +++ b/src/Mercoa.Client/InvoiceTypes/Types/InvoiceRequestBase.cs @@ -107,7 +107,7 @@ public class InvoiceRequestBase public string? ForeignId { get; init; } /// - /// Base64 encoded image or PDF of invoice document. PNG, JPG, and PDF are supported. 10MB max. If the invoice already has a document, this will add a new document to the invoice. + /// Base64 encoded image or PDF of invoice document. PNG, JPG, WEBP, and PDF are supported. 10MB max. If the invoice already has a document, this will add a new document to the invoice. /// [JsonPropertyName("document")] public string? Document { get; init; } diff --git a/src/Mercoa.Client/InvoiceTypes/Types/InvoiceUpdateRequest.cs b/src/Mercoa.Client/InvoiceTypes/Types/InvoiceUpdateRequest.cs index e0dad85..c366d40 100644 --- a/src/Mercoa.Client/InvoiceTypes/Types/InvoiceUpdateRequest.cs +++ b/src/Mercoa.Client/InvoiceTypes/Types/InvoiceUpdateRequest.cs @@ -113,7 +113,7 @@ public class InvoiceUpdateRequest public string? ForeignId { get; init; } /// - /// Base64 encoded image or PDF of invoice document. PNG, JPG, and PDF are supported. 10MB max. If the invoice already has a document, this will add a new document to the invoice. + /// Base64 encoded image or PDF of invoice document. PNG, JPG, WEBP, and PDF are supported. 10MB max. If the invoice already has a document, this will add a new document to the invoice. /// [JsonPropertyName("document")] public string? Document { get; init; } diff --git a/src/Mercoa.Client/Mercoa.Client.csproj b/src/Mercoa.Client/Mercoa.Client.csproj index 634c267..26461e9 100644 --- a/src/Mercoa.Client/Mercoa.Client.csproj +++ b/src/Mercoa.Client/Mercoa.Client.csproj @@ -5,7 +5,7 @@ net8.0;net7.0;net6.0;net5.0;net4.0 enable false - 0.4.4 + 0.4.5 README.md https://github.com/mercoa-finance/csharp diff --git a/src/Mercoa.Client/Mercoa.cs b/src/Mercoa.Client/Mercoa.cs index e02290c..97c3736 100644 --- a/src/Mercoa.Client/Mercoa.cs +++ b/src/Mercoa.Client/Mercoa.cs @@ -1,5 +1,6 @@ using Mercoa.Client; using Mercoa.Client.Entity; +using Mercoa.Client.EntityGroup; using Mercoa.Client.Invoice; using Mercoa.Client.Organization; @@ -19,10 +20,11 @@ public Mercoa(string token = null, ClientOptions clientOptions = null) { "Authorization", $"Bearer {token}" }, { "X-Fern-Language", "C#" }, { "X-Fern-SDK-Name", "Mercoa.Client" }, - { "X-Fern-SDK-Version", "0.4.4" }, + { "X-Fern-SDK-Version", "0.4.5" }, }, clientOptions ?? new ClientOptions() ); + EntityGroup = new EntityGroupClient(_client); Entity = new EntityClient(_client); Invoice = new InvoiceClient(_client); Organization = new OrganizationClient(_client); @@ -30,6 +32,7 @@ public Mercoa(string token = null, ClientOptions clientOptions = null) Commons = new CommonsClient(_client); CustomPaymentMethodSchema = new CustomPaymentMethodSchemaClient(_client); EmailLogTypes = new EmailLogTypesClient(_client); + EntityGroupTypes = new EntityGroupTypesClient(_client); EntityTypes = new EntityTypesClient(_client); Fees = new FeesClient(_client); InvoiceTypes = new InvoiceTypesClient(_client); @@ -39,6 +42,8 @@ public Mercoa(string token = null, ClientOptions clientOptions = null) Webhooks = new WebhooksClient(_client); } + public EntityGroupClient EntityGroup { get; } + public EntityClient Entity { get; } public InvoiceClient Invoice { get; } @@ -53,6 +58,8 @@ public Mercoa(string token = null, ClientOptions clientOptions = null) public EmailLogTypesClient EmailLogTypes { get; } + public EntityGroupTypesClient EntityGroupTypes { get; } + public EntityTypesClient EntityTypes { get; } public FeesClient Fees { get; } diff --git a/src/Mercoa.Client/Ocr/Types/OcrRequest.cs b/src/Mercoa.Client/Ocr/Types/OcrRequest.cs index 238ca16..babb0a1 100644 --- a/src/Mercoa.Client/Ocr/Types/OcrRequest.cs +++ b/src/Mercoa.Client/Ocr/Types/OcrRequest.cs @@ -14,7 +14,7 @@ public class OcrRequest public string MimeType { get; init; } /// - /// Base64 encoded image or PDF. PNG, JPG, and PDF are supported. 10MB max. + /// Base64 encoded image or PDF. PNG, JPG, WEBP, and PDF are supported. 10MB max. /// [JsonPropertyName("image")] public string Image { get; init; } diff --git a/src/Mercoa.Client/Webhooks/Types/CounterpartyWebhook.cs b/src/Mercoa.Client/Webhooks/Types/CounterpartyWebhook.cs index c996fad..1532182 100644 --- a/src/Mercoa.Client/Webhooks/Types/CounterpartyWebhook.cs +++ b/src/Mercoa.Client/Webhooks/Types/CounterpartyWebhook.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using Mercoa.Client; #nullable enable @@ -14,4 +15,10 @@ public class CounterpartyWebhook [JsonPropertyName("payorId")] public string PayorId { get; init; } + + /// + /// User who initiated the change. + /// + [JsonPropertyName("user")] + public EntityUserResponse? User { get; init; } } diff --git a/src/Mercoa.Client/Webhooks/Types/EntityWebhook.cs b/src/Mercoa.Client/Webhooks/Types/EntityWebhook.cs index 3bbe6f7..fc39c5f 100644 --- a/src/Mercoa.Client/Webhooks/Types/EntityWebhook.cs +++ b/src/Mercoa.Client/Webhooks/Types/EntityWebhook.cs @@ -12,4 +12,10 @@ public class EntityWebhook [JsonPropertyName("entity")] public EntityResponse Entity { get; init; } + + /// + /// User who initiated the change. + /// + [JsonPropertyName("user")] + public EntityUserResponse? User { get; init; } } diff --git a/src/Mercoa.Client/Webhooks/Types/InvoiceStatusChangedWebhook.cs b/src/Mercoa.Client/Webhooks/Types/InvoiceStatusChangedWebhook.cs index 6dcc23f..97ebfe1 100644 --- a/src/Mercoa.Client/Webhooks/Types/InvoiceStatusChangedWebhook.cs +++ b/src/Mercoa.Client/Webhooks/Types/InvoiceStatusChangedWebhook.cs @@ -18,4 +18,10 @@ public class InvoiceStatusChangedWebhook [JsonPropertyName("invoice")] public InvoiceResponse Invoice { get; init; } + + /// + /// User who initiated the change. + /// + [JsonPropertyName("user")] + public EntityUserResponse? User { get; init; } } diff --git a/src/Mercoa.Client/Webhooks/Types/InvoiceWebhook.cs b/src/Mercoa.Client/Webhooks/Types/InvoiceWebhook.cs index 5d1c3ce..8750e10 100644 --- a/src/Mercoa.Client/Webhooks/Types/InvoiceWebhook.cs +++ b/src/Mercoa.Client/Webhooks/Types/InvoiceWebhook.cs @@ -12,4 +12,10 @@ public class InvoiceWebhook [JsonPropertyName("invoice")] public InvoiceResponse Invoice { get; init; } + + /// + /// User who initiated the change. + /// + [JsonPropertyName("user")] + public EntityUserResponse? User { get; init; } } diff --git a/src/Mercoa.Client/Webhooks/Types/PaymentMethodWebhook.cs b/src/Mercoa.Client/Webhooks/Types/PaymentMethodWebhook.cs index 497df9e..136350c 100644 --- a/src/Mercoa.Client/Webhooks/Types/PaymentMethodWebhook.cs +++ b/src/Mercoa.Client/Webhooks/Types/PaymentMethodWebhook.cs @@ -18,4 +18,10 @@ public class PaymentMethodWebhook [JsonPropertyName("entity")] public EntityResponse Entity { get; init; } + + /// + /// User who initiated the change. + /// + [JsonPropertyName("user")] + public EntityUserResponse? User { get; init; } }