-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
30 changed files
with
1,099 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
165 changes: 165 additions & 0 deletions
165
...lient.ByteDance.TikTokGlobalShop/Extensions/TikTokShopClientExecutePromotionExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,165 @@ | ||
using System; | ||
using System.Net.Http; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using Flurl.Http; | ||
|
||
namespace SKIT.FlurlHttpClient.ByteDance.TikTokGlobalShop | ||
{ | ||
public static class TikTokShopClientExecutePromotionExtensions | ||
{ | ||
/// <summary> | ||
/// <para>异步调用 [POST] /promotion/{version}/activities 接口。</para> | ||
/// <para> | ||
/// REF: <br/> | ||
/// <![CDATA[ https://partner.tiktokshop.com/docv2/page/650c33c155bc3202b762b507 ]]> | ||
/// </para> | ||
/// </summary> | ||
/// <param name="client"></param> | ||
/// <param name="request"></param> | ||
/// <param name="cancellationToken"></param> | ||
/// <returns></returns> | ||
public static async Task<Models.PromotionCreateActivityResponse> ExecutePromotionCreateActivityAsync(this TikTokShopClient client, Models.PromotionCreateActivityRequest 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, "promotion", request.ApiVersion, "activities"); | ||
|
||
return await client.SendFlurlRequesAsJsontAsync<Models.PromotionCreateActivityResponse>(flurlReq, data: request, cancellationToken: cancellationToken).ConfigureAwait(false); | ||
} | ||
|
||
/// <summary> | ||
/// <para>异步调用 [POST] /promotion/{version}/activities/search 接口。</para> | ||
/// <para> | ||
/// REF: <br/> | ||
/// <![CDATA[ https://partner.tiktokshop.com/docv2/page/650acfbaf1fd3102b9315a3a ]]> | ||
/// </para> | ||
/// </summary> | ||
/// <param name="client"></param> | ||
/// <param name="request"></param> | ||
/// <param name="cancellationToken"></param> | ||
/// <returns></returns> | ||
public static async Task<Models.PromotionSearchActivitiesResponse> ExecutePromotionSearchActivitiesAsync(this TikTokShopClient client, Models.PromotionSearchActivitiesRequest 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, "promotion", request.ApiVersion, "activities", "search"); | ||
|
||
return await client.SendFlurlRequesAsJsontAsync<Models.PromotionSearchActivitiesResponse>(flurlReq, data: request, cancellationToken: cancellationToken).ConfigureAwait(false); | ||
} | ||
|
||
/// <summary> | ||
/// <para>异步调用 [GET] /promotion/{version}/activities/{activity_id} 接口。</para> | ||
/// <para> | ||
/// REF: <br/> | ||
/// <![CDATA[ https://partner.tiktokshop.com/docv2/page/650acd920fcef602bf36ee2b ]]> | ||
/// </para> | ||
/// </summary> | ||
/// <param name="client"></param> | ||
/// <param name="request"></param> | ||
/// <param name="cancellationToken"></param> | ||
/// <returns></returns> | ||
public static async Task<Models.PromotionGetActivityDetailResponse> ExecutePromotionGetActivityDetailAsync(this TikTokShopClient client, Models.PromotionGetActivityDetailRequest 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, "promotion", request.ApiVersion, "activities", request.ActivityId); | ||
|
||
return await client.SendFlurlRequesAsJsontAsync<Models.PromotionGetActivityDetailResponse>(flurlReq, data: request, cancellationToken: cancellationToken).ConfigureAwait(false); | ||
} | ||
|
||
/// <summary> | ||
/// <para>异步调用 [PUT] /promotion/{version}/activities/{activity_id} 接口。</para> | ||
/// <para> | ||
/// REF: <br/> | ||
/// <![CDATA[ https://partner.tiktokshop.com/docv2/page/650c584d82c3a602befa4ab8 ]]> | ||
/// </para> | ||
/// </summary> | ||
/// <param name="client"></param> | ||
/// <param name="request"></param> | ||
/// <param name="cancellationToken"></param> | ||
/// <returns></returns> | ||
public static async Task<Models.PromotionUpdateActivityResponse> ExecutePromotionUpdateActivityAsync(this TikTokShopClient client, Models.PromotionUpdateActivityRequest 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.Put, "promotion", request.ApiVersion, "activities", request.ActivityId); | ||
|
||
return await client.SendFlurlRequesAsJsontAsync<Models.PromotionUpdateActivityResponse>(flurlReq, data: request, cancellationToken: cancellationToken).ConfigureAwait(false); | ||
} | ||
|
||
/// <summary> | ||
/// <para>异步调用 [POST] /promotion/{version}/activities/{activity_id}/deactivate 接口。</para> | ||
/// <para> | ||
/// REF: <br/> | ||
/// <![CDATA[ https://partner.tiktokshop.com/docv2/page/650acf9adefece02be7380cf ]]> | ||
/// </para> | ||
/// </summary> | ||
/// <param name="client"></param> | ||
/// <param name="request"></param> | ||
/// <param name="cancellationToken"></param> | ||
/// <returns></returns> | ||
public static async Task<Models.PromotionDeactivateActivityResponse> ExecutePromotionDeactivateActivityAsync(this TikTokShopClient client, Models.PromotionDeactivateActivityRequest 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, "promotion", request.ApiVersion, "activities", request.ActivityId, "deactivate"); | ||
|
||
return await client.SendFlurlRequesAsJsontAsync<Models.PromotionDeactivateActivityResponse>(flurlReq, data: request, cancellationToken: cancellationToken).ConfigureAwait(false); | ||
} | ||
|
||
/// <summary> | ||
/// <para>异步调用 [PUT] /promotion/{version}/activities/{activity_id}/products 接口。</para> | ||
/// <para> | ||
/// REF: <br/> | ||
/// <![CDATA[ https://partner.tiktokshop.com/docv2/page/650d32c42aaa3602b86ccb5c ]]> | ||
/// </para> | ||
/// </summary> | ||
/// <param name="client"></param> | ||
/// <param name="request"></param> | ||
/// <param name="cancellationToken"></param> | ||
/// <returns></returns> | ||
public static async Task<Models.PromotionUpdateActivityProductsResponse> ExecutePromotionUpdateActivityProductsAsync(this TikTokShopClient client, Models.PromotionUpdateActivityProductsRequest 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.Put, "promotion", request.ApiVersion, "activities", request.ActivityId, "products"); | ||
|
||
return await client.SendFlurlRequesAsJsontAsync<Models.PromotionUpdateActivityProductsResponse>(flurlReq, data: request, cancellationToken: cancellationToken).ConfigureAwait(false); | ||
} | ||
|
||
/// <summary> | ||
/// <para>异步调用 [DELETE] /promotion/{version}/activities/{activity_id}/products 接口。</para> | ||
/// <para> | ||
/// REF: <br/> | ||
/// <![CDATA[ https://partner.tiktokshop.com/docv2/page/650d32c42aaa3602b86ccb5c ]]> | ||
/// </para> | ||
/// </summary> | ||
/// <param name="client"></param> | ||
/// <param name="request"></param> | ||
/// <param name="cancellationToken"></param> | ||
/// <returns></returns> | ||
public static async Task<Models.PromotionDeleteActivityProductsResponse> ExecutePromotionDeleteActivityProductsAsync(this TikTokShopClient client, Models.PromotionDeleteActivityProductsRequest 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.Delete, "promotion", request.ApiVersion, "activities", request.ActivityId, "products"); | ||
|
||
return await client.SendFlurlRequesAsJsontAsync<Models.PromotionDeleteActivityProductsResponse>(flurlReq, data: request, cancellationToken: cancellationToken).ConfigureAwait(false); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
...lHttpClient.ByteDance.TikTokGlobalShop/Models/Promotion/PromotionCreateActivityRequest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
namespace SKIT.FlurlHttpClient.ByteDance.TikTokGlobalShop.Models | ||
{ | ||
/// <summary> | ||
/// <para>表示 [POST] /promotion/{version}/activities 接口的请求。</para> | ||
/// </summary> | ||
public class PromotionCreateActivityRequest : TikTokShopRequest | ||
{ | ||
/// <summary> | ||
/// 获取或设置活动类型。 | ||
/// </summary> | ||
[Newtonsoft.Json.JsonProperty("activity_type")] | ||
[System.Text.Json.Serialization.JsonPropertyName("activity_type")] | ||
public string ActivityType { get; set; } = string.Empty; | ||
|
||
/// <summary> | ||
/// 获取或设置活动标题。 | ||
/// </summary> | ||
[Newtonsoft.Json.JsonProperty("title")] | ||
[System.Text.Json.Serialization.JsonPropertyName("title")] | ||
public string Title { get; set; } = string.Empty; | ||
|
||
/// <summary> | ||
/// 获取或设置商品类型。 | ||
/// </summary> | ||
[Newtonsoft.Json.JsonProperty("product_level")] | ||
[System.Text.Json.Serialization.JsonPropertyName("product_level")] | ||
public string ProductLevel { get; set; } = string.Empty; | ||
|
||
/// <summary> | ||
/// 获取或设置活动开始时间戳。 | ||
/// </summary> | ||
[Newtonsoft.Json.JsonProperty("begin_time")] | ||
[System.Text.Json.Serialization.JsonPropertyName("begin_time")] | ||
public long BeginTimestamp { get; set; } | ||
|
||
/// <summary> | ||
/// 获取或设置活动结束时间戳。 | ||
/// </summary> | ||
[Newtonsoft.Json.JsonProperty("end_time")] | ||
[System.Text.Json.Serialization.JsonPropertyName("end_time")] | ||
public long EndTimestamp { get; set; } | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
...HttpClient.ByteDance.TikTokGlobalShop/Models/Promotion/PromotionCreateActivityResponse.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
namespace SKIT.FlurlHttpClient.ByteDance.TikTokGlobalShop.Models | ||
{ | ||
/// <summary> | ||
/// <para>表示 [POST] /promotion/{version}/activities 接口的响应。</para> | ||
/// </summary> | ||
public class PromotionCreateActivityResponse : TikTokShopResponse<PromotionCreateActivityResponse.Types.Data> | ||
{ | ||
public static class Types | ||
{ | ||
public class Data | ||
{ | ||
/// <summary> | ||
/// 获取或设置活动 ID。 | ||
/// </summary> | ||
[Newtonsoft.Json.JsonProperty("activity_id")] | ||
[System.Text.Json.Serialization.JsonPropertyName("activity_id")] | ||
[System.Text.Json.Serialization.JsonConverter(typeof(System.Text.Json.Serialization.Common.NumericalStringReadOnlyConverter))] | ||
public string ActivityId { get; set; } = default!; | ||
|
||
/// <summary> | ||
/// 获取或设置活动状态。 | ||
/// </summary> | ||
[Newtonsoft.Json.JsonProperty("status")] | ||
[System.Text.Json.Serialization.JsonPropertyName("status")] | ||
public string Status { get; set; } = default!; | ||
|
||
/// <summary> | ||
/// 获取或设置创建时间戳。 | ||
/// </summary> | ||
[Newtonsoft.Json.JsonProperty("create_time")] | ||
[System.Text.Json.Serialization.JsonPropertyName("create_time")] | ||
public long CreateTimestamp { get; set; } | ||
|
||
/// <summary> | ||
/// 获取或设置更新时间戳。 | ||
/// </summary> | ||
[Newtonsoft.Json.JsonProperty("update_time")] | ||
[System.Text.Json.Serialization.JsonPropertyName("update_time")] | ||
public long UpdateTimestamp { get; set; } | ||
} | ||
} | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
...pClient.ByteDance.TikTokGlobalShop/Models/Promotion/PromotionDeactivateActivityRequest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
namespace SKIT.FlurlHttpClient.ByteDance.TikTokGlobalShop.Models | ||
{ | ||
/// <summary> | ||
/// <para>表示 [POST] /promotion/{version}/activities/{activity_id}/deactivate 接口的请求。</para> | ||
/// </summary> | ||
public class PromotionDeactivateActivityRequest : TikTokShopRequest | ||
{ | ||
/// <summary> | ||
/// 获取或设置活动 ID。 | ||
/// </summary> | ||
[Newtonsoft.Json.JsonIgnore] | ||
[System.Text.Json.Serialization.JsonIgnore] | ||
public string ActivityId { get; set; } = string.Empty; | ||
} | ||
} |
Oops, something went wrong.