-
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.
liblab SDK update v1.1.0
- Loading branch information
Showing
155 changed files
with
2,528 additions
and
409 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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 |
---|---|---|
|
@@ -396,3 +396,7 @@ FodyWeavers.xsd | |
|
||
# JetBrains Rider | ||
*.sln.iml | ||
|
||
# OS generated files | ||
.DS_Store | ||
Thumbs.db |
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
4 changes: 2 additions & 2 deletions
4
Signplus/Config/SignplusConfig.cs → Alohi.Signplus/Config/SignplusConfig.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
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,16 @@ | ||
namespace Alohi.Signplus.Http.Exceptions; | ||
|
||
public class ApiException : HttpRequestException | ||
{ | ||
public HttpResponseMessage Response { get; } | ||
|
||
public ApiException(HttpResponseMessage responseMessage) | ||
: base( | ||
$"Response status code does not indicate success: {(int)responseMessage.StatusCode} ({responseMessage.StatusCode}).", | ||
null, | ||
responseMessage.StatusCode | ||
) | ||
{ | ||
Response = responseMessage; | ||
} | ||
} |
6 changes: 5 additions & 1 deletion
6
Signplus/Http/Environment.cs → Alohi.Signplus/Http/Environment.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
15 changes: 15 additions & 0 deletions
15
Alohi.Signplus/Http/Extensions/HttpResponseMessageExtensions.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,15 @@ | ||
using Alohi.Signplus.Http.Exceptions; | ||
|
||
namespace Alohi.Signplus.Http.Extensions; | ||
|
||
public static class HttpResponseMessageExtensions | ||
{ | ||
public static HttpResponseMessage EnsureSuccessfulResponse(this HttpResponseMessage response) | ||
{ | ||
if (!response.IsSuccessStatusCode) | ||
{ | ||
throw new ApiException(response); | ||
} | ||
return response; | ||
} | ||
} |
59 changes: 59 additions & 0 deletions
59
Alohi.Signplus/Http/Extensions/MultipartFormDataContentExtensions.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,59 @@ | ||
using System.Net.Http.Headers; | ||
using System.Reflection; | ||
using System.Text.Json; | ||
using System.Text.Json.Serialization; | ||
|
||
namespace Alohi.Signplus.Http.Extensions; | ||
|
||
public static class MultipartFormDataContentExtensions | ||
{ | ||
public static MultipartFormDataContent AddObject( | ||
this MultipartFormDataContent formData, | ||
object content, | ||
JsonSerializerOptions? options | ||
) | ||
{ | ||
foreach (var property in content.GetType().GetProperties()) | ||
{ | ||
var value = property.GetValue(content); | ||
var key = property.Name; | ||
var mappedKey = GetPropertyName(property); | ||
|
||
if (value is byte[] fileBytes) | ||
{ | ||
var fileContent = new ByteArrayContent(fileBytes); | ||
fileContent.Headers.ContentType = new MediaTypeHeaderValue( | ||
"application/octet-stream" | ||
); | ||
|
||
formData.Add(fileContent, mappedKey, mappedKey); | ||
} | ||
else if (value != null && !IsPrimitive(property.PropertyType)) | ||
{ | ||
var nestedContent = new MultipartFormDataContent().AddObject(value, options); | ||
formData.Add(nestedContent, mappedKey); | ||
} | ||
else | ||
{ | ||
formData.Add(new StringContent(value?.ToString() ?? string.Empty), mappedKey); | ||
} | ||
} | ||
|
||
return formData; | ||
} | ||
|
||
private static bool IsPrimitive(Type type) | ||
{ | ||
return type.IsPrimitive || type.IsValueType || type == typeof(string); | ||
} | ||
|
||
private static string GetPropertyName(PropertyInfo property) | ||
{ | ||
var jsonPropertyAttribute = property.GetCustomAttribute<JsonPropertyNameAttribute>(); | ||
if (jsonPropertyAttribute != null) | ||
{ | ||
return jsonPropertyAttribute.Name; | ||
} | ||
return property.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
namespace Alohi.Signplus.Http.Extensions; | ||
|
||
public static class UriExtensions | ||
{ | ||
public static Uri EnsureTrailingSlash(this Uri uri) | ||
{ | ||
if (uri == null) | ||
throw new ArgumentNullException(nameof(uri)); | ||
|
||
var uriString = uri.ToString(); | ||
if (!uriString.EndsWith("/")) | ||
{ | ||
uriString += "/"; | ||
} | ||
|
||
return new Uri(uriString); | ||
} | ||
} |
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
2 changes: 1 addition & 1 deletion
2
Signplus/Http/Handlers/TokenHandler.cs → Alohi.Signplus/Http/Handlers/TokenHandler.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
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
4 changes: 2 additions & 2 deletions
4
...p/Serialization/PathSerializationStyle.cs → ...p/Serialization/PathSerializationStyle.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,8 +1,8 @@ | ||
namespace Signplus.Http.Serialization; | ||
namespace Alohi.Signplus.Http.Serialization; | ||
|
||
public enum PathSerializationStyle | ||
{ | ||
Simple = SerializationStyle.Simple, | ||
Label = SerializationStyle.Label, | ||
Matrix = SerializationStyle.Matrix | ||
Matrix = SerializationStyle.Matrix, | ||
} |
4 changes: 2 additions & 2 deletions
4
.../Serialization/QuerySerializationStyle.cs → .../Serialization/QuerySerializationStyle.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,9 @@ | ||
namespace Signplus.Http.Serialization; | ||
namespace Alohi.Signplus.Http.Serialization; | ||
|
||
public enum QuerySerializationStyle | ||
{ | ||
Form = SerializationStyle.Form, | ||
SpaceDelimited = SerializationStyle.SpaceDelimited, | ||
PipeDelimited = SerializationStyle.PipeDelimited, | ||
DeepObject = SerializationStyle.DeepObject | ||
DeepObject = SerializationStyle.DeepObject, | ||
} |
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,16 @@ | ||
namespace Alohi.Signplus.Http.Exceptions; | ||
|
||
using System; | ||
using FluentValidation.Results; | ||
|
||
public class ValidationException : Exception | ||
{ | ||
public List<ValidationFailure> ValidationFailure { get; } | ||
|
||
public ValidationException(List<ValidationFailure> validationFailure) | ||
: base("Validation failed.") | ||
{ | ||
ValidationFailure = | ||
validationFailure ?? throw new ArgumentNullException(nameof(validationFailure)); | ||
} | ||
} |
Oops, something went wrong.