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

第三方平台API 增加搜索状态接口 #2695

Merged
merged 7 commits into from
Aug 8, 2022
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
#region Apache License Version 2.0
/*----------------------------------------------------------------

Copyright 2022 Jeffrey Su & Suzhou Senparc Network Technology Co.,Ltd.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the
License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
either express or implied. See the License for the specific language governing permissions
and limitations under the License.

Detail: https://github.com/JeffreySu/WeiXinMPSDK/blob/master/license.md

----------------------------------------------------------------*/
#endregion Apache License Version 2.0

/*----------------------------------------------------------------
Copyright (C) 2022 Senparc

文件名:SearchStatusApi.cs
文件功能描述:搜索状态接口


创建标识:Yaofeng - 20220805

----------------------------------------------------------------*/

using Senparc.CO2NET.Extensions;
using Senparc.NeuChar;
using Senparc.Weixin.CommonAPIs;
using Senparc.Weixin.Entities;
using Senparc.Weixin.Open.WxaAPIs.ModifyDomain;
using Senparc.Weixin.Open.WxaAPIs.SearchStatus;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace Senparc.Weixin.Open.WxaAPIs
{
[NcApiBind(NeuChar.PlatformType.WeChat_Open, true)]
public class SearchStatusApi
{
#region 同步方法
/// <summary>
/// 获取搜索状态
/// </summary>
/// <param name="accessToken"></param>
/// <param name="timeOut"></param>
/// <returns></returns>
public static GetWxaSearchStatusResultJson GetWxaSearchStatus(string accessToken, int timeOut = Config.TIME_OUT)
{
var url = string.Format(Config.ApiMpHost + "/wxa/getwxasearchstatus?access_token={0}", accessToken.AsUrlData());
return CommonJsonSend.Send<GetWxaSearchStatusResultJson>(null, url, null, CommonJsonSendType.GET, timeOut);
}

/// <summary>
/// 设置搜索状态
/// </summary>
/// <param name="accessToken"></param>
/// <param name="timeOut"></param>
/// <returns></returns>
public static WxJsonResult ChangeWxaSearchStatus(string accessToken, int status, int timeOut = Config.TIME_OUT)
{
var url = string.Format(Config.ApiMpHost + "/wxa/changewxasearchstatus?access_token={0}", accessToken.AsUrlData());
object data = new
{
status = status
};
return CommonJsonSend.Send<WxJsonResult>(null, url, data, CommonJsonSendType.POST, timeOut);
}
#endregion

#region 异步方法
/// <summary>
/// 获取搜索状态
/// </summary>
/// <param name="accessToken"></param>
/// <param name="timeOut"></param>
/// <returns></returns>
public static async Task<GetWxaSearchStatusResultJson> GetWxaSearchStatusAsync(string accessToken, int timeOut = Config.TIME_OUT)
{
var url = string.Format(Config.ApiMpHost + "/wxa/getwxasearchstatus?access_token={0}", accessToken.AsUrlData());
return await CommonJsonSend.SendAsync<GetWxaSearchStatusResultJson>(null, url, null, CommonJsonSendType.GET, timeOut);
}

/// <summary>
/// 设置搜索状态
/// </summary>
/// <param name="accessToken"></param>
/// <param name="timeOut"></param>
/// <returns></returns>
public static async Task<WxJsonResult> ChangeWxaSearchStatusAsync(string accessToken, int status, int timeOut = Config.TIME_OUT)
{
var url = string.Format(Config.ApiMpHost + "/wxa/changewxasearchstatus?access_token={0}", accessToken.AsUrlData());
object data = new
{
status = status
};
return await CommonJsonSend.SendAsync<WxJsonResult>(null, url, data, CommonJsonSendType.POST, timeOut);
}
#endregion
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#region Apache License Version 2.0
/*----------------------------------------------------------------

Copyright 2022 Jeffrey Su & Suzhou Senparc Network Technology Co.,Ltd.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the
License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
either express or implied. See the License for the specific language governing permissions
and limitations under the License.

Detail: https://github.com/JeffreySu/WeiXinMPSDK/blob/master/license.md

----------------------------------------------------------------*/
#endregion Apache License Version 2.0

/*----------------------------------------------------------------
Copyright (C) 2022 Senparc

文件名:GetWxaSearchStatusJson.cs
文件功能描述:获取搜索状态返回类型


创建标识:Yaofeng - 20220805

----------------------------------------------------------------*/

using Senparc.Weixin.Entities;

namespace Senparc.Weixin.Open.WxaAPIs.SearchStatus
{
/// <summary>
/// 获取搜索状态返回类型
/// </summary>
public class GetWxaSearchStatusResultJson : WxJsonResult
{
/// <summary>
/// 1 表示不可搜索,0 表示可搜索
/// </summary>
public int status { get; set; }
}
}