using System; using System.Collections.Generic; using System.Linq; using System.Net.Http; using System.Text; using System.Threading; using System.Threading.Tasks; using Flurl; using Flurl.Http; namespace SKIT.FlurlHttpClient.Wechat.Api { public static class WechatApiClientExecuteUnionPromoterExtensions { #region Promotion /// /// 异步调用 [POST] /union/promoter/promotion/add 接口。 /// REF: https://developers.weixin.qq.com/doc/ministore/union/access-guidelines/promoter/api/promotion.html#_1-%E6%B7%BB%E5%8A%A0%E6%8E%A8%E5%B9%BF%E4%BD%8D /// /// /// /// /// public static async Task ExecuteUnionPromoterPromotionAddAsync(this WechatApiClient client, Models.UnionPromoterPromotionAddRequest 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 .CreateRequest(request, HttpMethod.Post, "union", "promoter", "promotion", "add") .SetQueryParam("access_token", request.AccessToken); return await client.SendRequestWithJsonAsync(flurlReq, data: request, cancellationToken: cancellationToken); } /// /// 异步调用 [POST] /union/promoter/promotion/del 接口。 /// REF: https://developers.weixin.qq.com/doc/ministore/union/access-guidelines/promoter/api/promotion.html#_2-%E5%88%A0%E9%99%A4%E6%8E%A8%E5%B9%BF%E4%BD%8D /// /// /// /// /// public static async Task ExecuteUnionPromoterPromotionDeleteAsync(this WechatApiClient client, Models.UnionPromoterPromotionDeleteRequest 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 .CreateRequest(request, HttpMethod.Post, "union", "promoter", "promotion", "del") .SetQueryParam("access_token", request.AccessToken); return await client.SendRequestWithJsonAsync(flurlReq, data: request, cancellationToken: cancellationToken); } /// /// 异步调用 [POST] /union/promoter/promotion/upd 接口。 /// REF: https://developers.weixin.qq.com/doc/ministore/union/access-guidelines/promoter/api/promotion.html#_3-%E7%BC%96%E8%BE%91%E6%8E%A8%E5%B9%BF%E4%BD%8D /// /// /// /// /// public static async Task ExecuteUnionPromoterPromotionUpdateAsync(this WechatApiClient client, Models.UnionPromoterPromotionUpdateRequest 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 .CreateRequest(request, HttpMethod.Post, "union", "promoter", "promotion", "upd") .SetQueryParam("access_token", request.AccessToken); return await client.SendRequestWithJsonAsync(flurlReq, data: request, cancellationToken: cancellationToken); } /// /// 异步调用 [GET] /union/promoter/promotion/list 接口。 /// REF: https://developers.weixin.qq.com/doc/ministore/union/access-guidelines/promoter/api/promotion.html#_4-%E8%8E%B7%E5%8F%96%E6%8E%A8%E5%B9%BF%E4%BD%8D%E5%88%97%E8%A1%A8 /// /// /// /// /// public static async Task ExecuteUnionPromoterPromotionListAsync(this WechatApiClient client, Models.UnionPromoterPromotionListRequest 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 .CreateRequest(request, HttpMethod.Get, "union", "promoter", "promotion", "list") .SetQueryParam("access_token", request.AccessToken) .SetQueryParam("start", request.Offset) .SetQueryParam("limit", request.Limit); return await client.SendRequestWithJsonAsync(flurlReq, data: request, cancellationToken: cancellationToken); } #endregion #region Product /// /// 异步调用 [GET] /union/promoter/product/category 接口。 /// REF: https://developers.weixin.qq.com/doc/ministore/union/access-guidelines/promoter/api/product/category.html#_1-%E8%8E%B7%E5%8F%96%E8%81%94%E7%9B%9F%E5%95%86%E5%93%81%E7%B1%BB%E7%9B%AE%E5%88%97%E8%A1%A8%E5%8F%8A%E7%B1%BB%E7%9B%AEID /// REF: https://developers.weixin.qq.com/miniprogram/dev/platform-capabilities/business-capabilities/union/access-guidelines/promoter/api/product/category.html /// /// /// /// /// public static async Task ExecuteUnionPromoterProductCategoryAsync(this WechatApiClient client, Models.UnionPromoterProductCategoryRequest 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 .CreateRequest(request, HttpMethod.Get, "union", "promoter", "product", "category") .SetQueryParam("access_token", request.AccessToken); return await client.SendRequestWithJsonAsync(flurlReq, data: request, cancellationToken: cancellationToken); } /// /// 异步调用 [GET] /union/promoter/product/list 接口。 /// REF: https://developers.weixin.qq.com/doc/ministore/union/access-guidelines/promoter/api/product/category.html#_2-%E6%9F%A5%E8%AF%A2%E5%95%86%E5%93%81%E8%AF%A6%E6%83%85%E4%BF%A1%E6%81%AF /// REF: https://developers.weixin.qq.com/miniprogram/dev/platform-capabilities/business-capabilities/union/access-guidelines/promoter/api/product/category.html /// /// /// /// /// public static async Task ExecuteUnionPromoterProductListAsync(this WechatApiClient client, Models.UnionPromoterProductListRequest 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 .CreateRequest(request, HttpMethod.Get, "union", "promoter", "product", "list") .SetQueryParam("access_token", request.AccessToken) .SetQueryParam("from", request.Offset) .SetQueryParam("limit", request.Limit); if (request.QueryType.HasValue) flurlReq.SetQueryParam("queryType", request.QueryType.Value); if (!string.IsNullOrEmpty(request.Query)) flurlReq.SetQueryParam("query", request.Query); if (request.MaxPrice.HasValue) flurlReq.SetQueryParam("maxPrice", request.MaxPrice.Value); if (request.MinPrice.HasValue) flurlReq.SetQueryParam("minPrice", request.MinPrice.Value); if (request.MinCommissionValue.HasValue) flurlReq.SetQueryParam("minCommissionValue", request.MinCommissionValue.Value); if (request.MinCommissionRatio.HasValue) flurlReq.SetQueryParam("minCommissionRatio", request.MinCommissionRatio.Value); if (request.SortType.HasValue) flurlReq.SetQueryParam("sortType", request.SortType.Value); if (request.HasCoupon.HasValue) flurlReq.SetQueryParam("hasCoupon", request.HasCoupon.Value ? 1 : 0); if (request.ShopAppIdList != null) flurlReq.SetQueryParam("shopAppIds", string.Join(",", request.ShopAppIdList)); if (request.CategoryId.HasValue) flurlReq.SetQueryParam("categoryId", request.CategoryId); if (request.CategoryIdList != null) flurlReq.SetQueryParam("category", string.Join(",", request.CategoryIdList)); if (request.CategoryIdBlackList != null) flurlReq.SetQueryParam("noCategory", string.Join(",", request.CategoryIdBlackList)); if (request.ProductIdList != null) flurlReq.SetQueryParam("productId", string.Join(",", request.ProductIdList)); return await client.SendRequestWithJsonAsync(flurlReq, data: request, cancellationToken: cancellationToken); } /// /// 异步调用 [GET] /union/promoter/product/select 接口。 /// REF: https://developers.weixin.qq.com/miniprogram/dev/platform-capabilities/business-capabilities/union/access-guidelines/promoter/api/product/category.html /// /// /// /// /// public static async Task ExecuteUnionPromoterProductSelectAsync(this WechatApiClient client, Models.UnionPromoterProductSelectRequest 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 .CreateRequest(request, HttpMethod.Get, "union", "promoter", "product", "select") .SetQueryParam("access_token", request.AccessToken) .SetQueryParam("from", request.Offset) .SetQueryParam("limit", request.Limit); if (request.MaxPrice.HasValue) flurlReq.SetQueryParam("maxPrice", request.MaxPrice.Value); if (request.MinPrice.HasValue) flurlReq.SetQueryParam("minPrice", request.MinPrice.Value); if (request.MinCommissionValue.HasValue) flurlReq.SetQueryParam("minCommissionValue", request.MinCommissionValue.Value); if (request.MinCommissionRatio.HasValue) flurlReq.SetQueryParam("minCommissionRatio", request.MinCommissionRatio.Value); if (request.SortType.HasValue) flurlReq.SetQueryParam("sortType", request.SortType.Value); if (request.HasCoupon.HasValue) flurlReq.SetQueryParam("hasCoupon", request.HasCoupon.Value ? 1 : 0); if (request.ShopAppIdList != null) flurlReq.SetQueryParam("shopAppIds", string.Join(",", request.ShopAppIdList)); if (request.CategoryId.HasValue) flurlReq.SetQueryParam("categoryId", request.CategoryId); if (request.CategoryIdList != null) flurlReq.SetQueryParam("category", string.Join(",", request.CategoryIdList)); if (request.CategoryIdBlackList != null) flurlReq.SetQueryParam("noCategory", string.Join(",", request.CategoryIdBlackList)); if (request.ProductIdList != null) flurlReq.SetQueryParam("productId", string.Join(",", request.ProductIdList)); if (request.ShippingMethods != null) flurlReq.SetQueryParam("shippingMethods", client.JsonSerializer.Serialize(request.ShippingMethods)); if (request.AddressList != null) flurlReq.SetQueryParam("addressList", client.JsonSerializer.Serialize(request.AddressList)); return await client.SendRequestWithJsonAsync(flurlReq, data: request, cancellationToken: cancellationToken); } /// /// 异步调用 [POST] /union/promoter/product/generate 接口。 /// REF: https://developers.weixin.qq.com/doc/ministore/union/access-guidelines/promoter/api/product/category.html#_3-%E8%8E%B7%E5%8F%96%E5%95%86%E5%93%81%E6%8E%A8%E5%B9%BF%E7%B4%A0%E6%9D%90 /// REF: https://developers.weixin.qq.com/miniprogram/dev/platform-capabilities/business-capabilities/union/access-guidelines/promoter/api/product/category.html /// /// /// /// /// public static async Task ExecuteUnionPromoterProductGenerateAsync(this WechatApiClient client, Models.UnionPromoterProductGenerateRequest 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 .CreateRequest(request, HttpMethod.Post, "union", "promoter", "product", "generate") .SetQueryParam("access_token", request.AccessToken); return await client.SendRequestWithJsonAsync(flurlReq, data: request, cancellationToken: cancellationToken); } #endregion #region Order /// /// 异步调用 [POST] /union/promoter/order/info 接口。 /// REF: https://developers.weixin.qq.com/doc/ministore/union/access-guidelines/promoter/api/order/order-info.html#_1-%E6%A0%B9%E6%8D%AE%E8%AE%A2%E5%8D%95ID%E6%9F%A5%E8%AF%A2%E8%AE%A2%E5%8D%95%E8%AF%A6%E6%83%85 /// /// /// /// /// public static async Task ExecuteUnionPromoterOrderInfoAsync(this WechatApiClient client, Models.UnionPromoterOrderInfoRequest 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 .CreateRequest(request, HttpMethod.Post, "union", "promoter", "order", "info") .SetQueryParam("access_token", request.AccessToken); return await client.SendRequestWithJsonAsync(flurlReq, data: request, cancellationToken: cancellationToken); } /// /// 异步调用 [GET] /union/promoter/order/search 接口。 /// REF: https://developers.weixin.qq.com/doc/ministore/union/access-guidelines/promoter/api/order/order-info.html#_2-%E6%A0%B9%E6%8D%AE%E8%AE%A2%E5%8D%95%E6%94%AF%E4%BB%98%E6%97%B6%E9%97%B4%E3%80%81%E8%AE%A2%E5%8D%95%E5%88%86%E4%BD%A3%E7%8A%B6%E6%80%81%E6%8B%89%E5%8F%96%E8%AE%A2%E5%8D%95%E8%AF%A6%E6%83%85 /// /// /// /// /// public static async Task ExecuteUnionPromoterOrderSearchAsync(this WechatApiClient client, Models.UnionPromoterOrderSearchRequest 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 .CreateRequest(request, HttpMethod.Get, "union", "promoter", "order", "search") .SetQueryParam("access_token", request.AccessToken) .SetQueryParam("page", request.Page); if (request.StartTimestamp.HasValue) flurlReq.SetQueryParam("startTimestamp", request.StartTimestamp.Value); if (request.EndTimestamp.HasValue) flurlReq.SetQueryParam("endTimestamp", request.EndTimestamp.Value); if (!string.IsNullOrEmpty(request.CommissionStatus)) flurlReq.SetQueryParam("commissionStatus", request.CommissionStatus); return await client.SendRequestWithJsonAsync(flurlReq, data: request, cancellationToken: cancellationToken); } #endregion #region Target /// /// 异步调用 [GET] /union/promoter/target/plan_info 接口。 /// REF: https://developers.weixin.qq.com/miniprogram/dev/platform-capabilities/business-capabilities/union/access-guidelines/promoter/api/target_plan/target_plan.html /// /// /// /// /// public static async Task ExecuteUnionPromoterTargetPlanInfoAsync(this WechatApiClient client, Models.UnionPromoterTargetPlanInfoRequest 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 .CreateRequest(request, HttpMethod.Get, "union", "promoter", "target", "plan_info") .SetQueryParam("access_token", request.AccessToken) .SetQueryParam("planInvitationUrl", request.PlanInvitaionUrl); return await client.SendRequestWithJsonAsync(flurlReq, data: request, cancellationToken: cancellationToken); } /// /// 异步调用 [POST] /union/promoter/target/apply_target 接口。 /// REF: https://developers.weixin.qq.com/miniprogram/dev/platform-capabilities/business-capabilities/union/access-guidelines/promoter/api/target_plan/target_plan.html /// /// /// /// /// public static async Task ExecuteUnionPromoterTargetApplyTargetAsync(this WechatApiClient client, Models.UnionPromoterTargetApplyTargetRequest 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 .CreateRequest(request, HttpMethod.Post, "union", "promoter", "target", "apply_target") .SetQueryParam("access_token", request.AccessToken); return await client.SendRequestWithJsonAsync(flurlReq, data: request, cancellationToken: cancellationToken); } /// /// 异步调用 [GET] /union/promoter/target/apply_status 接口。 /// REF: https://developers.weixin.qq.com/miniprogram/dev/platform-capabilities/business-capabilities/union/access-guidelines/promoter/api/target_plan/target_plan.html /// /// /// /// /// public static async Task ExecuteUnionPromoterTargetApplyStatusAsync(this WechatApiClient client, Models.UnionPromoterTargetApplyStatusRequest 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 .CreateRequest(request, HttpMethod.Get, "union", "promoter", "target", "apply_status") .SetQueryParam("access_token", request.AccessToken) .SetQueryParam("planId", request.PlanId); return await client.SendRequestWithJsonAsync(flurlReq, data: request, cancellationToken: cancellationToken); } #endregion #region OpenAccount /// /// 异步调用 [POST] /union/promoter/open_account/bind 接口。 /// REF: https://developers.weixin.qq.com/miniprogram/dev/platform-capabilities/business-capabilities/union/access-guidelines/promoter/api/customized-userinfo.html /// /// /// /// /// public static async Task ExecuteUnionPromoterOpenAccountBindAsync(this WechatApiClient client, Models.UnionPromoterOpenAccountBindRequest 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 .CreateRequest(request, HttpMethod.Post, "union", "promoter", "open_account", "bind") .SetQueryParam("access_token", request.AccessToken); return await client.SendRequestWithJsonAsync(flurlReq, data: request, cancellationToken: cancellationToken); } /// /// 异步调用 [GET] /union/promoter/open_account/get 接口。 /// REF: https://developers.weixin.qq.com/miniprogram/dev/platform-capabilities/business-capabilities/union/access-guidelines/promoter/api/customized-userinfo.html /// /// /// /// /// public static async Task ExecuteUnionPromoterOpenAccountGetAsync(this WechatApiClient client, Models.UnionPromoterOpenAccountGetRequest 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 .CreateRequest(request, HttpMethod.Get, "union", "promoter", "open_account", "get") .SetQueryParam("access_token", request.AccessToken); return await client.SendRequestWithJsonAsync(flurlReq, data: request, cancellationToken: cancellationToken); } /// /// 异步调用 [POST] /union/promoter/open_account/add_customize_info 接口。 /// REF: https://developers.weixin.qq.com/miniprogram/dev/platform-capabilities/business-capabilities/union/access-guidelines/promoter/api/customized-userinfo.html /// /// /// /// /// public static async Task ExecuteUnionPromoterOpenAccountAddCustomizeInfoAsync(this WechatApiClient client, Models.UnionPromoterOpenAccountAddCustomizeInfoRequest 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 .CreateRequest(request, HttpMethod.Post, "union", "promoter", "open_account", "add_customize_info") .SetQueryParam("access_token", request.AccessToken); return await client.SendRequestWithJsonAsync(flurlReq, data: request, cancellationToken: cancellationToken); } /// /// 异步调用 [POST] /union/promoter/open_account/del_customize_info 接口。 /// REF: https://developers.weixin.qq.com/miniprogram/dev/platform-capabilities/business-capabilities/union/access-guidelines/promoter/api/customized-userinfo.html /// /// /// /// /// public static async Task ExecuteUnionPromoterOpenAccountDeleteCustomizeInfoAsync(this WechatApiClient client, Models.UnionPromoterOpenAccountDeleteCustomizeInfoRequest 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 .CreateRequest(request, HttpMethod.Post, "union", "promoter", "open_account", "del_customize_info") .SetQueryParam("access_token", request.AccessToken); return await client.SendRequestWithJsonAsync(flurlReq, data: request, cancellationToken: cancellationToken); } /// /// 异步调用 [GET] /union/promoter/open_account/get_customize_info 接口。 /// REF: https://developers.weixin.qq.com/miniprogram/dev/platform-capabilities/business-capabilities/union/access-guidelines/promoter/api/customized-userinfo.html /// /// /// /// /// public static async Task ExecuteUnionPromoterOpenAccountGetCustomizeInfoAsync(this WechatApiClient client, Models.UnionPromoterOpenAccountGetCustomizeInfoRequest 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 .CreateRequest(request, HttpMethod.Get, "union", "promoter", "open_account", "get_customize_info") .SetQueryParam("access_token", request.AccessToken) .SetQueryParam("unionid", request.UnionId); return await client.SendRequestWithJsonAsync(flurlReq, data: request, cancellationToken: cancellationToken); } #endregion } }