Skip to content

Commit

Permalink
feat(tiktokshop): 升级公共组件
Browse files Browse the repository at this point in the history
  • Loading branch information
fudiwei committed Mar 4, 2024
1 parent a615690 commit 85c6ebe
Show file tree
Hide file tree
Showing 75 changed files with 777 additions and 721 deletions.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ public static class TikTokShopClientExecuteAuthExtensions
{
/// <summary>
/// <para>异步调用 [GET] /token/get 接口。</para>
/// <para>REF: https://partner.tiktokshop.com/doc/page/261250 </para>
/// <para>
/// REF: <br/>
/// <![CDATA[ https://partner.tiktokshop.com/doc/page/261250 ]]>
/// </para>
/// </summary>
/// <param name="client"></param>
/// <param name="request"></param>
Expand All @@ -23,21 +26,24 @@ public static class TikTokShopClientExecuteAuthExtensions
if (request is null) throw new ArgumentNullException(nameof(request));

IFlurlRequest flurlReq = client
.CreateRequest(request, HttpMethod.Get, "token", "get")
.WithUrl($"{client.EndpointForAuthAPI}/token/get")
.CreateFlurlRequest(request, HttpMethod.Get, "token", "get")
.WithUrl($"{client.EndpointForAuth}/token/get")
.RemoveQueryParams("app_key", "access_token", "timestamp", "shop_id", "version")
.SetQueryParam("app_key", client.Credentials.AppKey)
.SetQueryParam("app_secret", client.Credentials.AppSecret)
.SetQueryParam("grant_type", request.GrantType)
.SetQueryParam("auth_code", request.AuthorizedCode);

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

/// <summary>
/// <para>异步调用 [GET] /token/refresh 接口。</para>
/// <para>REF: https://partner.tiktokshop.com/doc/page/261250 </para>
/// <para>REF: https://partner.tiktokshop.com/doc/page/262967 </para>
/// <para>
/// REF: <br/>
/// <![CDATA[ https://partner.tiktokshop.com/doc/page/261250 ]]> <br/>
/// <![CDATA[ https://partner.tiktokshop.com/doc/page/262967 ]]>
/// </para>
/// </summary>
/// <param name="client"></param>
/// <param name="request"></param>
Expand All @@ -49,15 +55,15 @@ public static class TikTokShopClientExecuteAuthExtensions
if (request is null) throw new ArgumentNullException(nameof(request));

IFlurlRequest flurlReq = client
.CreateRequest(request, HttpMethod.Get, "token", "refresh")
.WithUrl($"{client.EndpointForAuthAPI}/token/refresh")
.CreateFlurlRequest(request, HttpMethod.Get, "token", "refresh")
.WithUrl($"{client.EndpointForAuth}/token/refresh")
.RemoveQueryParams("app_key", "access_token", "timestamp", "shop_id", "version")
.SetQueryParam("app_key", client.Credentials.AppKey)
.SetQueryParam("app_secret", client.Credentials.AppSecret)
.SetQueryParam("grant_type", request.GrantType)
.SetQueryParam("refresh_token", request.RefreshToken);

return await client.SendRequestWithJsonAsync<Models.AuthRefreshTokenResponse>(flurlReq, data: request, cancellationToken: cancellationToken);
return await client.SendFlurlRequesAsJsontAsync<Models.AuthRefreshTokenResponse>(flurlReq, data: request, cancellationToken: cancellationToken).ConfigureAwait(false);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ public static class TikTokShopClientExecuteFinanceExtensions
{
/// <summary>
/// <para>异步调用 [POST] /finance/transactions/search 接口。</para>
/// <para>REF: https://partner.tiktokshop.com/doc/page/262881 </para>
/// <para>
/// REF: <br/>
/// <![CDATA[ https://partner.tiktokshop.com/doc/page/262881 ]]>
/// </para>
/// </summary>
/// <param name="client"></param>
/// <param name="request"></param>
Expand All @@ -23,14 +26,17 @@ public static class TikTokShopClientExecuteFinanceExtensions
if (request is null) throw new ArgumentNullException(nameof(request));

IFlurlRequest flurlReq = client
.CreateRequest(request, HttpMethod.Post, "finance", "transactions", "search");
.CreateFlurlRequest(request, HttpMethod.Post, "finance", "transactions", "search");

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

/// <summary>
/// <para>异步调用 [POST] /finance/settlements/search 接口。</para>
/// <para>REF: https://partner.tiktokshop.com/doc/page/262880 </para>
/// <para>
/// REF: <br/>
/// <![CDATA[ https://partner.tiktokshop.com/doc/page/262880 ]]>
/// </para>
/// </summary>
/// <param name="client"></param>
/// <param name="request"></param>
Expand All @@ -42,14 +48,17 @@ public static class TikTokShopClientExecuteFinanceExtensions
if (request is null) throw new ArgumentNullException(nameof(request));

IFlurlRequest flurlReq = client
.CreateRequest(request, HttpMethod.Post, "finance", "settlements", "search");
.CreateFlurlRequest(request, HttpMethod.Post, "finance", "settlements", "search");

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

/// <summary>
/// <para>异步调用 [GET] /finance/order/settlements 接口。</para>
/// <para>REF: https://partner.tiktokshop.com/doc/page/262880 </para>
/// <para>
/// REF: <br/>
/// <![CDATA[ https://partner.tiktokshop.com/doc/page/262880 ]]>
/// </para>
/// </summary>
/// <param name="client"></param>
/// <param name="request"></param>
Expand All @@ -61,10 +70,10 @@ public static class TikTokShopClientExecuteFinanceExtensions
if (request is null) throw new ArgumentNullException(nameof(request));

IFlurlRequest flurlReq = client
.CreateRequest(request, HttpMethod.Get, "finance", "order", "settlements")
.CreateFlurlRequest(request, HttpMethod.Get, "finance", "order", "settlements")
.SetQueryParam("order_id", request.OrderId);

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

0 comments on commit 85c6ebe

Please sign in to comment.