Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support check_page and env_version for the getwxacodeunlimit API #97

Merged
merged 1 commit into from
Aug 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ namespace EasyAbp.Abp.WeChat.MiniProgram.Services.ACode
/// </summary>
public class ACodeWeService : MiniProgramAbpWeChatServiceBase
{
public ACodeWeService(AbpWeChatMiniProgramOptions options, IAbpLazyServiceProvider lazyServiceProvider) : base(options, lazyServiceProvider)
public ACodeWeService(AbpWeChatMiniProgramOptions options, IAbpLazyServiceProvider lazyServiceProvider) : base(
options, lazyServiceProvider)
{
}

Expand All @@ -19,16 +20,20 @@ public ACodeWeService(AbpWeChatMiniProgramOptions options, IAbpLazyServiceProvid
/// </summary>
/// <param name="scene">最大32个可见字符,只支持数字,大小写英文以及部分特殊字符:!#$&'()*+,/:;=?@-._~,其它字符请自行编码为合法字符(因不支持%,中文无法使用 urlencode 处理,请使用其他编码方式)</param>
/// <param name="page">必须是已经发布的小程序存在的页面(否则报错),例如 pages/index/index, 根路径前不要填加 /,不能携带参数(参数请放在scene字段里),如果不填写这个字段,默认跳主页面</param>
/// <param name="checkPage">检查 page 是否存在,为 true 时 page 必须是已经发布的小程序存在的页面(否则报错);为 false 时允许小程序未发布或者 page 不存在, 但 page 有数量上限(60000个)请勿滥用</param>
/// <param name="envVersion">要打开的小程序版本。正式版为 release,体验版为 trial,开发版为 develop</param>
/// <param name="width">二维码的宽度,单位 px,最小 280px,最大 1280px</param>
/// <param name="autoColor">自动配置线条颜色,如果颜色依然是黑色,则说明不建议配置主色调,默认 false</param>
/// <param name="lineColor">auto_color 为 false 时生效,使用 rgb 设置颜色 例如 {"r":"xxx","g":"xxx","b":"xxx"} 十进制表示</param>
/// <param name="isHyaline">是否需要透明底色,为 true 时,生成透明底色的小程序</param>
public virtual Task<GetUnlimitedACodeResponse> GetUnlimitedACodeAsync(string scene, string page = null,
short width = 430, bool autoColor = false, LineColorModel lineColor = null, bool isHyaline = false)
bool checkPage = true, string envVersion = "release", short width = 430, bool autoColor = false,
LineColorModel lineColor = null, bool isHyaline = false)
{
const string targetUrl = "https://api.weixin.qq.com/wxa/getwxacodeunlimit";

var request = new GetUnlimitedACodeRequest(scene, page, width, autoColor, lineColor, isHyaline);
var request = new GetUnlimitedACodeRequest(
scene, page, checkPage, envVersion, width, autoColor, lineColor, isHyaline);

return ApiRequester.RequestGetBinaryDataAsync<GetUnlimitedACodeResponse>(
targetUrl, HttpMethod.Post, request, Options);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,53 +23,70 @@ public class GetUnlimitedACodeRequest : MiniProgramCommonRequest
[JsonProperty("page")]
public string Page { get; protected set; }

/// <summary>
/// 检查 page 是否存在,为 true 时 page 必须是已经发布的小程序存在的页面(否则报错);为 false 时允许小程序未发布或者 page 不存在, 但 page 有数量上限(60000个)请勿滥用
/// </summary>
[JsonPropertyName("check_path")]
[JsonProperty("check_path")]
public bool CheckPage { get; protected set; }

/// <summary>
/// 要打开的小程序版本。正式版为 release,体验版为 trial,开发版为 develop
/// </summary>
[JsonPropertyName("env_version")]
[JsonProperty("env_version")]
public string EnvVersion { get; protected set; }

/// <summary>
/// 二维码的宽度,单位 px,最小 280px,最大 1280px
/// </summary>
[JsonPropertyName("width")]
[JsonProperty("width")]
public short Width { get; protected set; }

/// <summary>
/// 自动配置线条颜色,如果颜色依然是黑色,则说明不建议配置主色调,默认 false
/// </summary>
[JsonPropertyName("auto_color")]
[JsonProperty("auto_color")]
public bool AutoColor { get; set; }

/// <summary>
/// auto_color 为 false 时生效,使用 rgb 设置颜色 例如 {"r":"xxx","g":"xxx","b":"xxx"} 十进制表示
/// </summary>
[JsonPropertyName("line_color")]
[JsonProperty("line_color")]
public LineColorModel LineColor { get; set; }

/// <summary>
/// 是否需要透明底色,为 true 时,生成透明底色的小程序
/// </summary>
[JsonPropertyName("is_hyaline")]
[JsonProperty("is_hyaline")]
public bool IsHyaline { get; set; }

protected GetUnlimitedACodeRequest()
{

}

/// <summary>
/// 构造一个新的 <see cref="GetUnlimitedACodeRequest"/> 实例。
/// </summary>
/// <param name="scene">最大32个可见字符,只支持数字,大小写英文以及部分特殊字符:!#$&'()*+,/:;=?@-._~,其它字符请自行编码为合法字符(因不支持%,中文无法使用 urlencode 处理,请使用其他编码方式)</param>
/// <param name="page">必须是已经发布的小程序存在的页面(否则报错),例如 pages/index/index, 根路径前不要填加 /,不能携带参数(参数请放在scene字段里),如果不填写这个字段,默认跳主页面</param>
/// <param name="checkPage">检查 page 是否存在,为 true 时 page 必须是已经发布的小程序存在的页面(否则报错);为 false 时允许小程序未发布或者 page 不存在, 但 page 有数量上限(60000个)请勿滥用</param>
/// <param name="envVersion">要打开的小程序版本。正式版为 release,体验版为 trial,开发版为 develop</param>
/// <param name="width">二维码的宽度,单位 px,最小 280px,最大 1280px</param>
/// <param name="autoColor">自动配置线条颜色,如果颜色依然是黑色,则说明不建议配置主色调,默认 false</param>
/// <param name="lineColor">auto_color 为 false 时生效,使用 rgb 设置颜色 例如 {"r":"xxx","g":"xxx","b":"xxx"} 十进制表示</param>
/// <param name="isHyaline">是否需要透明底色,为 true 时,生成透明底色的小程序</param>
public GetUnlimitedACodeRequest(string scene, string page, short width, bool autoColor,
LineColorModel lineColor, bool isHyaline)
public GetUnlimitedACodeRequest(string scene, string page, bool checkPage, string envVersion, short width,
bool autoColor, LineColorModel lineColor, bool isHyaline)
{
Scene = scene;
Page = page;
CheckPage = checkPage;
EnvVersion = envVersion;
Width = width;
AutoColor = autoColor;
LineColor = lineColor;
Expand Down