Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
fudiwei committed Aug 8, 2024
1 parent 8030ae8 commit de0e586
Show file tree
Hide file tree
Showing 15 changed files with 99 additions and 239 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1237,12 +1237,10 @@ public static class DouyinOpenClientExecuteDataExternalExtensions
.CreateFlurlRequest(request, HttpMethod.Get, "data", "external", "poi", "service_base")
.WithHeader("access-token", request.AccessToken)
.SetQueryParam("poi_id", request.POIId)
.SetQueryParam("service_type", request.ServiceType)
.SetQueryParam("begin_date", request.BeginDateString)
.SetQueryParam("end_date", request.EndDateString);

if (request.ServiceType is not null)
flurlReq.SetQueryParam("service_type", request.ServiceType);

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

Expand All @@ -1266,10 +1264,8 @@ public static class DouyinOpenClientExecuteDataExternalExtensions
.CreateFlurlRequest(request, HttpMethod.Get, "data", "external", "poi", "service_user")
.WithHeader("access-token", request.AccessToken)
.SetQueryParam("poi_id", request.POIId)
.SetQueryParam("date_type", request.DateType);

if (request.ServiceType is not null)
flurlReq.SetQueryParam("service_type", request.ServiceType);
.SetQueryParam("date_type", request.DateType)
.SetQueryParam("service_type", request.ServiceType);

return await client.SendFlurlRequestAsJsonAsync<Models.DataExternalPOIServiceUserResponse>(flurlReq, data: request, cancellationToken: cancellationToken).ConfigureAwait(false);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,18 +228,12 @@ public static class DouyinOpenClientExecuteGoodLifeExtensions
IFlurlRequest flurlReq = client
.CreateFlurlRequest(request, HttpMethod.Get, "goodlife", "v1", "fulfilment", "certificate", "verify_record", "query")
.WithHeader("access-token", request.AccessToken)
.SetQueryParam("account_id", request.AccountId)
.SetQueryParam("poi_ids", request.POIIdList is null ? null : string.Join(",", request.POIIdList))
.SetQueryParam("start_time", request.StartTimestamp)
.SetQueryParam("end_time", request.EndTimestamp)
.SetQueryParam("cursor", request.PageCursor)
.SetQueryParam("size", request.PageSize)
.SetQueryParam("account_id", request.AccountId);

if (request.POIIdList is not null)
flurlReq.SetQueryParam("poi_ids", string.Join(",", request.POIIdList));

if (request.StartTimestamp is not null)
flurlReq.SetQueryParam("start_time", request.StartTimestamp);

if (request.EndTimestamp is not null)
flurlReq.SetQueryParam("end_time", request.EndTimestamp);
.SetQueryParam("size", request.PageSize);

return await client.SendFlurlRequestAsJsonAsync<Models.GoodLifeFulfilmentCertificateVerifyRecordQueryV1Response>(flurlReq, data: request, cancellationToken: cancellationToken).ConfigureAwait(false);
}
Expand Down Expand Up @@ -410,16 +404,10 @@ public static class DouyinOpenClientExecuteGoodLifeExtensions

IFlurlRequest flurlReq = client
.CreateFlurlRequest(request, HttpMethod.Get, "goodlife", "v1", "goods", "category", "get")
.WithHeader("access-token", request.AccessToken);

if (request.AccountId is not null)
flurlReq.SetQueryParam("account_id", request.AccountId);

if (request.ParentCategoryId is not null)
flurlReq.SetQueryParam("category_id", request.ParentCategoryId.Value);

if (request.QueryType is not null)
flurlReq.SetQueryParam("query_category_type", request.QueryType.Value);
.WithHeader("access-token", request.AccessToken)
.SetQueryParam("account_id", request.AccountId)
.SetQueryParam("category_id", request.ParentCategoryId)
.SetQueryParam("query_category_type", request.QueryType);

return await client.SendFlurlRequestAsJsonAsync<Models.GoodLifeGoodsCategoryGetV1Response>(flurlReq, data: request, cancellationToken: cancellationToken).ConfigureAwait(false);
}
Expand Down Expand Up @@ -513,19 +501,11 @@ public static class DouyinOpenClientExecuteGoodLifeExtensions

IFlurlRequest flurlReq = client
.CreateFlurlRequest(request, HttpMethod.Get, "goodlife", "v1", "goods", "product", "draft", "query")
.WithHeader("access-token", request.AccessToken);

if (request.AccountId is not null)
flurlReq.SetQueryParam("account_id", request.AccountId);

if (request.Status is not null)
flurlReq.SetQueryParam("status", request.Status.Value);

if (request.PageCursor is not null)
flurlReq.SetQueryParam("cursor", request.PageCursor);

if (request.PageSize is not null)
flurlReq.SetQueryParam("count", request.PageSize.Value);
.WithHeader("access-token", request.AccessToken)
.SetQueryParam("account_id", request.AccountId)
.SetQueryParam("status", request.Status)
.SetQueryParam("cursor", request.PageCursor)
.SetQueryParam("count", request.PageSize);

return await client.SendFlurlRequestAsJsonAsync<Models.GoodLifeGoodsProductDraftQueryV1Response>(flurlReq, data: request, cancellationToken: cancellationToken).ConfigureAwait(false);
}
Expand All @@ -548,16 +528,10 @@ public static class DouyinOpenClientExecuteGoodLifeExtensions

IFlurlRequest flurlReq = client
.CreateFlurlRequest(request, HttpMethod.Get, "goodlife", "v1", "goods", "product", "draft", "get")
.WithHeader("access-token", request.AccessToken);

if (request.AccountId is not null)
flurlReq.SetQueryParam("account_id", request.AccountId);

if (request.ProductIdList is not null)
flurlReq.SetQueryParam("product_ids", string.Join(",", request.ProductIdList));

if (request.OutProductIdList is not null)
flurlReq.SetQueryParam("out_ids", string.Join(",", request.OutProductIdList));
.WithHeader("access-token", request.AccessToken)
.SetQueryParam("account_id", request.AccountId)
.SetQueryParam("product_ids", request.ProductIdList is null ? null : string.Join(",", request.ProductIdList))
.SetQueryParam("out_ids", request.OutProductIdList is null ? null : string.Join(",", request.OutProductIdList));

return await client.SendFlurlRequestAsJsonAsync<Models.GoodLifeGoodsProductDraftGetV1Response>(flurlReq, data: request, cancellationToken: cancellationToken).ConfigureAwait(false);
}
Expand All @@ -580,19 +554,11 @@ public static class DouyinOpenClientExecuteGoodLifeExtensions

IFlurlRequest flurlReq = client
.CreateFlurlRequest(request, HttpMethod.Get, "goodlife", "v1", "goods", "product", "online", "query")
.WithHeader("access-token", request.AccessToken);

if (request.AccountId is not null)
flurlReq.SetQueryParam("account_id", request.AccountId);

if (request.Status is not null)
flurlReq.SetQueryParam("status", request.Status.Value);

if (request.PageCursor is not null)
flurlReq.SetQueryParam("cursor", request.PageCursor);

if (request.PageSize is not null)
flurlReq.SetQueryParam("count", request.PageSize.Value);
.WithHeader("access-token", request.AccessToken)
.SetQueryParam("account_id", request.AccountId)
.SetQueryParam("status", request.Status)
.SetQueryParam("cursor", request.PageCursor)
.SetQueryParam("count", request.PageSize);

return await client.SendFlurlRequestAsJsonAsync<Models.GoodLifeGoodsProductOnlineQueryV1Response>(flurlReq, data: request, cancellationToken: cancellationToken).ConfigureAwait(false);
}
Expand All @@ -615,16 +581,10 @@ public static class DouyinOpenClientExecuteGoodLifeExtensions

IFlurlRequest flurlReq = client
.CreateFlurlRequest(request, HttpMethod.Get, "goodlife", "v1", "goods", "product", "online", "get")
.WithHeader("access-token", request.AccessToken);

if (request.AccountId is not null)
flurlReq.SetQueryParam("account_id", request.AccountId);

if (request.ProductIdList is not null)
flurlReq.SetQueryParam("product_ids", string.Join(",", request.ProductIdList));

if (request.OutProductIdList is not null)
flurlReq.SetQueryParam("out_ids", string.Join(",", request.OutProductIdList));
.WithHeader("access-token", request.AccessToken)
.SetQueryParam("account_id", request.AccountId)
.SetQueryParam("product_ids", request.ProductIdList is null ? null : string.Join(",", request.ProductIdList))
.SetQueryParam("out_ids", request.OutProductIdList is null ? null : string.Join(",", request.OutProductIdList));

return await client.SendFlurlRequestAsJsonAsync<Models.GoodLifeGoodsProductOnlineGetV1Response>(flurlReq, data: request, cancellationToken: cancellationToken).ConfigureAwait(false);
}
Expand Down Expand Up @@ -927,24 +887,14 @@ public static class DouyinOpenClientExecuteGoodLifeExtensions
IFlurlRequest flurlReq = client
.CreateFlurlRequest(request, HttpMethod.Get, "goodlife", "v1", "partner", "order", "query")
.WithHeader("access-token", request.AccessToken)
.SetQueryParam("account_id", request.AccountId)
.SetQueryParam("cooperation_contents", request.CooperationContentType)
.SetQueryParam("start_time", request.StartTimestamp)
.SetQueryParam("end_time", request.EndTimestamp)
.SetQueryParam("status", request.Status)
.SetQueryParam("page", request.PageNumber)
.SetQueryParam("size", request.PageSize)
.SetQueryParam("is_asc", request.IsSortByAsc.GetValueOrDefault() ? "true" : "false");

if (request.AccountId is not null)
flurlReq.SetQueryParam("account_id", request.AccountId);

if (request.CooperationContentType is not null)
flurlReq.SetQueryParam("cooperation_contents", request.CooperationContentType.Value);

if (request.StartTimestamp is not null)
flurlReq.SetQueryParam("start_time", request.StartTimestamp.Value);

if (request.EndTimestamp is not null)
flurlReq.SetQueryParam("end_time", request.EndTimestamp.Value);

if (request.Status is not null)
flurlReq.SetQueryParam("status", request.Status.Value);
.SetQueryParam("is_asc", request.IsSortByAsc.HasValue ? request.IsSortByAsc.Value ? "true" : "false" : null);

return await client.SendFlurlRequestAsJsonAsync<Models.GoodLifePartnerOrderQueryV1Response>(flurlReq, data: request, cancellationToken: cancellationToken).ConfigureAwait(false);
}
Expand Down Expand Up @@ -1370,36 +1320,18 @@ public static class DouyinOpenClientExecuteGoodLifeExtensions
.CreateFlurlRequest(request, HttpMethod.Get, "goodlife", "v1", "trade", "order", "query")
.WithHeader("access-token", request.AccessToken)
.SetQueryParam("account_id", request.AccountId)
.SetQueryParam("order_id", request.OrderId)
.SetQueryParam("ext_order_id", request.OrderExternalId)
.SetQueryParam("open_id", request.OpenId)
.SetQueryParam("order_status", request.OrderStatus)
.SetQueryParam("create_order_start_time", request.CreateOrderStartTimestamp)
.SetQueryParam("create_order_end_time", request.CreateOrderEndTimestamp)
.SetQueryParam("update_order_start_time", request.UpdateOrderStartTimestamp)
.SetQueryParam("update_order_end_time", request.UpdateOrderEndTimestamp)
.SetQueryParam("get_secret_number", request.RequireGetSecretNumber.HasValue ? request.RequireGetSecretNumber.Value ? "true" : "false" : null)
.SetQueryParam("page_num", request.PageNumber)
.SetQueryParam("page_size", request.PageSize);

if (request.OrderId is not null)
flurlReq.SetQueryParam("order_id", request.OrderId);

if (request.OrderExternalId is not null)
flurlReq.SetQueryParam("ext_order_id", request.OrderExternalId);

if (request.OpenId is not null)
flurlReq.SetQueryParam("open_id", request.OpenId);

if (request.OrderStatus is not null)
flurlReq.SetQueryParam("order_status", request.OrderStatus);

if (request.CreateOrderStartTimestamp is not null)
flurlReq.SetQueryParam("create_order_start_time", request.CreateOrderStartTimestamp);

if (request.CreateOrderEndTimestamp is not null)
flurlReq.SetQueryParam("create_order_end_time", request.CreateOrderEndTimestamp);

if (request.UpdateOrderStartTimestamp is not null)
flurlReq.SetQueryParam("update_order_start_time", request.UpdateOrderStartTimestamp);

if (request.UpdateOrderEndTimestamp is not null)
flurlReq.SetQueryParam("update_order_end_time", request.UpdateOrderEndTimestamp);

if (request.RequireGetSecretNumber is not null)
flurlReq.SetQueryParam("get_secret_number", request.RequireGetSecretNumber.Value ? "true" : "false");

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

Expand All @@ -1422,13 +1354,9 @@ public static class DouyinOpenClientExecuteGoodLifeExtensions
IFlurlRequest flurlReq = client
.CreateFlurlRequest(request, HttpMethod.Get, "goodlife", "v1", "trade", "book", "get")
.WithHeader("access-token", request.AccessToken)
.SetQueryParam("account_id", request.AccountId);

if (request.BookId is not null)
flurlReq.SetQueryParam("book_id", request.BookId);

if (request.OrderId is not null)
flurlReq.SetQueryParam("order_id", request.OrderId);
.SetQueryParam("account_id", request.AccountId)
.SetQueryParam("book_id", request.BookId)
.SetQueryParam("order_id", request.OrderId);

return await client.SendFlurlRequestAsJsonAsync<Models.GoodLifeTradeBookGetV1Response>(flurlReq, data: request, cancellationToken: cancellationToken).ConfigureAwait(false);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -775,10 +775,8 @@ public static class DouyinOpenClientExecutePOIExtensions
.WithHeader("access-token", request.AccessToken)
.SetQueryParam("spu_ext_id", request.SPUExternalId)
.SetQueryParam("need_spu_draft", request.RequireSPUDraft)
.SetQueryParam("spu_draft_count", request.SPUDraftCount);

if (request.SupplierIdForFilterReasonList is not null)
flurlReq.SetQueryParam("supplier_ids_for_filter_reason", string.Join(",", request.SupplierIdForFilterReasonList));
.SetQueryParam("spu_draft_count", request.SPUDraftCount)
.SetQueryParam("supplier_ids_for_filter_reason", request.SupplierIdForFilterReasonList is null ? null : string.Join(",", request.SupplierIdForFilterReasonList));

return await client.SendFlurlRequestAsJsonAsync<Models.POISPUGetV2Response>(flurlReq, data: request, cancellationToken: cancellationToken).ConfigureAwait(false);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,11 @@ public static class DouyinOpenClientExecuteShareIdExtensions

IFlurlRequest flurlReq = client
.CreateFlurlRequest(request, HttpMethod.Get, "share-id/")
.WithHeader("access-token", request.AccessToken);

if (request.RequireCallback is not null)
flurlReq.SetQueryParam("need_callback", request.RequireCallback.Value ? "true" : "false");

if (request.SourceStyleId is not null)
flurlReq.SetQueryParam("source_style_id", request.SourceStyleId);

if (request.DefaultHashTag is not null)
flurlReq.SetQueryParam("default_hashtag", request.DefaultHashTag);

if (request.LinkParameter is not null)
flurlReq.SetQueryParam("link_param", request.LinkParameter);
.WithHeader("access-token", request.AccessToken)
.SetQueryParam("need_callback", request.RequireCallback.HasValue ? request.RequireCallback.Value ? "true" : "false" : null)
.SetQueryParam("source_style_id", request.SourceStyleId)
.SetQueryParam("default_hashtag", request.DefaultHashTag)
.SetQueryParam("link_param", request.LinkParameter);

return await client.SendFlurlRequestAsJsonAsync<Models.ShareIdResponse>(flurlReq, data: request, cancellationToken: cancellationToken).ConfigureAwait(false);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,10 @@ public static class DouyinMicroAppWebcastClientExecuteQuizExtensions

IFlurlRequest flurlReq = client
.CreateFlurlRequest(request, HttpMethod.Get, "quiz", "get")
.WithHeader("X-Token", request.AccessToken);

if (request.Level is not null)
flurlReq.SetQueryParam("level", request.Level.Value);

if (request.Type is not null)
flurlReq.SetQueryParam("type", request.Type.Value);

if (request.Number is not null)
flurlReq.SetQueryParam("num", request.Number.Value);
.WithHeader("X-Token", request.AccessToken)
.SetQueryParam("level", request.Level)
.SetQueryParam("type", request.Type)
.SetQueryParam("num", request.Number);

return await client.SendFlurlRequestAsJsonAsync<Models.WebcastQuizGetResponse>(flurlReq, data: request, cancellationToken: cancellationToken).ConfigureAwait(false);
}
Expand Down
Loading

0 comments on commit de0e586

Please sign in to comment.