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 efb0b8f commit 28ffa98
Show file tree
Hide file tree
Showing 14 changed files with 606 additions and 0 deletions.
5 changes: 5 additions & 0 deletions docs/TikTokGlobalShop/Basic_ModelDefinition.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@ Naming Policies:
- Orders
- Get Order List: `OrderSearchOrders`
- Get Order Detail: `OrderBatchGetOrderDetail`
- Logistics
- Get Warehouse Delivery Options: `LogisticsGetWarehouseDeliveryOptions`
- Get Warehouse List: `LogisticsGetWarehouses`
- Get Shipping Providers: `LogisticsGetDeliveryOptionShippingProviders`
- Get Global Seller Warehouse: `LogisticsGetGlobalWarehouses`
- Supply Chain
- Confirm Package Shipment: `SupplyChainSyncPackages`

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
using System;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
using Flurl.Http;

namespace SKIT.FlurlHttpClient.ByteDance.TikTokGlobalShop
{
public static class TikTokShopClientExecuteLogisticsExtensions
{
/// <summary>
/// <para>异步调用 [GET] /logistics/{version}/warehouses 接口。</para>
/// <para>
/// REF: <br/>
/// <![CDATA[ https://partner.tiktokshop.com/docv2/page/650aa418defece02be6e66b6 ]]>
/// </para>
/// </summary>
/// <param name="client"></param>
/// <param name="request"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
public static async Task<Models.LogisticsGetWarehousesResponse> ExecuteLogisticsGetWarehousesAsync(this TikTokShopClient client, Models.LogisticsGetWarehousesRequest 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, "logistics", request.ApiVersion, "warehouses");

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

/// <summary>
/// <para>异步调用 [GET] /logistics/{version}/global_warehouses 接口。</para>
/// <para>
/// REF: <br/>
/// <![CDATA[ https://partner.tiktokshop.com/docv2/page/650aa3f0defece02be6e5ffb ]]>
/// </para>
/// </summary>
/// <param name="client"></param>
/// <param name="request"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
public static async Task<Models.LogisticsGetGlobalWarehousesResponse> ExecuteLogisticsGetGlobalWarehousesAsync(this TikTokShopClient client, Models.LogisticsGetGlobalWarehousesRequest 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, "logistics", request.ApiVersion, "global_warehouses");

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

/// <summary>
/// <para>异步调用 [GET] /logistics/{version}/warehouses/{warehouse_id}/delivery_options 接口。</para>
/// <para>
/// REF: <br/>
/// <![CDATA[ https://partner.tiktokshop.com/docv2/page/650aa46ebace3e02b75d9afa ]]>
/// </para>
/// </summary>
/// <param name="client"></param>
/// <param name="request"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
public static async Task<Models.LogisticsGetWarehouseDeliveryOptionsResponse> ExecuteLogisticsGetWarehouseDeliveryOptionsAsync(this TikTokShopClient client, Models.LogisticsGetWarehouseDeliveryOptionsRequest 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, "logistics", request.ApiVersion, "warehouses", request.WarehouseId, "delivery_options");

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

/// <summary>
/// <para>异步调用 [GET] /logistics/{version}/delivery_options/{delivery_option_id}/shipping_providers 接口。</para>
/// <para>
/// REF: <br/>
/// <![CDATA[ https://partner.tiktokshop.com/docv2/page/650aa48d4a0bb702c06d85cd ]]>
/// </para>
/// </summary>
/// <param name="client"></param>
/// <param name="request"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
public static async Task<Models.LogisticsGetDeliveryOptionShippingProvidersResponse> ExecuteLogisticsGetDeliveryOptionShippingProvidersAsync(this TikTokShopClient client, Models.LogisticsGetDeliveryOptionShippingProvidersRequest 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, "logistics", request.ApiVersion, "delivery_options", request.DeliveryOptionId, "shipping_providers");

return await client.SendFlurlRequesAsJsontAsync<Models.LogisticsGetDeliveryOptionShippingProvidersResponse>(flurlReq, data: request, cancellationToken: cancellationToken).ConfigureAwait(false);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
namespace SKIT.FlurlHttpClient.ByteDance.TikTokGlobalShop.Models
{
/// <summary>
/// <para>表示 [GET] /logistics/{version}/delivery_options/{delivery_option_id}/shipping_providers 接口的请求。</para>
/// </summary>
public class LogisticsGetDeliveryOptionShippingProvidersRequest : TikTokShopRequest
{
/// <summary>
/// 获取或设置配送方式 ID。
/// </summary>
[Newtonsoft.Json.JsonIgnore]
[System.Text.Json.Serialization.JsonIgnore]
public string DeliveryOptionId { get; set; } = string.Empty;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
namespace SKIT.FlurlHttpClient.ByteDance.TikTokGlobalShop.Models
{
/// <summary>
/// <para>表示 [GET] /logistics/{version}/delivery_options/{delivery_option_id}/shipping_providers 接口的响应。</para>
/// </summary>
public class LogisticsGetDeliveryOptionShippingProvidersResponse : TikTokShopResponse<LogisticsGetDeliveryOptionShippingProvidersResponse.Types.Data>
{
public static class Types
{
public class Data
{
public static class Types
{
public class ShippingProvider
{
/// <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 ShippingProviderId { 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("shipping_providers")]
[System.Text.Json.Serialization.JsonPropertyName("shipping_providers")]
public Types.ShippingProvider[] ShippingProviderList { get; set; } = default!;
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace SKIT.FlurlHttpClient.ByteDance.TikTokGlobalShop.Models
{
/// <summary>
/// <para>表示 [GET] /logistics/{version}/global_warehouses 接口的请求。</para>
/// </summary>
public class LogisticsGetGlobalWarehousesRequest : TikTokShopRequest
{
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
namespace SKIT.FlurlHttpClient.ByteDance.TikTokGlobalShop.Models
{
/// <summary>
/// <para>表示 [GET] /logistics/{version}/global_warehouses 接口的响应。</para>
/// </summary>
public class LogisticsGetGlobalWarehousesResponse : TikTokShopResponse<LogisticsGetGlobalWarehousesResponse.Types.Data>
{
public static class Types
{
public class Data
{
public static class Types
{
public class Warehouse
{
/// <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 WarehouseId { 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("ownership")]
[System.Text.Json.Serialization.JsonPropertyName("ownership")]
public string Ownership { get; set; } = default!;
}
}

/// <summary>
/// 获取或设置仓库列表。
/// </summary>
[Newtonsoft.Json.JsonProperty("global_warehouses")]
[System.Text.Json.Serialization.JsonPropertyName("global_warehouses")]
public Types.Warehouse[] WarehouseList { get; set; } = default!;
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
namespace SKIT.FlurlHttpClient.ByteDance.TikTokGlobalShop.Models
{
/// <summary>
/// <para>表示 [GET] /logistics/{version}/warehouses/{warehouse_id}/delivery_options 接口的请求。</para>
/// </summary>
public class LogisticsGetWarehouseDeliveryOptionsRequest : TikTokShopRequest
{
/// <summary>
/// 获取或设置仓库 ID。
/// </summary>
[Newtonsoft.Json.JsonIgnore]
[System.Text.Json.Serialization.JsonIgnore]
public string WarehouseId { get; set; } = string.Empty;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
namespace SKIT.FlurlHttpClient.ByteDance.TikTokGlobalShop.Models
{
/// <summary>
/// <para>表示 [GET] /logistics/{version}/warehouses/{warehouse_id}/delivery_options 接口的响应。</para>
/// </summary>
public class LogisticsGetWarehouseDeliveryOptionsResponse : TikTokShopResponse<LogisticsGetWarehouseDeliveryOptionsResponse.Types.Data>
{
public static class Types
{
public class Data
{
public static class Types
{
public class DeliveryOption
{
public static class Types
{
public class DimensionLimit
{
/// <summary>
/// 获取或设置最大长度。
/// </summary>
[Newtonsoft.Json.JsonProperty("max_length")]
[System.Text.Json.Serialization.JsonPropertyName("max_length")]
public int MaxLength { get; set; }

/// <summary>
/// 获取或设置最大宽度。
/// </summary>
[Newtonsoft.Json.JsonProperty("max_width")]
[System.Text.Json.Serialization.JsonPropertyName("max_width")]
public int MaxWidth { get; set; }

/// <summary>
/// 获取或设置最大高度。
/// </summary>
[Newtonsoft.Json.JsonProperty("max_height")]
[System.Text.Json.Serialization.JsonPropertyName("max_height")]
public int MaxHeight { get; set; }

/// <summary>
/// 获取或设置尺寸单位。
/// </summary>
[Newtonsoft.Json.JsonProperty("unit")]
[System.Text.Json.Serialization.JsonPropertyName("unit")]
public string Unit { get; set; } = default!;
}

public class WeightLimit
{
/// <summary>
/// 获取或设置最小重量。
/// </summary>
[Newtonsoft.Json.JsonProperty("min_weight")]
[System.Text.Json.Serialization.JsonPropertyName("min_weight")]
public int MinWeight { get; set; }

/// <summary>
/// 获取或设置最大重量。
/// </summary>
[Newtonsoft.Json.JsonProperty("max_weight")]
[System.Text.Json.Serialization.JsonPropertyName("max_weight")]
public int MaxWeight { get; set; }

/// <summary>
/// 获取或设置重量单位。
/// </summary>
[Newtonsoft.Json.JsonProperty("unit")]
[System.Text.Json.Serialization.JsonPropertyName("unit")]
public string Unit { get; set; } = default!;
}
}

/// <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 DeliveryOptionId { 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("type")]
[System.Text.Json.Serialization.JsonPropertyName("type")]
public string Type { get; set; } = default!;

/// <summary>
/// 获取或设置描述。
/// </summary>
[Newtonsoft.Json.JsonProperty("description")]
[System.Text.Json.Serialization.JsonPropertyName("description")]
public string Description { get; set; } = default!;

/// <summary>
/// 获取或设置尺寸限制。
/// </summary>
[Newtonsoft.Json.JsonProperty("dimension_limit")]
[System.Text.Json.Serialization.JsonPropertyName("dimension_limit")]
public Types.DimensionLimit DimensionLimit { get; set; } = default!;

/// <summary>
/// 获取或设置重量限制。
/// </summary>
[Newtonsoft.Json.JsonProperty("weight_limit")]
[System.Text.Json.Serialization.JsonPropertyName("weight_limit")]
public Types.WeightLimit WeightLimit { get; set; } = default!;
}
}

/// <summary>
/// 获取或设置配送方式列表。
/// </summary>
[Newtonsoft.Json.JsonProperty("delivery_options")]
[System.Text.Json.Serialization.JsonPropertyName("delivery_options")]
public Types.DeliveryOption[] DeliveryOptionList { get; set; } = default!;
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace SKIT.FlurlHttpClient.ByteDance.TikTokGlobalShop.Models
{
/// <summary>
/// <para>表示 [GET] /logistics/{version}/warehouses 接口的请求。</para>
/// </summary>
public class LogisticsGetWarehousesRequest : TikTokShopRequest
{
}
}
Loading

0 comments on commit 28ffa98

Please sign in to comment.