Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion sandbox/ConsoleAppSample/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ internal class Commands(ILogger<Commands> logger, IKaonaviClient client)
public async Task Layout(CancellationToken cancellationToken)
{
cancellationToken.ThrowIfCancellationRequested();
var memberLayout = await client.Layout.ReadMemberLayoutAsync(cancellationToken).ConfigureAwait(false);
var memberLayout = await client.Layout.ReadMemberLayoutAsync(cancellationToken: cancellationToken).ConfigureAwait(false);
logger.LogInformation("Received Layout: {memberLayout}", memberLayout);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ namespace Kaonavi.Net.Entities;
/// </summary>
/// <param name="Code">社員番号</param>
/// <param name="Content">顔写真画像(5MBまで)</param>
public record FaceImage(string Code, [property: JsonPropertyName("base64_face_image")] byte[] Content);
public record FaceImagePayload(string Code, [property: JsonPropertyName("base64_face_image")] byte[] Content);
2 changes: 1 addition & 1 deletion src/Kaonavi.NET.Core/Json/Context.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace Kaonavi.Net.Json;
[JsonSerializable(typeof(IReadOnlyList<Attachment>))]
[JsonSerializable(typeof(IReadOnlyList<DepartmentTree>))]
[JsonSerializable(typeof(IReadOnlyList<EnumOption>))]
[JsonSerializable(typeof(IReadOnlyList<FaceImage>))]
[JsonSerializable(typeof(IReadOnlyList<FaceImagePayload>))]
[JsonSerializable(typeof(IReadOnlyList<FaceImageInfo>))]
[JsonSerializable(typeof(IReadOnlyList<JsonElement>))]
[JsonSerializable(typeof(IReadOnlyList<MemberData>))]
Expand Down
5 changes: 1 addition & 4 deletions src/Kaonavi.NET.Core/KaonaviClient.Layout.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,13 @@ public partial class KaonaviClient : KaonaviClient.ILayout
/// </summary>
public interface ILayout
{
/// <inheritdoc cref="ReadMemberLayoutAsync(bool, CancellationToken)"/>
public ValueTask<MemberLayout> ReadMemberLayoutAsync(CancellationToken cancellationToken = default) => ReadMemberLayoutAsync(false, cancellationToken);

/// <summary>
/// 使用可能なメンバーのレイアウト設定情報を全て取得します。
/// <see href="https://developer.kaonavi.jp/api/v2.0/index.html#tag/%E3%83%AC%E3%82%A4%E3%82%A2%E3%82%A6%E3%83%88%E8%A8%AD%E5%AE%9A/paths/~1member_layouts/get"/>
/// </summary>
/// <param name="getCalcType">計算式パーツの取得</param>
/// <param name="cancellationToken"><inheritdoc cref="HttpClient.SendAsync(HttpRequestMessage, CancellationToken)" path="/param[@name='cancellationToken']"/></param>
public ValueTask<MemberLayout> ReadMemberLayoutAsync(bool getCalcType, CancellationToken cancellationToken = default);
public ValueTask<MemberLayout> ReadMemberLayoutAsync(bool getCalcType = false, CancellationToken cancellationToken = default);

/// <summary>
/// 使用可能なシートのレイアウト設定情報を全て取得します。
Expand Down
12 changes: 6 additions & 6 deletions src/Kaonavi.NET.Core/KaonaviClient.Member.cs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ public interface IMember
/// </param>
/// <param name="cancellationToken"><inheritdoc cref="HttpClient.SendAsync(HttpRequestMessage, CancellationToken)" path="/param[@name='cancellationToken']"/></param>
/// <returns><inheritdoc cref="TaskProgress" path="/param[@name='Id']"/></returns>
public ValueTask<int> AddFaceImageAsync(IReadOnlyList<FaceImage> payload, bool enableTrimming = true, CancellationToken cancellationToken = default);
public ValueTask<int> AddFaceImageAsync(IReadOnlyList<FaceImagePayload> payload, bool enableTrimming = true, CancellationToken cancellationToken = default);

/// <summary>
/// 指定したメンバーの顔写真を置き換えます。
Expand All @@ -161,7 +161,7 @@ public interface IMember
/// <param name="enableTrimming"><inheritdoc cref="IMember.AddFaceImageAsync" path="/param[@name='enableTrimming']"/></param>
/// <param name="cancellationToken"><inheritdoc cref="HttpClient.SendAsync(HttpRequestMessage, CancellationToken)" path="/param[@name='cancellationToken']"/></param>
/// <returns><inheritdoc cref="TaskProgress" path="/param[@name='Id']"/></returns>
public ValueTask<int> UpdateFaceImageAsync(IReadOnlyList<FaceImage> payload, bool enableTrimming = true, CancellationToken cancellationToken = default);
public ValueTask<int> UpdateFaceImageAsync(IReadOnlyList<FaceImagePayload> payload, bool enableTrimming = true, CancellationToken cancellationToken = default);
}

/// <inheritdoc/>
Expand Down Expand Up @@ -196,11 +196,11 @@ ValueTask<IReadOnlyList<FaceImageInfo>> IMember.GetFaceImageListAsync(DateOnly u
=> CallApiAsync(new(HttpMethod.Get, $"members/face_image?updated_since={updatedSince:yyyy-MM-dd}"), "member_data", Context.Default.IReadOnlyListFaceImageInfo, cancellationToken);

/// <inheritdoc/>
ValueTask<int> IMember.AddFaceImageAsync(IReadOnlyList<FaceImage> payload, bool enableTrimming, CancellationToken cancellationToken)
ValueTask<int> IMember.AddFaceImageAsync(IReadOnlyList<FaceImagePayload> payload, bool enableTrimming, CancellationToken cancellationToken)
=> CallFaceImageApiAsync(HttpMethod.Post, payload, enableTrimming, cancellationToken);

/// <inheritdoc/>
ValueTask<int> IMember.UpdateFaceImageAsync(IReadOnlyList<FaceImage> payload, bool enableTrimming, CancellationToken cancellationToken)
ValueTask<int> IMember.UpdateFaceImageAsync(IReadOnlyList<FaceImagePayload> payload, bool enableTrimming, CancellationToken cancellationToken)
=> CallFaceImageApiAsync(HttpMethod.Patch, payload, enableTrimming, cancellationToken);

/// <summary>
Expand All @@ -212,7 +212,7 @@ ValueTask<int> IMember.UpdateFaceImageAsync(IReadOnlyList<FaceImage> payload, bo
/// <param name="cancellationToken"><inheritdoc cref="HttpClient.SendAsync(HttpRequestMessage, CancellationToken)" path="/param[@name='cancellationToken']"/></param>
/// <returns><inheritdoc cref="TaskProgress" path="/param[@name='Id']"/></returns>
/// <inheritdoc cref="ObjectDisposedException.ThrowIf(bool, Type)" path="/exception"/>
private ValueTask<int> CallFaceImageApiAsync(HttpMethod method, IReadOnlyList<FaceImage> payload, bool enableTrimming, CancellationToken cancellationToken)
private ValueTask<int> CallFaceImageApiAsync(HttpMethod method, IReadOnlyList<FaceImagePayload> payload, bool enableTrimming, CancellationToken cancellationToken)
{
ObjectDisposedException.ThrowIf(_disposedValue, GetType());

Expand All @@ -221,7 +221,7 @@ private ValueTask<int> CallFaceImageApiAsync(HttpMethod method, IReadOnlyList<Fa
writer.WriteStartObject();
writer.WriteBoolean("enable_trimming"u8, enableTrimming);
writer.WritePropertyName("member_data"u8);
JsonSerializer.Serialize(writer, payload, Context.Default.IReadOnlyListFaceImage);
JsonSerializer.Serialize(writer, payload, Context.Default.IReadOnlyListFaceImagePayload);
writer.WriteEndObject();
writer.Flush();

Expand Down
21 changes: 0 additions & 21 deletions src/Kaonavi.NET.Core/PublicAPI.Shipped.txt
Original file line number Diff line number Diff line change
Expand Up @@ -88,14 +88,6 @@ Kaonavi.Net.Entities.EnumOption.Name.get -> string!
Kaonavi.Net.Entities.EnumOption.Name.init -> void
Kaonavi.Net.Entities.EnumOption.SheetName.get -> string!
Kaonavi.Net.Entities.EnumOption.SheetName.init -> void
Kaonavi.Net.Entities.FaceImage
Kaonavi.Net.Entities.FaceImage.Code.get -> string!
Kaonavi.Net.Entities.FaceImage.Code.init -> void
Kaonavi.Net.Entities.FaceImage.Content.get -> byte[]!
Kaonavi.Net.Entities.FaceImage.Content.init -> void
Kaonavi.Net.Entities.FaceImage.Deconstruct(out string! Code, out byte[]! Content) -> void
Kaonavi.Net.Entities.FaceImage.FaceImage(Kaonavi.Net.Entities.FaceImage! original) -> void
Kaonavi.Net.Entities.FaceImage.FaceImage(string! Code, byte[]! Content) -> void
Kaonavi.Net.Entities.FaceImageInfo
Kaonavi.Net.Entities.FaceImageInfo.Code.get -> string!
Kaonavi.Net.Entities.FaceImageInfo.Code.init -> void
Expand Down Expand Up @@ -366,18 +358,14 @@ Kaonavi.Net.KaonaviClient.IEnumOption.UpdateAsync(int id, System.Collections.Gen
Kaonavi.Net.KaonaviClient.ILayout
Kaonavi.Net.KaonaviClient.ILayout.ListAsync(bool getCalcType = false, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.ValueTask<System.Collections.Generic.IReadOnlyList<Kaonavi.Net.Entities.SheetLayout!>!>
Kaonavi.Net.KaonaviClient.ILayout.ReadAsync(int id, bool getCalcType = false, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.ValueTask<Kaonavi.Net.Entities.SheetLayout!>
Kaonavi.Net.KaonaviClient.ILayout.ReadMemberLayoutAsync(bool getCalcType, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.ValueTask<Kaonavi.Net.Entities.MemberLayout!>
Kaonavi.Net.KaonaviClient.ILayout.ReadMemberLayoutAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.ValueTask<Kaonavi.Net.Entities.MemberLayout!>
Kaonavi.Net.KaonaviClient.IMember
Kaonavi.Net.KaonaviClient.IMember.AddFaceImageAsync(System.Collections.Generic.IReadOnlyList<Kaonavi.Net.Entities.FaceImage!>! payload, bool enableTrimming = true, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.ValueTask<int>
Kaonavi.Net.KaonaviClient.IMember.CreateAsync(System.Collections.Generic.IReadOnlyList<Kaonavi.Net.Entities.MemberData!>! payload, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.ValueTask<int>
Kaonavi.Net.KaonaviClient.IMember.DeleteAsync(System.Collections.Generic.IReadOnlyList<string!>! codes, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.ValueTask<int>
Kaonavi.Net.KaonaviClient.IMember.GetFaceImageListAsync(System.DateOnly updatedSince, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.ValueTask<System.Collections.Generic.IReadOnlyList<Kaonavi.Net.Entities.FaceImageInfo!>!>
Kaonavi.Net.KaonaviClient.IMember.ListAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.ValueTask<System.Collections.Generic.IReadOnlyList<Kaonavi.Net.Entities.MemberData!>!>
Kaonavi.Net.KaonaviClient.IMember.OverWriteAsync(System.Collections.Generic.IReadOnlyList<Kaonavi.Net.Entities.MemberData!>! payload, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.ValueTask<int>
Kaonavi.Net.KaonaviClient.IMember.ReplaceAsync(System.Collections.Generic.IReadOnlyList<Kaonavi.Net.Entities.MemberData!>! payload, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.ValueTask<int>
Kaonavi.Net.KaonaviClient.IMember.UpdateAsync(System.Collections.Generic.IReadOnlyList<Kaonavi.Net.Entities.MemberData!>! payload, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.ValueTask<int>
Kaonavi.Net.KaonaviClient.IMember.UpdateFaceImageAsync(System.Collections.Generic.IReadOnlyList<Kaonavi.Net.Entities.FaceImage!>! payload, bool enableTrimming = true, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.ValueTask<int>
Kaonavi.Net.KaonaviClient.IRole
Kaonavi.Net.KaonaviClient.IRole.ListAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.ValueTask<System.Collections.Generic.IReadOnlyList<Kaonavi.Net.Entities.Role!>!>
Kaonavi.Net.KaonaviClient.ISheet
Expand Down Expand Up @@ -440,9 +428,6 @@ override Kaonavi.Net.Entities.EnumOption.Data.ToString() -> string!
override Kaonavi.Net.Entities.EnumOption.Equals(object? obj) -> bool
override Kaonavi.Net.Entities.EnumOption.GetHashCode() -> int
override Kaonavi.Net.Entities.EnumOption.ToString() -> string!
override Kaonavi.Net.Entities.FaceImage.Equals(object? obj) -> bool
override Kaonavi.Net.Entities.FaceImage.GetHashCode() -> int
override Kaonavi.Net.Entities.FaceImage.ToString() -> string!
override Kaonavi.Net.Entities.FaceImageInfo.Equals(object? obj) -> bool
override Kaonavi.Net.Entities.FaceImageInfo.GetHashCode() -> int
override Kaonavi.Net.Entities.FaceImageInfo.ToString() -> string!
Expand Down Expand Up @@ -511,8 +496,6 @@ static Kaonavi.Net.Entities.EnumOption.Data.operator !=(Kaonavi.Net.Entities.Enu
static Kaonavi.Net.Entities.EnumOption.Data.operator ==(Kaonavi.Net.Entities.EnumOption.Data? left, Kaonavi.Net.Entities.EnumOption.Data? right) -> bool
static Kaonavi.Net.Entities.EnumOption.operator !=(Kaonavi.Net.Entities.EnumOption? left, Kaonavi.Net.Entities.EnumOption? right) -> bool
static Kaonavi.Net.Entities.EnumOption.operator ==(Kaonavi.Net.Entities.EnumOption? left, Kaonavi.Net.Entities.EnumOption? right) -> bool
static Kaonavi.Net.Entities.FaceImage.operator !=(Kaonavi.Net.Entities.FaceImage? left, Kaonavi.Net.Entities.FaceImage? right) -> bool
static Kaonavi.Net.Entities.FaceImage.operator ==(Kaonavi.Net.Entities.FaceImage? left, Kaonavi.Net.Entities.FaceImage? right) -> bool
static Kaonavi.Net.Entities.FaceImageInfo.operator !=(Kaonavi.Net.Entities.FaceImageInfo? left, Kaonavi.Net.Entities.FaceImageInfo? right) -> bool
static Kaonavi.Net.Entities.FaceImageInfo.operator ==(Kaonavi.Net.Entities.FaceImageInfo? left, Kaonavi.Net.Entities.FaceImageInfo? right) -> bool
static Kaonavi.Net.Entities.FieldLayout.operator !=(Kaonavi.Net.Entities.FieldLayout? left, Kaonavi.Net.Entities.FieldLayout? right) -> bool
Expand Down Expand Up @@ -572,10 +555,6 @@ virtual Kaonavi.Net.Entities.EnumOption.Data.PrintMembers(System.Text.StringBuil
virtual Kaonavi.Net.Entities.EnumOption.EqualityContract.get -> System.Type!
virtual Kaonavi.Net.Entities.EnumOption.Equals(Kaonavi.Net.Entities.EnumOption? other) -> bool
virtual Kaonavi.Net.Entities.EnumOption.PrintMembers(System.Text.StringBuilder! builder) -> bool
virtual Kaonavi.Net.Entities.FaceImage.<Clone>$() -> Kaonavi.Net.Entities.FaceImage!
virtual Kaonavi.Net.Entities.FaceImage.EqualityContract.get -> System.Type!
virtual Kaonavi.Net.Entities.FaceImage.Equals(Kaonavi.Net.Entities.FaceImage? other) -> bool
virtual Kaonavi.Net.Entities.FaceImage.PrintMembers(System.Text.StringBuilder! builder) -> bool
virtual Kaonavi.Net.Entities.FaceImageInfo.<Clone>$() -> Kaonavi.Net.Entities.FaceImageInfo!
virtual Kaonavi.Net.Entities.FaceImageInfo.EqualityContract.get -> System.Type!
virtual Kaonavi.Net.Entities.FaceImageInfo.Equals(Kaonavi.Net.Entities.FaceImageInfo? other) -> bool
Expand Down
20 changes: 20 additions & 0 deletions src/Kaonavi.NET.Core/PublicAPI.Unshipped.txt
Original file line number Diff line number Diff line change
@@ -1 +1,21 @@
#nullable enable
Kaonavi.Net.Entities.FaceImagePayload
Kaonavi.Net.Entities.FaceImagePayload.Code.get -> string!
Kaonavi.Net.Entities.FaceImagePayload.Code.init -> void
Kaonavi.Net.Entities.FaceImagePayload.Content.get -> byte[]!
Kaonavi.Net.Entities.FaceImagePayload.Content.init -> void
Kaonavi.Net.Entities.FaceImagePayload.Deconstruct(out string! Code, out byte[]! Content) -> void
Kaonavi.Net.Entities.FaceImagePayload.FaceImagePayload(Kaonavi.Net.Entities.FaceImagePayload! original) -> void
Kaonavi.Net.Entities.FaceImagePayload.FaceImagePayload(string! Code, byte[]! Content) -> void
Kaonavi.Net.KaonaviClient.ILayout.ReadMemberLayoutAsync(bool getCalcType = false, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.ValueTask<Kaonavi.Net.Entities.MemberLayout!>
Kaonavi.Net.KaonaviClient.IMember.AddFaceImageAsync(System.Collections.Generic.IReadOnlyList<Kaonavi.Net.Entities.FaceImagePayload!>! payload, bool enableTrimming = true, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.ValueTask<int>
Kaonavi.Net.KaonaviClient.IMember.UpdateFaceImageAsync(System.Collections.Generic.IReadOnlyList<Kaonavi.Net.Entities.FaceImagePayload!>! payload, bool enableTrimming = true, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.ValueTask<int>
override Kaonavi.Net.Entities.FaceImagePayload.Equals(object? obj) -> bool
override Kaonavi.Net.Entities.FaceImagePayload.GetHashCode() -> int
override Kaonavi.Net.Entities.FaceImagePayload.ToString() -> string!
static Kaonavi.Net.Entities.FaceImagePayload.operator !=(Kaonavi.Net.Entities.FaceImagePayload? left, Kaonavi.Net.Entities.FaceImagePayload? right) -> bool
static Kaonavi.Net.Entities.FaceImagePayload.operator ==(Kaonavi.Net.Entities.FaceImagePayload? left, Kaonavi.Net.Entities.FaceImagePayload? right) -> bool
virtual Kaonavi.Net.Entities.FaceImagePayload.<Clone>$() -> Kaonavi.Net.Entities.FaceImagePayload!
virtual Kaonavi.Net.Entities.FaceImagePayload.EqualityContract.get -> System.Type!
virtual Kaonavi.Net.Entities.FaceImagePayload.Equals(Kaonavi.Net.Entities.FaceImagePayload? other) -> bool
virtual Kaonavi.Net.Entities.FaceImagePayload.PrintMembers(System.Text.StringBuilder! builder) -> bool
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@

namespace Kaonavi.Net.Tests.Entities;

/// <summary><see cref="FaceImage"/>の単体テスト</summary>
/// <summary><see cref="FaceImagePayload"/>の単体テスト</summary>
[TestClass, TestCategory("Entities")]
public sealed class FaceImageTest
public sealed class FaceImagePayloadTest
{
/// <summary>JSONからデシリアライズできる。</summary>
[TestMethod(DisplayName = $"{nameof(FaceImage)} > JSONからデシリアライズできる。"), TestCategory("JSON Deserialize")]
[TestMethod(DisplayName = $"{nameof(FaceImagePayload)} > JSONからデシリアライズできる。"), TestCategory("JSON Deserialize")]
public void CanDeserializeJSON()
{
// Arrange
Expand All @@ -21,7 +21,7 @@ public void CanDeserializeJSON()
""";

// Act
var faceImage = JsonSerializer.Deserialize(json, Context.Default.FaceImage);
var faceImage = JsonSerializer.Deserialize(json, Context.Default.FaceImagePayload);

// Assert
faceImage.ShouldNotBeNull().ShouldSatisfyAllConditions(
Expand Down
2 changes: 1 addition & 1 deletion test/Kaonavi.NET.Tests/KaonaviClient.Member.Test.cs
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ public async ValueTask Member_DeleteAsync_Calls_PostApi()
]
""";
/// <summary>メンバー情報 顔写真 APIのリクエストPayload</summary>
private static readonly IReadOnlyList<FaceImage> _faceImagePayload = JsonSerializer.Deserialize(FaceImagePayloadJson, Context.Default.IReadOnlyListFaceImage)!;
private static readonly IReadOnlyList<FaceImagePayload> _faceImagePayload = JsonSerializer.Deserialize(FaceImagePayloadJson, Context.Default.IReadOnlyListFaceImagePayload)!;


/// <summary>
Expand Down