Skip to content

Commit

Permalink
feat(microapp): 新增流量主 v2 接口
Browse files Browse the repository at this point in the history
  • Loading branch information
fudiwei committed Mar 8, 2024
1 parent dca8d9e commit d2535b2
Show file tree
Hide file tree
Showing 77 changed files with 425 additions and 16 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
using System;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
using Flurl.Http;

namespace SKIT.FlurlHttpClient.ByteDance.MicroApp
{
public static class DouyinMicroAppClientExecuteAppsAdPlacementExtensions
{
/// <summary>
/// <para>异步调用 [GET] /apps/v1/ad_placement/query/ 接口。</para>
/// <para>
/// REF: <br/>
/// <![CDATA[ https://developer.open-douyin.com/docs/resource/zh-CN/mini-app/develop/server/traffic-permission/query-ad-placement-list ]]>
/// </para>
/// </summary>
/// <param name="client"></param>
/// <param name="request"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
public static async Task<Models.AppsAdPlacementQueryV1Response> ExecuteAppsAdPlacementQueryV1Async(this DouyinMicroAppClient client, Models.AppsAdPlacementQueryV1Request 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.Get, "apps", "v1", "ad_placement", "query", "")
.WithHeader("access-token", request.AccessToken);

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

/// <summary>
/// <para>异步调用 [POST] /apps/v1/ad_placement/add/ 接口。</para>
/// <para>
/// REF: <br/>
/// <![CDATA[ https://developer.open-douyin.com/docs/resource/zh-CN/mini-app/develop/server/traffic-permission/add-ad-placement ]]>
/// </para>
/// </summary>
/// <param name="client"></param>
/// <param name="request"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
public static async Task<Models.AppsAdPlacementAddV1Response> ExecuteAppsAdPlacementAddV1Async(this DouyinMicroAppClient client, Models.AppsAdPlacementAddV1Request 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, "apps", "v1", "ad_placement", "add", "")
.WithHeader("access-token", request.AccessToken);

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

/// <summary>
/// <para>异步调用 [POST] /apps/v1/ad_placement/update/ 接口。</para>
/// <para>
/// REF: <br/>
/// <![CDATA[ https://developer.open-douyin.com/docs/resource/zh-CN/mini-app/develop/server/traffic-permission/update-ad-placement-status ]]>
/// </para>
/// </summary>
/// <param name="client"></param>
/// <param name="request"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
public static async Task<Models.AppsAdPlacementUpdateV1Response> ExecuteAppsAdPlacementUpdateV1Async(this DouyinMicroAppClient client, Models.AppsAdPlacementUpdateV1Request 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, "apps", "v1", "ad_placement", "update", "")
.WithHeader("access-token", request.AccessToken);

return await client.SendFlurlRequestAsJsonAsync<Models.AppsAdPlacementUpdateV1Response>(flurlReq, data: request, cancellationToken: cancellationToken).ConfigureAwait(false);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
using System;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
using Flurl.Http;

namespace SKIT.FlurlHttpClient.ByteDance.MicroApp
{
public static class DouyinMicroAppClientExecuteAppsTrafficPermissionExtensions
{
/// <summary>
/// <para>异步调用 [GET] /apps/v1/traffic_permission/query/ 接口。</para>
/// <para>
/// REF: <br/>
/// <![CDATA[ https://developer.open-douyin.com/docs/resource/zh-CN/mini-app/develop/server/traffic-permission/query-status ]]>
/// </para>
/// </summary>
/// <param name="client"></param>
/// <param name="request"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
public static async Task<Models.AppsTrafficPermissionQueryV1Response> ExecuteAppsTrafficPermissionQueryV1Async(this DouyinMicroAppClient client, Models.AppsTrafficPermissionQueryV1Request 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.Get, "apps", "v1", "traffic_permission", "query", "")
.WithHeader("access-token", request.AccessToken);

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

/// <summary>
/// <para>异步调用 [POST] /apps/v1/traffic_permission/open/ 接口。</para>
/// <para>
/// REF: <br/>
/// <![CDATA[ https://developer.open-douyin.com/docs/resource/zh-CN/mini-app/develop/server/traffic-permission/open-traffic-permission ]]>
/// </para>
/// </summary>
/// <param name="client"></param>
/// <param name="request"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
public static async Task<Models.AppsTrafficPermissionOpenV1Response> ExecuteAppsTrafficPermissionOpenV1Async(this DouyinMicroAppClient client, Models.AppsTrafficPermissionOpenV1Request 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, "apps", "v1", "traffic_permission", "open", "")
.WithHeader("access-token", request.AccessToken);

return await client.SendFlurlRequestAsJsonAsync<Models.AppsTrafficPermissionOpenV1Response>(flurlReq, data: request, cancellationToken: cancellationToken).ConfigureAwait(false);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1124,7 +1124,6 @@ public static class DouyinMicroAppClientExecuteLegacyAppsExtensions
/// <param name="request"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
[Obsolete("相关接口或字段于 2024-02-29 下线。")]
public static async Task<Models.AppsCapacityQueryAdIncomeV1Response> ExecuteAppsCapacityQueryAdIncomeV1Async(this DouyinMicroAppClient client, Models.AppsCapacityQueryAdIncomeV1Request request, CancellationToken cancellationToken = default)
{
if (client is null) throw new ArgumentNullException(nameof(client));
Expand Down Expand Up @@ -1154,7 +1153,6 @@ public static class DouyinMicroAppClientExecuteLegacyAppsExtensions
/// <param name="request"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
[Obsolete("相关接口或字段于 2024-02-29 下线。")]
public static async Task<Models.AppsCapacityQueryAdSettlementListV1Response> ExecuteAppsCapacityQueryAdSettlementListV1Async(this DouyinMicroAppClient client, Models.AppsCapacityQueryAdSettlementListV1Request request, CancellationToken cancellationToken = default)
{
if (client is null) throw new ArgumentNullException(nameof(client));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

namespace SKIT.FlurlHttpClient.ByteDance.MicroApp
{
public static class DouyinMicroAppClientExecuteMatchExtensions
public static class DouyinMicroAppClientExecuteMatchTaskBoxExtensions
{
/// <summary>
/// <para>异步调用 [POST] /match/v2/taskbox/add_task/ 接口。</para>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

namespace SKIT.FlurlHttpClient.ByteDance.MicroApp
{
public static class DouyinMicroAppClientExecuteNotificationExtensions
public static class DouyinMicroAppClientExecuteNotificationSubscriptionExtensions
{
/// <summary>
/// <para>异步调用 [GET] /notification/v2/subscription/query_tpl_list/ 接口。</para>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
namespace SKIT.FlurlHttpClient.ByteDance.MicroApp.Models
{
/// <summary>
/// <para>表示 [POST] /apps/v1/ad_placement/add/ 接口的请求。</para>
/// </summary>
public class AppsAdPlacementAddV1Request : DouyinMicroAppRequest
{
/// <summary>
/// 获取或设置广告位名称。
/// </summary>
[Newtonsoft.Json.JsonProperty("ad_placement_name")]
[System.Text.Json.Serialization.JsonPropertyName("ad_placement_name")]
public string AdPlacementName { get; set; } = string.Empty;

/// <summary>
/// 获取或设置广告位类型。
/// </summary>
[Newtonsoft.Json.JsonProperty("ad_placement_type")]
[System.Text.Json.Serialization.JsonPropertyName("ad_placement_type")]
public int AdPlacementType { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace SKIT.FlurlHttpClient.ByteDance.MicroApp.Models
{
/// <summary>
/// <para>表示 [POST] /apps/v1/ad_placement/add/ 接口的响应。</para>
/// </summary>
public class AppsAdPlacementAddV1Response : DouyinMicroAppResponse
{
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace SKIT.FlurlHttpClient.ByteDance.MicroApp.Models
{
/// <summary>
/// <para>表示 [GET] /apps/v1/ad_placement/query/ 接口的请求。</para>
/// </summary>
public class AppsAdPlacementQueryV1Request : DouyinMicroAppRequest
{
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
namespace SKIT.FlurlHttpClient.ByteDance.MicroApp.Models
{
/// <summary>
/// <para>表示 [GET] /apps/v1/ad_placement/query/ 接口的响应。</para>
/// </summary>
public class AppsAdPlacementQueryV1Response : DouyinMicroAppResponse
{
public static class Types
{
public class Data
{
public static class Types
{
public class AdPlacement
{
/// <summary>
/// 获取或设置广告位 ID。
/// </summary>
[Newtonsoft.Json.JsonProperty("ad_placement_id")]
[System.Text.Json.Serialization.JsonPropertyName("ad_placement_id")]
public string AdPlacementId { get; set; } = default!;

/// <summary>
/// 获取或设置广告位名称。
/// </summary>
[Newtonsoft.Json.JsonProperty("ad_placement_name")]
[System.Text.Json.Serialization.JsonPropertyName("ad_placement_name")]
public string AdPlacementName { get; set; } = default!;

/// <summary>
/// 获取或设置广告位类型。
/// </summary>
[Newtonsoft.Json.JsonProperty("ad_placement_type")]
[System.Text.Json.Serialization.JsonPropertyName("ad_placement_type")]
public int AdPlacementType { get; set; }

/// <summary>
/// 获取或设置状态。
/// </summary>
[Newtonsoft.Json.JsonProperty("status")]
[System.Text.Json.Serialization.JsonPropertyName("status")]
public int Status { get; set; }
}
}

/// <summary>
/// 获取或设置广告位列表。
/// </summary>
[Newtonsoft.Json.JsonProperty("ad_placement_list")]
[System.Text.Json.Serialization.JsonPropertyName("ad_placement_list")]
public Types.AdPlacement[] AdPlacementList { get; set; } = default!;
}
}

/// <summary>
/// 获取或设置返回数据。
/// </summary>
[Newtonsoft.Json.JsonProperty("data")]
[System.Text.Json.Serialization.JsonPropertyName("data")]
public Types.Data Data { get; set; } = default!;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
namespace SKIT.FlurlHttpClient.ByteDance.MicroApp.Models
{
/// <summary>
/// <para>表示 [POST] /apps/v1/ad_placement/update/ 接口的请求。</para>
/// </summary>
public class AppsAdPlacementUpdateV1Request : DouyinMicroAppRequest
{
/// <summary>
/// 获取或设置广告位 ID。
/// </summary>
[Newtonsoft.Json.JsonProperty("ad_placement_id")]
[System.Text.Json.Serialization.JsonPropertyName("ad_placement_id")]
public string AdPlacementId { get; set; } = string.Empty;

/// <summary>
/// 获取或设置状态。
/// </summary>
[Newtonsoft.Json.JsonProperty("status")]
[System.Text.Json.Serialization.JsonPropertyName("status")]
public int Status { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace SKIT.FlurlHttpClient.ByteDance.MicroApp.Models
{
/// <summary>
/// <para>表示 [POST] /apps/v1/ad_placement/update/ 接口的响应。</para>
/// </summary>
public class AppsAdPlacementUpdateV1Response : DouyinMicroAppResponse
{
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
namespace SKIT.FlurlHttpClient.ByteDance.MicroApp.Models
{
/// <summary>
/// <para>表示 [POST] /apps/v1/traffic_permission/open/ 接口的请求。</para>
/// </summary>
public class AppsTrafficPermissionOpenV1Request : DouyinMicroAppRequest
{
/// <summary>
/// 获取或设置省份。
/// </summary>
[Newtonsoft.Json.JsonProperty("province")]
[System.Text.Json.Serialization.JsonPropertyName("province")]
public string Province { get; set; } = string.Empty;

/// <summary>
/// 获取或设置城市。
/// </summary>
[Newtonsoft.Json.JsonProperty("city")]
[System.Text.Json.Serialization.JsonPropertyName("city")]
public string City { get; set; } = string.Empty;

/// <summary>
/// 获取或设置手机号码。
/// </summary>
[Newtonsoft.Json.JsonProperty("phone_number")]
[System.Text.Json.Serialization.JsonPropertyName("phone_number")]
public string PhoneNumber { get; set; } = string.Empty;

/// <summary>
/// 获取或设置纳税人性质。
/// </summary>
[Newtonsoft.Json.JsonProperty("tax_nature")]
[System.Text.Json.Serialization.JsonPropertyName("tax_nature")]
public int TaxNatureType { get; set; }

/// <summary>
/// 获取或设置银行账号。
/// </summary>
[Newtonsoft.Json.JsonProperty("bank_account_number")]
[System.Text.Json.Serialization.JsonPropertyName("bank_account_number")]
public string BankAccountNumber { get; set; } = string.Empty;

/// <summary>
/// 获取或设置开户银行名称。
/// </summary>
[Newtonsoft.Json.JsonProperty("bank_name")]
[System.Text.Json.Serialization.JsonPropertyName("bank_name")]
public string BankName { get; set; } = string.Empty;

/// <summary>
/// 获取或设置开户支行名称。
/// </summary>
[Newtonsoft.Json.JsonProperty("bank_branch")]
[System.Text.Json.Serialization.JsonPropertyName("bank_branch")]
public string BankBranch { get; set; } = string.Empty;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace SKIT.FlurlHttpClient.ByteDance.MicroApp.Models
{
/// <summary>
/// <para>表示 [POST] /apps/v1/traffic_permission/open/ 接口的响应。</para>
/// </summary>
public class AppsTrafficPermissionOpenV1Response : DouyinMicroAppResponse
{
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace SKIT.FlurlHttpClient.ByteDance.MicroApp.Models
{
/// <summary>
/// <para>表示 [GET] /apps/v1/traffic_permission/query/ 接口的请求。</para>
/// </summary>
public class AppsTrafficPermissionQueryV1Request : DouyinMicroAppRequest
{
}
}
Loading

0 comments on commit d2535b2

Please sign in to comment.