-
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
11 changed files
with
264 additions
and
7 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
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
64 changes: 64 additions & 0 deletions
64
...pClient.ByteDance.TikTokGlobalShop/Extensions/TikTokShopClientExecuteProductExtensions.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,64 @@ | ||
using System; | ||
using System.Net.Http; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using Flurl.Http; | ||
|
||
namespace SKIT.FlurlHttpClient.ByteDance.TikTokGlobalShop | ||
{ | ||
public static class TikTokShopClientExecuteProductExtensions | ||
{ | ||
#region Brand | ||
/// <summary> | ||
/// <para>异步调用 [GET] /product/{version}/brands 接口。</para> | ||
/// <para> | ||
/// REF: <br/> | ||
/// <![CDATA[ https://partner.tiktokshop.com/docv2/page/6503075656e2bb0289dd5d01 ]]> | ||
/// </para> | ||
/// </summary> | ||
/// <param name="client"></param> | ||
/// <param name="request"></param> | ||
/// <param name="cancellationToken"></param> | ||
/// <returns></returns> | ||
public static async Task<Models.ProductGetBrandsResponse> ExecuteProductGetBrandsAsync(this TikTokShopClient client, Models.ProductGetBrandsRequest 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, "product", request.ApiVersion, "brands") | ||
.SetQueryParam("category_id", request.CategoryId) | ||
.SetQueryParam("brand_name", request.BrandName) | ||
.SetQueryParam("page_size", request.PageSize) | ||
.SetQueryParam("page_token", request.PageToken); | ||
|
||
if (request.IsAuthorized is not null) | ||
flurlReq.SetQueryParam("is_authorized", request.IsAuthorized.Value ? "true" : "false"); | ||
|
||
return await client.SendFlurlRequesAsJsontAsync<Models.ProductGetBrandsResponse>(flurlReq, data: request, cancellationToken: cancellationToken).ConfigureAwait(false); | ||
} | ||
|
||
/// <summary> | ||
/// <para>异步调用 [POST] /product/{version}/brands 接口。</para> | ||
/// <para> | ||
/// REF: <br/> | ||
/// <![CDATA[ https://partner.tiktokshop.com/docv2/page/650a0926f1fd3102b91bbfb0 ]]> | ||
/// </para> | ||
/// </summary> | ||
/// <param name="client"></param> | ||
/// <param name="request"></param> | ||
/// <param name="cancellationToken"></param> | ||
/// <returns></returns> | ||
public static async Task<Models.ProductCreateBrandResponse> ExecuteProductCreateBrandAsync(this TikTokShopClient client, Models.ProductCreateBrandRequest 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, "product", request.ApiVersion, "brands"); | ||
|
||
return await client.SendFlurlRequesAsJsontAsync<Models.ProductCreateBrandResponse>(flurlReq, data: request, cancellationToken: cancellationToken).ConfigureAwait(false); | ||
} | ||
#endregion | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
...rlHttpClient.ByteDance.TikTokGlobalShop/Models/Product/Brand/ProductCreateBrandRequest.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] /product/{version}/brands 接口的请求。</para> | ||
/// </summary> | ||
public class ProductCreateBrandRequest : TikTokShopRequest | ||
{ | ||
/// <summary> | ||
/// 获取或设置品牌名称。 | ||
/// </summary> | ||
[Newtonsoft.Json.JsonProperty("name")] | ||
[System.Text.Json.Serialization.JsonPropertyName("name")] | ||
public string Name { get; set; } = string.Empty; | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
...lHttpClient.ByteDance.TikTokGlobalShop/Models/Product/Brand/ProductCreateBrandResponse.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,22 @@ | ||
namespace SKIT.FlurlHttpClient.ByteDance.TikTokGlobalShop.Models | ||
{ | ||
/// <summary> | ||
/// <para>表示 [POST] /product/{version}/brands 接口的响应。</para> | ||
/// </summary> | ||
public class ProductCreateBrandResponse : TikTokShopResponse<ProductCreateBrandResponse.Types.Data> | ||
{ | ||
public static class Types | ||
{ | ||
public class Data | ||
{ | ||
/// <summary> | ||
/// 获取或设置品牌 ID。 | ||
/// </summary> | ||
[Newtonsoft.Json.JsonProperty("id")] | ||
[System.Text.Json.Serialization.JsonPropertyName("id")] | ||
[System.Text.Json.Serialization.JsonConverter(typeof(System.Text.Json.Serialization.Common.NumericalStringReadOnlyConverter))] | ||
public string BrandId { get; set; } = default!; | ||
} | ||
} | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
...lurlHttpClient.ByteDance.TikTokGlobalShop/Models/Product/Brand/ProductGetBrandsRequest.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,44 @@ | ||
namespace SKIT.FlurlHttpClient.ByteDance.TikTokGlobalShop.Models | ||
{ | ||
/// <summary> | ||
/// <para>表示 [GET] /product/{version}/brands 接口的请求。</para> | ||
/// </summary> | ||
public class ProductGetBrandsRequest : TikTokShopRequest | ||
{ | ||
/// <summary> | ||
/// 获取或设置分类 ID。 | ||
/// </summary> | ||
[Newtonsoft.Json.JsonIgnore] | ||
[System.Text.Json.Serialization.JsonIgnore] | ||
public string? CategoryId { get; set; } | ||
|
||
/// <summary> | ||
/// 获取或设置是否仅返回已授权品牌。 | ||
/// </summary> | ||
[Newtonsoft.Json.JsonIgnore] | ||
[System.Text.Json.Serialization.JsonIgnore] | ||
public bool? IsAuthorized { get; set; } | ||
|
||
/// <summary> | ||
/// 获取或设置品牌名称。 | ||
/// </summary> | ||
[Newtonsoft.Json.JsonIgnore] | ||
[System.Text.Json.Serialization.JsonIgnore] | ||
public string? BrandName { get; set; } | ||
|
||
/// <summary> | ||
/// 获取或设置分页每页数量。 | ||
/// <para>默认值:10</para> | ||
/// </summary> | ||
[Newtonsoft.Json.JsonIgnore] | ||
[System.Text.Json.Serialization.JsonIgnore] | ||
public int PageSize { get; set; } = 10; | ||
|
||
/// <summary> | ||
/// 获取或设置分页令牌。 | ||
/// </summary> | ||
[Newtonsoft.Json.JsonIgnore] | ||
[System.Text.Json.Serialization.JsonIgnore] | ||
public string? PageToken { get; set; } | ||
} | ||
} |
77 changes: 77 additions & 0 deletions
77
...urlHttpClient.ByteDance.TikTokGlobalShop/Models/Product/Brand/ProductGetBrandsResponse.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,77 @@ | ||
namespace SKIT.FlurlHttpClient.ByteDance.TikTokGlobalShop.Models | ||
{ | ||
/// <summary> | ||
/// <para>表示 [GET] /product/{version}/brands 接口的响应。</para> | ||
/// </summary> | ||
public class ProductGetBrandsResponse : TikTokShopResponse<ProductGetBrandsResponse.Types.Data> | ||
{ | ||
public static class Types | ||
{ | ||
public class Data | ||
{ | ||
public static class Types | ||
{ | ||
public class Brand | ||
{ | ||
/// <summary> | ||
/// 获取或设置品牌 ID。 | ||
/// </summary> | ||
[Newtonsoft.Json.JsonProperty("id")] | ||
[System.Text.Json.Serialization.JsonPropertyName("id")] | ||
[System.Text.Json.Serialization.JsonConverter(typeof(System.Text.Json.Serialization.Common.NumericalStringReadOnlyConverter))] | ||
public string BrandId { get; set; } = default!; | ||
|
||
/// <summary> | ||
/// 获取或设置品牌名称。 | ||
/// </summary> | ||
[Newtonsoft.Json.JsonProperty("name")] | ||
[System.Text.Json.Serialization.JsonPropertyName("name")] | ||
public string Name { get; set; } = default!; | ||
|
||
/// <summary> | ||
/// 获取或设置授权状态。 | ||
/// </summary> | ||
[Newtonsoft.Json.JsonProperty("authorized_status")] | ||
[System.Text.Json.Serialization.JsonPropertyName("authorized_status")] | ||
public string AuthorizedStatus { get; set; } = default!; | ||
|
||
/// <summary> | ||
/// 获取或设置品牌状态。 | ||
/// </summary> | ||
[Newtonsoft.Json.JsonProperty("brand_status")] | ||
[System.Text.Json.Serialization.JsonPropertyName("brand_status")] | ||
public string BrandStatus { get; set; } = default!; | ||
|
||
/// <summary> | ||
/// 获取或设置是否是 T1 品牌。 | ||
/// </summary> | ||
[Newtonsoft.Json.JsonProperty("is_t1_brand")] | ||
[System.Text.Json.Serialization.JsonPropertyName("is_t1_brand")] | ||
public bool IsT1Brand { get; set; } | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// 获取或设置品牌列表。 | ||
/// </summary> | ||
[Newtonsoft.Json.JsonProperty("brands")] | ||
[System.Text.Json.Serialization.JsonPropertyName("brands")] | ||
public Types.Brand[] BrandList { get; set; } = default!; | ||
|
||
/// <summary> | ||
/// 获取或设置总数量。 | ||
/// </summary> | ||
[Newtonsoft.Json.JsonProperty("total_count")] | ||
[System.Text.Json.Serialization.JsonPropertyName("total_count")] | ||
public int TotalCount { get; set; } | ||
|
||
/// <summary> | ||
/// 获取或设置下一页分页令牌。 | ||
/// </summary> | ||
[Newtonsoft.Json.JsonProperty("next_page_token")] | ||
[System.Text.Json.Serialization.JsonPropertyName("next_page_token")] | ||
public string? NextPageToken { get; set; } | ||
} | ||
} | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
...ce.TikTokGlobalShop.UnitTests/ModelSamples/_/Product/Brand/ProductCreateBrandRequest.json
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,3 @@ | ||
{ | ||
"name": "Teas" | ||
} |
8 changes: 8 additions & 0 deletions
8
...e.TikTokGlobalShop.UnitTests/ModelSamples/_/Product/Brand/ProductCreateBrandResponse.json
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,8 @@ | ||
{ | ||
"code": 0, | ||
"data": { | ||
"id": "7082427311584347905" | ||
}, | ||
"message": "Success", | ||
"request_id": "202203070749000101890810281E8C70B7" | ||
} |
18 changes: 18 additions & 0 deletions
18
...nce.TikTokGlobalShop.UnitTests/ModelSamples/_/Product/Brand/ProductGetBrandsResponse.json
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,18 @@ | ||
{ | ||
"code": 0, | ||
"data": { | ||
"brands": [ | ||
{ | ||
"authorized_status": "UNAUTHORIEZD", | ||
"brand_status": "AVAILABLE", | ||
"id": "7082427311584347905", | ||
"is_t1_brand": true, | ||
"name": "Teas" | ||
} | ||
], | ||
"next_page_token": "b2Zmc2V0PTAK", | ||
"total_count": 10000 | ||
}, | ||
"message": "Success", | ||
"request_id": "202203070749000101890810281E8C70B7" | ||
} |