Skip to content

Commit

Permalink
feat(tiktokshop): 新增新版促销活动相关接口
Browse files Browse the repository at this point in the history
  • Loading branch information
fudiwei committed May 13, 2024
1 parent 28ffa98 commit c11dc68
Show file tree
Hide file tree
Showing 30 changed files with 1,099 additions and 6 deletions.
18 changes: 18 additions & 0 deletions docs/TikTokGlobalShop/Basic_ModelDefinition.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ Naming Policies:

### APIs

Notes: The following catalog is consistent with the catalog structure of [TikTokShop Partner Center API Reference](https://partner.tiktokshop.com/docv2/page/6507ead7b99d5302be949ba9?external_id=6507ead7b99d5302be949ba9).

<details>

<summary>[View Details]</summary>
Expand Down Expand Up @@ -63,11 +65,27 @@ Naming Policies:
- Orders
- Get Order List: `OrderSearchOrders`
- Get Order Detail: `OrderBatchGetOrderDetail`
- Fulfillment
- *Pending ...*
- Return and Refund
- *Pending ...*
- Logistics
- Get Warehouse Delivery Options: `LogisticsGetWarehouseDeliveryOptions`
- Get Warehouse List: `LogisticsGetWarehouses`
- Get Shipping Providers: `LogisticsGetDeliveryOptionShippingProviders`
- Get Global Seller Warehouse: `LogisticsGetGlobalWarehouses`
- Promotion
- Create Activity: `PromotionCreateActivity`
- Update Activity Product: `PromotionUpdateActivityProducts`
- Remove Activity Product: `PromotionDeleteActivityProducts`
- Search Activities: `PromotionSearchActivities`
- Get Activity: `PromotionGetActivityDetail`
- Update Activity: `PromotionUpdateActivity`
- Deactivate Activity: `PromotionDeactivateActivity`
- Finance
- *Pending ...*
- Customer Service
- *Pending ...*
- Supply Chain
- Confirm Package Shipment: `SupplyChainSyncPackages`

Expand Down
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);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ public class IdentifierCode : ProductGetProductDetailResponse.Types.Data.Types.S
[Newtonsoft.Json.JsonProperty("sku_unit_count")]
[Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.Common.TextualNumberConverter))]
[System.Text.Json.Serialization.JsonPropertyName("sku_unit_count")]
[System.Text.Json.Serialization.JsonNumberHandling(System.Text.Json.Serialization.JsonNumberHandling.AllowReadingFromString | System.Text.Json.Serialization.JsonNumberHandling.WriteAsString)]
[System.Text.Json.Serialization.JsonNumberHandling(System.Text.Json.Serialization.JsonNumberHandling.AllowReadingFromString)]
public decimal? UnitCount { get; set; }
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ public class ReplicateSource
[Newtonsoft.Json.JsonProperty("sku_unit_count")]
[Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.Common.TextualNumberConverter))]
[System.Text.Json.Serialization.JsonPropertyName("sku_unit_count")]
[System.Text.Json.Serialization.JsonNumberHandling(System.Text.Json.Serialization.JsonNumberHandling.AllowReadingFromString | System.Text.Json.Serialization.JsonNumberHandling.WriteAsString)]
[System.Text.Json.Serialization.JsonNumberHandling(System.Text.Json.Serialization.JsonNumberHandling.AllowReadingFromString)]
public decimal? UnitCount { get; set; }

/// <summary>
Expand All @@ -430,7 +430,7 @@ public class PackageDimension
[Newtonsoft.Json.JsonProperty("length")]
[Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.Common.TextualNumberConverter))]
[System.Text.Json.Serialization.JsonPropertyName("length")]
[System.Text.Json.Serialization.JsonNumberHandling(System.Text.Json.Serialization.JsonNumberHandling.AllowReadingFromString | System.Text.Json.Serialization.JsonNumberHandling.WriteAsString)]
[System.Text.Json.Serialization.JsonNumberHandling(System.Text.Json.Serialization.JsonNumberHandling.AllowReadingFromString)]
public decimal Length { get; set; }

/// <summary>
Expand All @@ -439,7 +439,7 @@ public class PackageDimension
[Newtonsoft.Json.JsonProperty("width")]
[Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.Common.TextualNumberConverter))]
[System.Text.Json.Serialization.JsonPropertyName("width")]
[System.Text.Json.Serialization.JsonNumberHandling(System.Text.Json.Serialization.JsonNumberHandling.AllowReadingFromString | System.Text.Json.Serialization.JsonNumberHandling.WriteAsString)]
[System.Text.Json.Serialization.JsonNumberHandling(System.Text.Json.Serialization.JsonNumberHandling.AllowReadingFromString)]
public decimal Width { get; set; }

/// <summary>
Expand All @@ -448,7 +448,7 @@ public class PackageDimension
[Newtonsoft.Json.JsonProperty("height")]
[Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.Common.TextualNumberConverter))]
[System.Text.Json.Serialization.JsonPropertyName("height")]
[System.Text.Json.Serialization.JsonNumberHandling(System.Text.Json.Serialization.JsonNumberHandling.AllowReadingFromString | System.Text.Json.Serialization.JsonNumberHandling.WriteAsString)]
[System.Text.Json.Serialization.JsonNumberHandling(System.Text.Json.Serialization.JsonNumberHandling.AllowReadingFromString)]
public decimal Height { get; set; }

/// <summary>
Expand All @@ -467,7 +467,7 @@ public class PackageWeight
[Newtonsoft.Json.JsonProperty("value")]
[Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.Common.TextualNumberConverter))]
[System.Text.Json.Serialization.JsonPropertyName("value")]
[System.Text.Json.Serialization.JsonNumberHandling(System.Text.Json.Serialization.JsonNumberHandling.AllowReadingFromString | System.Text.Json.Serialization.JsonNumberHandling.WriteAsString)]
[System.Text.Json.Serialization.JsonNumberHandling(System.Text.Json.Serialization.JsonNumberHandling.AllowReadingFromString)]
public decimal Value { get; set; }

/// <summary>
Expand Down
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; }
}
}
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; }
}
}
}
}
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;
}
}
Loading

0 comments on commit c11dc68

Please sign in to comment.