Skip to content

Commit 229b744

Browse files
committed
feat(microapp): 新增设置关联地区相关接口
1 parent a00d82a commit 229b744

10 files changed

Lines changed: 211 additions & 0 deletions

File tree

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
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 DouyinMicroAppClientExecuteProductExtensions
10+
{
11+
#region Activity
12+
/// <summary>
13+
/// <para>异步调用 [POST] /api/product/v1/app_region_add/ 接口。</para>
14+
/// <para>
15+
/// REF: <br/>
16+
/// <![CDATA[ https://developer.open-douyin.com/docs/resource/zh-CN/mini-app/develop/server/mount/set-distribute-city/add-bind-city ]]>
17+
/// </para>
18+
/// </summary>
19+
/// <param name="client"></param>
20+
/// <param name="request"></param>
21+
/// <param name="cancellationToken"></param>
22+
/// <returns></returns>
23+
public static async Task<Models.ProductAppRegionAddV1Response> ExecuteProductAppRegionAddV1Async(this DouyinMicroAppClient client, Models.ProductAppRegionAddV1Request request, CancellationToken cancellationToken = default)
24+
{
25+
if (client is null) throw new ArgumentNullException(nameof(client));
26+
if (request is null) throw new ArgumentNullException(nameof(request));
27+
28+
IFlurlRequest flurlReq = client
29+
.CreateFlurlRequest(request, HttpMethod.Post, "api", "product", "v1", "app_region_add/")
30+
.WithHeader("access-token", request.AccessToken);
31+
32+
return await client.SendFlurlRequestAsJsonAsync<Models.ProductAppRegionAddV1Response>(flurlReq, data: request, cancellationToken: cancellationToken).ConfigureAwait(false);
33+
}
34+
35+
/// <summary>
36+
/// <para>异步调用 [POST] /api/product/v1/app_region_modify/ 接口。</para>
37+
/// <para>
38+
/// REF: <br/>
39+
/// <![CDATA[ https://developer.open-douyin.com/docs/resource/zh-CN/mini-app/develop/server/mount/set-distribute-city/modify-bind-city ]]>
40+
/// </para>
41+
/// </summary>
42+
/// <param name="client"></param>
43+
/// <param name="request"></param>
44+
/// <param name="cancellationToken"></param>
45+
/// <returns></returns>
46+
public static async Task<Models.ProductAppRegionModifyV1Response> ExecuteProductAppRegionModifyV1Async(this DouyinMicroAppClient client, Models.ProductAppRegionModifyV1Request request, CancellationToken cancellationToken = default)
47+
{
48+
if (client is null) throw new ArgumentNullException(nameof(client));
49+
if (request is null) throw new ArgumentNullException(nameof(request));
50+
51+
IFlurlRequest flurlReq = client
52+
.CreateFlurlRequest(request, HttpMethod.Post, "api", "product", "v1", "app_region_modify/")
53+
.WithHeader("access-token", request.AccessToken);
54+
55+
return await client.SendFlurlRequestAsJsonAsync<Models.ProductAppRegionModifyV1Response>(flurlReq, data: request, cancellationToken: cancellationToken).ConfigureAwait(false);
56+
}
57+
58+
/// <summary>
59+
/// <para>异步调用 [POST] /api/product/v1/app_region_delete/ 接口。</para>
60+
/// <para>
61+
/// REF: <br/>
62+
/// <![CDATA[ https://developer.open-douyin.com/docs/resource/zh-CN/mini-app/develop/server/mount/set-distribute-city/delete-bind-city ]]>
63+
/// </para>
64+
/// </summary>
65+
/// <param name="client"></param>
66+
/// <param name="request"></param>
67+
/// <param name="cancellationToken"></param>
68+
/// <returns></returns>
69+
public static async Task<Models.ProductAppRegionDeleteV1Response> ExecuteProductAppRegionDeleteV1Async(this DouyinMicroAppClient client, Models.ProductAppRegionDeleteV1Request request, CancellationToken cancellationToken = default)
70+
{
71+
if (client is null) throw new ArgumentNullException(nameof(client));
72+
if (request is null) throw new ArgumentNullException(nameof(request));
73+
74+
IFlurlRequest flurlReq = client
75+
.CreateFlurlRequest(request, HttpMethod.Post, "api", "product", "v1", "app_region_delete/")
76+
.WithHeader("access-token", request.AccessToken);
77+
78+
return await client.SendFlurlRequestAsJsonAsync<Models.ProductAppRegionDeleteV1Response>(flurlReq, data: request, cancellationToken: cancellationToken).ConfigureAwait(false);
79+
}
80+
#endregion
81+
}
82+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
namespace SKIT.FlurlHttpClient.ByteDance.MicroApp.Models
2+
{
3+
/// <summary>
4+
/// <para>表示 [POST] /api/product/v1/app_region_add/ 接口的请求。</para>
5+
/// </summary>
6+
public class ProductAppRegionAddV1Request : DouyinMicroAppRequest
7+
{
8+
/// <summary>
9+
/// 获取或设置城市绑定归属维度。
10+
/// </summary>
11+
[Newtonsoft.Json.JsonProperty("bind_type")]
12+
[System.Text.Json.Serialization.JsonPropertyName("bind_type")]
13+
public int BindType { get; set; }
14+
15+
/// <summary>
16+
/// 获取或设置关联地区编码。
17+
/// </summary>
18+
[Newtonsoft.Json.JsonProperty("region_id")]
19+
[System.Text.Json.Serialization.JsonPropertyName("region_id")]
20+
public string RegionId { get; set; } = string.Empty;
21+
22+
/// <summary>
23+
/// 获取或设置页面路径。
24+
/// </summary>
25+
[Newtonsoft.Json.JsonProperty("path")]
26+
[System.Text.Json.Serialization.JsonPropertyName("path")]
27+
public string? PagePath { get; set; }
28+
}
29+
}
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/product/v1/app_region_add/ 接口的响应。</para>
5+
/// </summary>
6+
public class ProductAppRegionAddV1Response : DouyinMicroAppResponse
7+
{
8+
/// <summary>
9+
/// 获取或设置绑定数据的唯一记录 ID。
10+
/// </summary>
11+
[Newtonsoft.Json.JsonProperty("data_id")]
12+
[System.Text.Json.Serialization.JsonPropertyName("data_id")]
13+
public string DataId { get; set; } = default!;
14+
}
15+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
namespace SKIT.FlurlHttpClient.ByteDance.MicroApp.Models
2+
{
3+
/// <summary>
4+
/// <para>表示 [POST] /api/product/v1/app_region_delete/ 接口的请求。</para>
5+
/// </summary>
6+
public class ProductAppRegionDeleteV1Request : DouyinMicroAppRequest
7+
{
8+
/// <summary>
9+
/// 获取或设置关联地区编码。
10+
/// </summary>
11+
[Newtonsoft.Json.JsonProperty("region_id")]
12+
[System.Text.Json.Serialization.JsonPropertyName("region_id")]
13+
public string RegionId { get; set; } = string.Empty;
14+
15+
/// <summary>
16+
/// 获取或设置页面路径。
17+
/// </summary>
18+
[Newtonsoft.Json.JsonProperty("path")]
19+
[System.Text.Json.Serialization.JsonPropertyName("path")]
20+
public string? PagePath { get; set; }
21+
}
22+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
namespace SKIT.FlurlHttpClient.ByteDance.MicroApp.Models
2+
{
3+
/// <summary>
4+
/// <para>表示 [POST] /api/product/v1/app_region_delete/ 接口的响应。</para>
5+
/// </summary>
6+
public class ProductAppRegionDeleteV1Response : DouyinMicroAppResponse
7+
{
8+
}
9+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
namespace SKIT.FlurlHttpClient.ByteDance.MicroApp.Models
2+
{
3+
/// <summary>
4+
/// <para>表示 [POST] /api/product/v1/app_region_modify/ 接口的请求。</para>
5+
/// </summary>
6+
public class ProductAppRegionModifyV1Request : DouyinMicroAppRequest
7+
{
8+
/// <summary>
9+
/// 获取或设置原关联地区编码。
10+
/// </summary>
11+
[Newtonsoft.Json.JsonProperty("origin_region")]
12+
[System.Text.Json.Serialization.JsonPropertyName("origin_region")]
13+
public string OriginRegionId { get; set; } = string.Empty;
14+
15+
/// <summary>
16+
/// 获取或设置新关联地区编码。
17+
/// </summary>
18+
[Newtonsoft.Json.JsonProperty("current_region")]
19+
[System.Text.Json.Serialization.JsonPropertyName("current_region")]
20+
public string CurrentRegionId { get; set; } = string.Empty;
21+
22+
/// <summary>
23+
/// 获取或设置页面路径。
24+
/// </summary>
25+
[Newtonsoft.Json.JsonProperty("path")]
26+
[System.Text.Json.Serialization.JsonPropertyName("path")]
27+
public string? PagePath { get; set; }
28+
}
29+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
namespace SKIT.FlurlHttpClient.ByteDance.MicroApp.Models
2+
{
3+
/// <summary>
4+
/// <para>表示 [POST] /api/product/v1/app_region_modify/ 接口的响应。</para>
5+
/// </summary>
6+
public class ProductAppRegionModifyV1Response : DouyinMicroAppResponse
7+
{
8+
}
9+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"bind_type": 2,
3+
"region_id": "130400",
4+
"path": "page/test/index"
5+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"err_no": 0,
3+
"data_id": "region_7276042845767827500",
4+
"err_msg": "成功",
5+
"log_id": "02169414664986000000000000000000000ffff0a706f5dd63726"
6+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"origin_region": "440300",
3+
"current_region": "440400",
4+
"path": "page/path/index"
5+
}

0 commit comments

Comments
 (0)