123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534 |
- #region Apache License Version 2.0
- #endregion Apache License Version 2.0
- using System.Collections.Generic;
- using System.IO;
- using System.Threading.Tasks;
- using Senparc.CO2NET.Extensions;
- using Senparc.NeuChar;
- using Senparc.Weixin.CommonAPIs;
- using Senparc.Weixin.Entities;
- using Senparc.Weixin.Helpers;
- using Senparc.Weixin.HttpUtility;
- using Senparc.Weixin.MP.AdvancedAPIs.GroupMessage;
- using Senparc.Weixin.MP.AdvancedAPIs.Scan;
- using Senparc.Weixin.MP.CommonAPIs;
- namespace Senparc.Weixin.MP.AdvancedAPIs
- {
-
-
-
- public static class ScanApi
- {
- #region 同步方法
-
-
-
-
-
-
- [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "ScanApi.MerchantInfoGet", true)]
- public static MerchantInfoGetResultJson MerchantInfoGet(string accessTokenOrAppId, int timeOut = Config.TIME_OUT)
- {
- return ApiHandlerWapper.TryCommonApi(accessToken =>
- {
- var urlFormat = string.Format(Config.ApiMpHost + "/scan/merchantinfo/get?access_token={0}", accessToken.AsUrlData());
- return CommonJsonSend.Send<MerchantInfoGetResultJson>(null, urlFormat, null, CommonJsonSendType.GET, timeOut: timeOut);
- }, accessTokenOrAppId);
- }
-
-
-
-
-
-
-
-
-
- [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "ScanApi.ProductCreate", true)]
- public static ProductCreateResultJson ProductCreate(string accessTokenOrAppId, string keyStandard, string keyStr, BrandInfo brandInfo, int timeOut = Config.TIME_OUT)
- {
- return ApiHandlerWapper.TryCommonApi(accessToken =>
- {
- var urlFormat = string.Format(Config.ApiMpHost + "/scan/product/create?access_token={0}", accessToken.AsUrlData());
- var data = new
- {
- keystandard = keyStandard,
- keystr = keyStr,
- brand_info = brandInfo
- };
- return CommonJsonSend.Send<ProductCreateResultJson>(null, urlFormat, null, CommonJsonSendType.POST, timeOut: timeOut);
- }, accessTokenOrAppId);
- }
-
-
-
-
-
-
-
-
-
- [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "ScanApi.ModStatus", true)]
- public static WxJsonResult ModStatus(string accessTokenOrAppId, string keyStandard, string keyStr, string status, int timeOut = Config.TIME_OUT)
- {
- return ApiHandlerWapper.TryCommonApi(accessToken =>
- {
- var urlFormat = string.Format(Config.ApiMpHost + "/scan/product/modstatus?access_token={0}", accessToken.AsUrlData());
- var data = new
- {
- keystandard = keyStandard,
- keystr = keyStr,
- status = status
- };
- return CommonJsonSend.Send<WxJsonResult>(null, urlFormat, data, CommonJsonSendType.POST, timeOut: timeOut);
- }, accessTokenOrAppId);
- }
-
-
-
-
-
-
-
-
- [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "ScanApi.TestWhiteListSet", true)]
- public static WxJsonResult TestWhiteListSet(string accessTokenOrAppId, string openId, string userName, int timeOut = Config.TIME_OUT)
- {
- return ApiHandlerWapper.TryCommonApi(accessToken =>
- {
- var urlFormat = string.Format(Config.ApiMpHost + "/scan/testwhitelist/set?access_token={0}", accessToken.AsUrlData());
- var data = new
- {
- openid = openId,
- userName = userName
- };
- return CommonJsonSend.Send<WxJsonResult>(null, urlFormat, data, CommonJsonSendType.POST, timeOut: timeOut);
- }, accessTokenOrAppId);
- }
-
-
-
-
-
-
-
-
-
-
- [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "ScanApi.ProductGetList", true)]
- public static ProductGetListJsonResult ProductGetList(string accessTokenOrAppId, int offset, int limit, string status, int timeOut = Config.TIME_OUT)
- {
- return ApiHandlerWapper.TryCommonApi(accessToken =>
- {
- var urlFormat = string.Format(Config.ApiMpHost + "/scan/product/getlist?access_token={0}", accessToken.AsUrlData());
- var data = new
- {
- offset = offset,
- limit = limit,
- status = status
- };
- return CommonJsonSend.Send<ProductGetListJsonResult>(null, urlFormat, data, CommonJsonSendType.POST, timeOut: timeOut);
- }, accessTokenOrAppId);
- }
-
-
-
-
-
-
-
-
- [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "ScanApi.ProductClear", true)]
- public static WxJsonResult ProductClear(string accessTokenOrAppId, int keyStandard, string keyStr, int timeOut = Config.TIME_OUT)
- {
- return ApiHandlerWapper.TryCommonApi(accessToken =>
- {
- var urlFormat = string.Format(Config.ApiMpHost + "/scan/product/clear?access_token={0}", accessToken.AsUrlData());
- var data = new
- {
- keystandard = keyStandard,
- keystr = keyStr
- };
- return CommonJsonSend.Send<WxJsonResult>(null, urlFormat, data, CommonJsonSendType.POST, timeOut: timeOut);
- }, accessTokenOrAppId);
- }
-
-
-
-
-
-
-
- [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "ScanApi.ScanTicketCheck", true)]
- public static ScanTicketCheckJsonResult ScanTicketCheck(string accessTokenOrAppId, string ticket, int timeOut = Config.TIME_OUT)
- {
- return ApiHandlerWapper.TryCommonApi(accessToken =>
- {
- var urlFormat = string.Format(Config.ApiMpHost + "/scan/scanticket/check?access_token={0}", accessToken.AsUrlData());
- var data = new
- {
- ticket = ticket
- };
- return CommonJsonSend.Send<ScanTicketCheckJsonResult>(null, urlFormat, data, CommonJsonSendType.POST, timeOut: timeOut);
- }, accessTokenOrAppId);
- }
-
-
-
-
-
-
-
-
-
-
-
- [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "ScanApi.GetQrCode", true)]
- public static ProductGetQrCodeJsonResult GetQrCode(string accessTokenOrAppId, string keystr, string extinfo = null, string keystandard = "ean13", int qrcode_size = 100, int timeOut = Config.TIME_OUT)
- {
- return ApiHandlerWapper.TryCommonApi(accessToken =>
- {
- var urlFormat = string.Format(Config.ApiMpHost + "/scan/product/getqrcode?access_token={0}", accessToken.AsUrlData());
- var data = new
- {
- keystandard,
- keystr,
- extinfo,
- qrcode_size
- };
- return CommonJsonSend.Send<ProductGetQrCodeJsonResult>(null, urlFormat, data, CommonJsonSendType.POST, timeOut: timeOut);
- }, accessTokenOrAppId);
- }
-
-
-
-
-
-
-
- [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "ScanApi.UpdateBrand", true)]
- public static UpdateBrandResultJson UpdateBrand(string accessTokenOrAppId, UpdateBrandData data, int timeOut = Config.TIME_OUT)
- {
- return ApiHandlerWapper.TryCommonApi(accessToken =>
- {
- var urlFormat = string.Format(Config.ApiMpHost + "/scan/product/update?access_token={0}", accessToken.AsUrlData());
- return CommonJsonSend.Send<UpdateBrandResultJson>(null, urlFormat, data, CommonJsonSendType.POST, timeOut: timeOut);
- }, accessTokenOrAppId);
- }
- #endregion
- #if !NET35 && !NET40
- #region 异步方法
-
-
-
-
-
-
- [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "ScanApi.MerchantInfoGetAsync", true)]
- public static async Task<MerchantInfoGetResultJson> MerchantInfoGetAsync(string accessTokenOrAppId, int timeOut = Config.TIME_OUT)
- {
- return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
- {
- var urlFormat = string.Format(Config.ApiMpHost + "/scan/merchantinfo/get?access_token={0}", accessToken.AsUrlData());
- return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync<MerchantInfoGetResultJson>(null, urlFormat, null, CommonJsonSendType.GET, timeOut: timeOut);
- }, accessTokenOrAppId);
- }
-
-
-
-
-
-
-
-
-
- [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "ScanApi.ProductCreateAsync", true)]
- public static async Task<ProductCreateResultJson> ProductCreateAsync(string accessTokenOrAppId, string keyStandard, string keyStr, BrandInfo brandInfo, int timeOut = Config.TIME_OUT)
- {
- return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
- {
- var urlFormat = string.Format(Config.ApiMpHost + "/scan/product/create?access_token={0}", accessToken.AsUrlData());
- var data = new
- {
- keystandard = keyStandard,
- keystr = keyStr,
- brand_info = brandInfo
- };
- return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync<ProductCreateResultJson>(null, urlFormat, null, CommonJsonSendType.POST, timeOut: timeOut);
- }, accessTokenOrAppId);
- }
-
-
-
-
-
-
-
-
-
- [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "ScanApi.ModStatusAsync", true)]
- public static async Task<WxJsonResult> ModStatusAsync(string accessTokenOrAppId, string keyStandard, string keyStr, string status, int timeOut = Config.TIME_OUT)
- {
- return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
- {
- var urlFormat = string.Format(Config.ApiMpHost + "/scan/product/modstatus?access_token={0}", accessToken.AsUrlData());
- var data = new
- {
- keystandard = keyStandard,
- keystr = keyStr,
- status = status
- };
- return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync<WxJsonResult>(null, urlFormat, data, CommonJsonSendType.POST, timeOut: timeOut);
- }, accessTokenOrAppId);
- }
-
-
-
-
-
-
-
-
- [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "ScanApi.TestWhiteListSetAsync", true)]
- public static async Task<WxJsonResult> TestWhiteListSetAsync(string accessTokenOrAppId, string openId, string userName, int timeOut = Config.TIME_OUT)
- {
- return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
- {
- var urlFormat = string.Format(Config.ApiMpHost + "/scan/testwhitelist/set?access_token={0}", accessToken.AsUrlData());
- var data = new
- {
- openid = openId,
- userName = userName
- };
- return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync<WxJsonResult>(null, urlFormat, data, CommonJsonSendType.POST, timeOut: timeOut);
- }, accessTokenOrAppId);
- }
-
-
-
-
-
-
-
-
-
-
- [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "ScanApi.ProductGetListAsync", true)]
- public static async Task<ProductGetListJsonResult> ProductGetListAsync(string accessTokenOrAppId, int offset, int limit, string status, int timeOut = Config.TIME_OUT)
- {
- return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
- {
- var urlFormat = string.Format(Config.ApiMpHost + "/scan/product/getlist?access_token={0}", accessToken.AsUrlData());
- var data = new
- {
- offset = offset,
- limit = limit,
- status = status
- };
- return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync<ProductGetListJsonResult>(null, urlFormat, data, CommonJsonSendType.POST, timeOut: timeOut);
- }, accessTokenOrAppId);
- }
-
-
-
-
-
-
-
-
- [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "ScanApi.ProductClearAsync", true)]
- public static async Task<WxJsonResult> ProductClearAsync(string accessTokenOrAppId, int keyStandard, string keyStr, int timeOut = Config.TIME_OUT)
- {
- return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
- {
- var urlFormat = string.Format(Config.ApiMpHost + "/scan/product/clear?access_token={0}", accessToken.AsUrlData());
- var data = new
- {
- keystandard = keyStandard,
- keystr = keyStr
- };
- return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync<WxJsonResult>(null, urlFormat, data, CommonJsonSendType.POST, timeOut: timeOut);
- }, accessTokenOrAppId);
- }
-
-
-
-
-
-
-
- [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "ScanApi.ScanTicketCheckAsync", true)]
- public static async Task<ScanTicketCheckJsonResult> ScanTicketCheckAsync(string accessTokenOrAppId, string ticket, int timeOut = Config.TIME_OUT)
- {
- return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
- {
- var urlFormat = string.Format(Config.ApiMpHost + "/scan/scanticket/check?access_token={0}", accessToken.AsUrlData());
- var data = new
- {
- ticket = ticket
- };
- return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync<ScanTicketCheckJsonResult>(null, urlFormat, data, CommonJsonSendType.POST, timeOut: timeOut);
- }, accessTokenOrAppId);
- }
-
-
-
-
-
-
-
-
-
-
-
- [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "ScanApi.GetQrCodeAsync", true)]
- public static async Task<ProductGetQrCodeJsonResult> GetQrCodeAsync(string accessTokenOrAppId, string keystr, string extinfo = null, string keystandard = "ean13", int qrcode_size = 100, int timeOut = Config.TIME_OUT)
- {
- return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
- {
- var urlFormat = string.Format(Config.ApiMpHost + "/scan/product/getqrcode?access_token={0}", accessToken.AsUrlData());
- var data = new
- {
- keystandard,
- keystr,
- extinfo,
- qrcode_size
- };
- return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync<ProductGetQrCodeJsonResult>(null, urlFormat, data, CommonJsonSendType.POST, timeOut: timeOut);
- }, accessTokenOrAppId);
- }
-
-
-
-
-
-
-
- [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "ScanApi.UpdateBrandAsync", true)]
- public static async Task<UpdateBrandResultJson> UpdateBrandAsync(string accessTokenOrAppId, UpdateBrandData data, int timeOut = Config.TIME_OUT)
- {
- return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
- {
- var urlFormat = string.Format(Config.ApiMpHost + "/scan/product/update?access_token={0}", accessToken.AsUrlData());
- return await Weixin.CommonAPIs.CommonJsonSend.SendAsync<UpdateBrandResultJson>(null, urlFormat, data, CommonJsonSendType.POST, timeOut: timeOut);
- }, accessTokenOrAppId);
- }
- #endregion
- #endif
- }
- }
|