Skip to content

Commit

Permalink
Release 0.4.5
Browse files Browse the repository at this point in the history
  • Loading branch information
fern-api[bot] committed Jul 8, 2024
1 parent 0cd45e1 commit 31f553d
Show file tree
Hide file tree
Showing 27 changed files with 605 additions and 56 deletions.
20 changes: 10 additions & 10 deletions src/Mercoa.Client.sln
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
4 changes: 0 additions & 4 deletions src/Mercoa.Client/Entity/Invoice/InvoiceClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,6 @@ public async Task<FindInvoiceResponse> FindAsync(EntityGetInvoicesRequest reques
{
_query["status"] = request.Status;
}
if (request.IncludeFees != null)
{
_query["includeFees"] = request.IncludeFees;
}
var response = await _client.MakeRequestAsync(
new RawClient.ApiRequest
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,4 @@ public class EntityGetInvoicesRequest
/// Invoice status to filter on.
/// </summary>
public InvoiceStatus? Status { get; init; }

/// <summary>
/// DEPRECATED. Fees are now included by default in the response.
/// </summary>
public bool? IncludeFees { get; init; }
}
129 changes: 129 additions & 0 deletions src/Mercoa.Client/EntityGroup/EntityGroupClient.cs
Original file line number Diff line number Diff line change
@@ -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; }

/// <summary>
/// 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.
/// </summary>
public async Task<EntityGroupFindResponse> GetAllAsync(EntityGroupFindRequest request)
{
var _query = new Dictionary<string, object>() { };
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<EntityGroupFindResponse>(responseBody);
}
throw new Exception(responseBody);
}

/// <summary>
/// Create an entity group
/// </summary>
public async Task<EntityGroupResponse> 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<EntityGroupResponse>(responseBody);
}
throw new Exception(responseBody);
}

/// <summary>
/// Get an entity group
/// </summary>
public async Task<EntityGroupResponse> 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<EntityGroupResponse>(responseBody);
}
throw new Exception(responseBody);
}

/// <summary>
/// Update an entity group
/// </summary>
public async Task<EntityGroupResponse> 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<EntityGroupResponse>(responseBody);
}
throw new Exception(responseBody);
}

/// <summary>
/// Delete an entity group
/// </summary>
public async void DeleteAsync(string entityGroupId)
{
var response = await _client.MakeRequestAsync(
new RawClient.ApiRequest
{
Method = HttpMethod.Delete,
Path = $"/entityGroup/{entityGroupId}"
}
);
}
}
183 changes: 183 additions & 0 deletions src/Mercoa.Client/EntityGroup/Invoice/InvoiceClient.cs
Original file line number Diff line number Diff line change
@@ -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;
}

/// <summary>
/// Get invoices for an entity group with the given filters.
/// </summary>
public async Task<FindInvoiceResponse> FindAsync(EntityGetInvoicesRequest request)
{
var _query = new Dictionary<string, object>() { };
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<FindInvoiceResponse>(responseBody);
}
throw new Exception(responseBody);
}

/// <summary>
/// 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.
/// </summary>
public async Task<IEnumerable<InvoiceMetricsResponse>> MetricsAsync(
GroupInvoiceMetricsRequest request
)
{
var _query = new Dictionary<string, object>() { };
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<IEnumerable<InvoiceMetricsResponse>>(responseBody);
}
throw new Exception(responseBody);
}
}
Loading

0 comments on commit 31f553d

Please sign in to comment.