Skip to content

Commit

Permalink
feat(work): 新增添加打卡记录接口
Browse files Browse the repository at this point in the history
  • Loading branch information
fudiwei committed Apr 9, 2024
1 parent fbb0e60 commit 01b2bc1
Show file tree
Hide file tree
Showing 5 changed files with 163 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,29 @@ public static class WechatWorkClientExecuteCgibinCheckinExtensions
return await client.SendFlurlRequestAsJsonAsync<Models.CgibinCheckinSetCheckinScheduleListResponse>(flurlReq, data: request, cancellationToken: cancellationToken).ConfigureAwait(false);
}

/// <summary>
/// <para>异步调用 [POST] /cgi-bin/checkin/add_checkin_record 接口。</para>
/// <para>
/// REF: <br/>
/// <![CDATA[ https://developer.work.weixin.qq.com/document/path/99647 ]]>
/// </para>
/// </summary>
/// <param name="client"></param>
/// <param name="request"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
public static async Task<Models.CgibinCheckinAddCheckinRecordResponse> ExecuteCgibinCheckinAddCheckinRecordAsync(this WechatWorkClient client, Models.CgibinCheckinAddCheckinRecordRequest request, CancellationToken cancellationToken = default)
{
if (client is null) throw new ArgumentNullException(nameof(client));
if (request is null) throw new ArgumentNullException(nameof(request));

IFlurlRequest flurlReq = client
.CreateFlurlRequest(request, HttpMethod.Post, "cgi-bin", "checkin", "add_checkin_record")
.SetQueryParam("access_token", request.AccessToken);

return await client.SendFlurlRequestAsJsonAsync<Models.CgibinCheckinAddCheckinRecordResponse>(flurlReq, data: request, cancellationToken: cancellationToken).ConfigureAwait(false);
}

/// <summary>
/// <para>异步调用 [POST] /cgi-bin/checkin/addcheckinuserface 接口。</para>
/// <para>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
using System.Collections.Generic;

namespace SKIT.FlurlHttpClient.Wechat.Work.Models
{
/// <summary>
/// <para>表示 [POST] /cgi-bin/checkin/add_checkin_record 接口的请求。</para>
/// </summary>
public class CgibinCheckinAddCheckinRecordRequest : WechatWorkRequest
{
public static class Types
{
public class Record
{
/// <summary>
/// 获取或设置成员账号。
/// </summary>
[Newtonsoft.Json.JsonProperty("userid")]
[System.Text.Json.Serialization.JsonPropertyName("userid")]
public string UserId { get; set; } = default!;

/// <summary>
/// 获取或设置打卡时间戳。
/// </summary>
[Newtonsoft.Json.JsonProperty("checkin_time")]
[System.Text.Json.Serialization.JsonPropertyName("checkin_time")]
public long CheckinTimestamp { get; set; }

/// <summary>
/// 获取或设置打卡地点名称。
/// </summary>
[Newtonsoft.Json.JsonProperty("location_title")]
[System.Text.Json.Serialization.JsonPropertyName("location_title")]
public string? LocationTitle { get; set; }

/// <summary>
/// 获取或设置打卡地点详情。
/// </summary>
[Newtonsoft.Json.JsonProperty("location_detail")]
[System.Text.Json.Serialization.JsonPropertyName("location_detail")]
public string? LocationDetail { get; set; }

/// <summary>
/// 获取或设置打卡地点经度。
/// </summary>
[Newtonsoft.Json.JsonProperty("lng")]
[System.Text.Json.Serialization.JsonPropertyName("lng")]
public decimal? LocationLongitude { get; set; }

/// <summary>
/// 获取或设置打卡地点纬度。
/// </summary>
[Newtonsoft.Json.JsonProperty("lat")]
[System.Text.Json.Serialization.JsonPropertyName("lat")]
public decimal? LocationLatitude { get; set; }

/// <summary>
/// 获取或设置打卡 Wi-Fi 名称。
/// </summary>
[Newtonsoft.Json.JsonProperty("wifiname")]
[System.Text.Json.Serialization.JsonPropertyName("wifiname")]
public string? WiFiName { get; set; }

/// <summary>
/// 获取或设置打卡 Wi-Fi 的 MAC 地址或 BSSID。
/// </summary>
[Newtonsoft.Json.JsonProperty("wifimac")]
[System.Text.Json.Serialization.JsonPropertyName("wifimac")]
public string? WiFiMac { get; set; }

/// <summary>
/// 获取或设置打卡设备类型。
/// </summary>
[Newtonsoft.Json.JsonProperty("device_type")]
[System.Text.Json.Serialization.JsonPropertyName("device_type")]
public int? DeviceType { get; set; }

/// <summary>
/// 获取或设置打卡设备品牌。
/// </summary>
[Newtonsoft.Json.JsonProperty("device_detail")]
[System.Text.Json.Serialization.JsonPropertyName("device_detail")]
public string? DeviceDetail { get; set; }

/// <summary>
/// 获取或设置备注。
/// </summary>
[Newtonsoft.Json.JsonProperty("notes")]
[System.Text.Json.Serialization.JsonPropertyName("notes")]
public string? Notes { get; set; }

/// <summary>
/// 获取或设置附件图片 MediaId 列表。
/// </summary>
[Newtonsoft.Json.JsonProperty("mediaids")]
[System.Text.Json.Serialization.JsonPropertyName("mediaids")]
public IList<string>? MediaIdList { get; set; }
}
}

/// <summary>
/// 获取或设置打卡记录列表。
/// </summary>
[Newtonsoft.Json.JsonProperty("records")]
[System.Text.Json.Serialization.JsonPropertyName("records")]
public IList<Types.Record> RecordList { get; set; } = new List<Types.Record>();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace SKIT.FlurlHttpClient.Wechat.Work.Models
{
/// <summary>
/// <para>表示 [POST] /cgi-bin/checkin/add_checkin_record 接口的响应。</para>
/// </summary>
public class CgibinCheckinAddCheckinRecordResponse : WechatWorkResponse
{
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ public class CgibinCheckinGetCheckinDataResponse : WechatWorkResponse
{
public static class Types
{
public class Data
public class Record
{
/// <summary>
/// 获取或设置成员账号。
Expand Down Expand Up @@ -129,11 +129,11 @@ public class Data
public string? Notes { get; set; }

/// <summary>
/// 获取或设置备注附件图片 MediaId 列表。
/// 获取或设置附件图片 MediaId 列表。
/// </summary>
[Newtonsoft.Json.JsonProperty("mediaids")]
[System.Text.Json.Serialization.JsonPropertyName("mediaids")]
public string[]? NotesMediaIdList { get; set; }
public string[]? MediaIdList { get; set; }
}
}

Expand All @@ -142,6 +142,6 @@ public class Data
/// </summary>
[Newtonsoft.Json.JsonProperty("checkindata")]
[System.Text.Json.Serialization.JsonPropertyName("checkindata")]
public Types.Data[] DataList { get; set; } = default!;
public Types.Record[] RecordList { get; set; } = default!;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"records": [
{
"userid": "userId",
"checkin_time": 1705899000,
"location_title": "1234",
"location_detail": "1234",
"mediaids": [
"mediaId"
],
"notes": "",
"device_type": 1,
"lat": 22234233,
"lng": 1233123,
"device_detail": "device_detail_test",
"wifiname": "Tencent-WiFi",
"wifimac": "a2:8b:7f:c0:27:4b"
}
]
}

0 comments on commit 01b2bc1

Please sign in to comment.