-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cf0d231
commit b00e4a7
Showing
16 changed files
with
137 additions
and
110 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
namespace Mercoa.Client.Core; | ||
|
||
public class Environments | ||
{ | ||
public static string PRODUCTION = "https://api.mercoa.com"; | ||
} |
75 changes: 75 additions & 0 deletions
75
src/Mercoa.Client/Core/JsonEnumMemberStringEnumConverter.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
using System.Reflection; | ||
using System.Runtime.Serialization; | ||
using System.Text.Json; | ||
using System.Text.Json.Serialization; | ||
|
||
namespace Mercoa.Client; | ||
|
||
#nullable enable | ||
|
||
/// <summary> | ||
/// Handles serializing C# enums into the appropriate string values. | ||
/// </summary> | ||
public class JsonEnumMemberStringEnumConverter : JsonConverterFactory | ||
{ | ||
private readonly JsonNamingPolicy? _namingPolicy; | ||
private readonly bool _allowIntegerValues; | ||
private readonly JsonStringEnumConverter _baseConverter; | ||
|
||
public JsonEnumMemberStringEnumConverter( | ||
JsonNamingPolicy? namingPolicy = null, | ||
bool allowIntegerValues = true | ||
) | ||
{ | ||
_namingPolicy = namingPolicy; | ||
_allowIntegerValues = allowIntegerValues; | ||
_baseConverter = new JsonStringEnumConverter(namingPolicy, allowIntegerValues); | ||
} | ||
|
||
public override bool CanConvert(Type typeToConvert) => _baseConverter.CanConvert(typeToConvert); | ||
|
||
public override JsonConverter CreateConverter(Type typeToConvert, JsonSerializerOptions options) | ||
{ | ||
var query = | ||
from field in typeToConvert.GetFields(BindingFlags.Public | BindingFlags.Static) | ||
let attr = field.GetCustomAttribute<EnumMemberAttribute>() | ||
where attr != null && attr.Value != null | ||
select (field.Name, attr.Value); | ||
var dictionary = query.ToDictionary(p => p.Item1, p => p.Item2); | ||
if (dictionary.Count > 0) | ||
return new JsonStringEnumConverter( | ||
new DictionaryLookupNamingPolicy(dictionary, _namingPolicy), | ||
_allowIntegerValues | ||
).CreateConverter(typeToConvert, options); | ||
else | ||
return _baseConverter.CreateConverter(typeToConvert, options); | ||
} | ||
} | ||
|
||
public class JsonNamingPolicyDecorator : JsonNamingPolicy | ||
{ | ||
readonly JsonNamingPolicy? _underlyingNamingPolicy; | ||
|
||
protected JsonNamingPolicyDecorator(JsonNamingPolicy? underlyingNamingPolicy) | ||
{ | ||
_underlyingNamingPolicy = underlyingNamingPolicy; | ||
} | ||
|
||
public override string ConvertName(string name) => | ||
_underlyingNamingPolicy?.ConvertName(name) ?? name; | ||
} | ||
|
||
internal class DictionaryLookupNamingPolicy : JsonNamingPolicyDecorator | ||
{ | ||
readonly Dictionary<string, string> dictionary; | ||
|
||
public DictionaryLookupNamingPolicy( | ||
Dictionary<string, string> dictionary, | ||
JsonNamingPolicy? underlyingNamingPolicy | ||
) | ||
: base(underlyingNamingPolicy) => | ||
this.dictionary = dictionary ?? throw new ArgumentNullException(); | ||
|
||
public override string ConvertName(string name) => | ||
dictionary.TryGetValue(name, out var value) ? value : base.ConvertName(name); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
3 changes: 3 additions & 0 deletions
3
src/Mercoa.Client/Entity/PaymentMethod/requests/CompleteMicroDepositsRequest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,12 @@ | ||
using System.Text.Json.Serialization; | ||
|
||
namespace Mercoa.Client.Entity; | ||
|
||
public class CompleteMicroDepositsRequest | ||
{ | ||
/// <summary> | ||
/// The amounts of the micro deposits in cents | ||
/// </summary> | ||
[JsonPropertyName("amounts")] | ||
public List<int> Amounts { get; init; } | ||
} |
3 changes: 3 additions & 0 deletions
3
src/Mercoa.Client/Invoice/Document/requests/UploadDocumentRequest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,12 @@ | ||
using System.Text.Json.Serialization; | ||
|
||
namespace Mercoa.Client.Invoice; | ||
|
||
public class UploadDocumentRequest | ||
{ | ||
/// <summary> | ||
/// Base64 encoded image or PDF of invoice document. PNG, JPG, and PDF are supported. 10MB max. | ||
/// </summary> | ||
[JsonPropertyName("document")] | ||
public string? Document { get; init; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 14 additions & 9 deletions
23
...Mercoa.Client/Ocr/requests/RunOcrAsync.cs → src/Mercoa.Client/Ocr/Types/OcrRequest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,31 @@ | ||
using System.Text.Json.Serialization; | ||
using Mercoa.Client; | ||
|
||
namespace Mercoa.Client; | ||
|
||
public class RunOcrAsync | ||
public class OcrRequest | ||
{ | ||
/// <summary> | ||
/// Limit OCR vendor search to a specific network | ||
/// MIME type of the image. Supported types are image/png, image/jpeg, and application/pdf. | ||
/// </summary> | ||
public VendorNetwork? VendorNetwork { get; init; } | ||
[JsonPropertyName("mimeType")] | ||
public string MimeType { get; init; } | ||
|
||
/// <summary> | ||
/// When using the Entity vendor network, specify the entity to use if. EntityId on an auth token will take precedence over this parameter. | ||
/// Base64 encoded image or PDF. PNG, JPG, and PDF are supported. 10MB max. | ||
/// </summary> | ||
public string? EntityId { get; init; } | ||
[JsonPropertyName("image")] | ||
public string Image { get; init; } | ||
|
||
/// <summary> | ||
/// MIME type of the image. Supported types are image/png, image/jpeg, and application/pdf. | ||
/// Limit OCR vendor search to a specific network | ||
/// </summary> | ||
public string MimeType { get; init; } | ||
[JsonPropertyName("vendorNetwork")] | ||
public VendorNetwork? VendorNetwork { get; init; } | ||
|
||
/// <summary> | ||
/// Base64 encoded image or PDF. PNG, JPG, and PDF are supported. 10MB max. | ||
/// When using the Entity vendor network, specify the entity to use if. EntityId on an auth token will take precedence over this parameter. | ||
/// </summary> | ||
public string Image { get; init; } | ||
[JsonPropertyName("entityId")] | ||
public string? EntityId { get; init; } | ||
} |
Oops, something went wrong.