Skip to content

Commit 73e1840

Browse files
committed
feat(microapp): 新增获取用户唯一标识接口
1 parent b45768b commit 73e1840

5 files changed

Lines changed: 88 additions & 0 deletions

File tree

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
using System;
2+
using System.Net.Http;
3+
using System.Threading;
4+
using System.Threading.Tasks;
5+
using Flurl.Http;
6+
7+
namespace SKIT.FlurlHttpClient.ByteDance.MicroApp
8+
{
9+
public static class DouyinMicroAppClientExecuteAppsAuthExtensions
10+
{
11+
/// <summary>
12+
/// <para>异步调用 [POST] /api/apps/v1/auth/get_related_id/ 接口。</para>
13+
/// <para>
14+
/// REF: <br/>
15+
/// <![CDATA[ https://developer.open-douyin.com/docs/resource/zh-CN/mini-app/develop/server/data-open/get-related-id ]]>
16+
/// </para>
17+
/// </summary>
18+
/// <param name="client"></param>
19+
/// <param name="request"></param>
20+
/// <param name="cancellationToken"></param>
21+
/// <returns></returns>
22+
public static async Task<Models.AppsAuthGetRelatedIdV1Response> ExecuteAppsAuthGetRelatedIdV1Async(this DouyinMicroAppClient client, Models.AppsAuthGetRelatedIdV1Request request, CancellationToken cancellationToken = default)
23+
{
24+
if (client is null) throw new ArgumentNullException(nameof(client));
25+
if (request is null) throw new ArgumentNullException(nameof(request));
26+
27+
IFlurlRequest flurlReq = client
28+
.CreateFlurlRequest(request, HttpMethod.Post, "api", "apps", "v1", "auth", "get_related_id/")
29+
.WithHeader("access-token", request.AccessToken);
30+
31+
return await client.SendFlurlRequestAsJsonAsync<Models.AppsAuthGetRelatedIdV1Response>(flurlReq, data: request, cancellationToken: cancellationToken).ConfigureAwait(false);
32+
}
33+
}
34+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
namespace SKIT.FlurlHttpClient.ByteDance.MicroApp.Models
2+
{
3+
/// <summary>
4+
/// <para>表示 [POST] /api/apps/v1/auth/get_related_id/ 接口的请求。</para>
5+
/// </summary>
6+
public class AppsAuthGetRelatedIdV1Request : DouyinMicroAppRequest
7+
{
8+
/// <summary>
9+
/// 获取或设置用户的 OpenId。
10+
/// </summary>
11+
[Newtonsoft.Json.JsonProperty("open_id")]
12+
[System.Text.Json.Serialization.JsonPropertyName("open_id")]
13+
public string OpenId { get; set; } = string.Empty;
14+
}
15+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
namespace SKIT.FlurlHttpClient.ByteDance.MicroApp.Models
2+
{
3+
/// <summary>
4+
/// <para>表示 [POST] /api/apps/v1/auth/get_related_id/ 接口的响应。</para>
5+
/// </summary>
6+
public class AppsAuthGetRelatedIdV1Response : DouyinMicroAppResponse
7+
{
8+
public static class Types
9+
{
10+
public class Data
11+
{
12+
/// <summary>
13+
/// 获取或设置用户在相同主体下的唯一标志。
14+
/// </summary>
15+
[Newtonsoft.Json.JsonProperty("allied_id")]
16+
[System.Text.Json.Serialization.JsonPropertyName("allied_id")]
17+
public string AlliedId { get; set; } = default!;
18+
}
19+
}
20+
21+
/// <summary>
22+
/// 获取或设置返回数据。
23+
/// </summary>
24+
[Newtonsoft.Json.JsonProperty("data")]
25+
[System.Text.Json.Serialization.JsonPropertyName("data")]
26+
public Types.Data Data { get; set; } = default!;
27+
}
28+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"open_id": "Cv4PoJXaTPn63rNu"
3+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"log_id": "202405291440576E078D8757B9",
3+
"data": {
4+
"allied_id": "ZsNCZC1dUR"
5+
},
6+
"err_no": 0,
7+
"err_msg": ""
8+
}

0 commit comments

Comments
 (0)