Exemple #1
0
        public static async Task <WiFiRegisterJsonResult> WifeRegisterAsync(string accessTokenOrAppId, long shopId, string ssid, string reset,
                                                                            int timeOut = WxConfig.TIME_OUT)
        {
            return(await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
            {
                string urlFormat = WxConfig.ApiMpHost + "/bizwifi/apportal/register?access_token={0}";

                var data = new
                {
                    shop_id = shopId,
                    ssid = ssid,
                    reset = reset,
                };
                return await CommonJsonSend.SendAsync <WiFiRegisterJsonResult>(accessToken, urlFormat, data, timeOut: timeOut);
            }, accessTokenOrAppId));
        }
        public static async Task <GetAuditResultJson> SubmitAuditAsync(string accessToken, List <SubmitAuditPageInfo> item_list, SubmitAuditPreviewInfo preview_info, string version_desc = "", string feedback_info = "", string feedback_stuff = "", int timeOut = Config.TIME_OUT)
        {
            var url = string.Format(Config.ApiMpHost + "/wxa/submit_audit?access_token={0}", accessToken.AsUrlData());

            object data;

            data = new
            {
                item_list      = item_list,
                feedback_info  = feedback_info,
                feedback_stuff = feedback_stuff,
                preview_info   = preview_info
            };

            return(await CommonJsonSend.SendAsync <GetAuditResultJson>(null, url, data, CommonJsonSendType.POST, timeOut).ConfigureAwait(false));
        }
Exemple #3
0
        /// <summary>
        /// Obtaining New Access Tokens (异步)
        ///
        /// 范例
        /// https://www.merchant.wish.com/documentation/oauth
        ///
        /// </summary>
        /// <param name="clientId"></param>
        /// <param name="clientSecret"></param>
        /// <param name="refreshToken"></param>
        /// <param name="redirectUrl"></param>
        /// <param name="sessionType"></param>
        /// <returns></returns>
        public static async Task <OAuthAccessTokenResult> RefreshAccessTokenAsync(string clientId, string clientSecret, string refreshToken, SessionType sessionType = SessionType.Prod)
        {
            var url =
                string.Format("{0}/api/v2/oauth/refresh_token",
                              sessionType == SessionType.Sandbox ? Wl.Wish.Config.RequestUriRootSandbox : Wl.Wish.Config.RequestUriRoot);

            var data = new
            {
                client_id     = clientId,     //   Your app's client ID
                client_secret = clientSecret, //   Your app's client secret
                refresh_token = refreshToken, //    The authorization code you received
                grant_type    = "refresh_token"
            };

            return(await CommonJsonSend.SendAsync <OAuthAccessTokenResult>(null, url, data, CommonJsonSendType.POST));
        }
        /// <summary>
        /// 修改头像
        /// </summary>
        /// <para>图片格式只支持:BMP、JPEG、JPG、GIF、PNG,大小不超过2M
        /// 注:实际头像始终为正方形</para>
        /// <param name="accessToken">小程序的access_token</param>
        /// <param name="head_img_media_id">头像素材media_id</param>
        /// <param name="x1">裁剪框左上角x坐标(取值范围:[0, 1])</param>
        /// <param name="y1">裁剪框左上角y坐标(取值范围:[0, 1])</param>
        /// <param name="x2">裁剪框右下角x坐标(取值范围:[0, 1])</param>
        /// <param name="y2">裁剪框右下角y坐标(取值范围:[0, 1])</param>
        /// <returns></returns>
        public static async Task <WxJsonResult> ModifyHeadImageAsync(string accessToken, string head_img_media_id, float x1, float y1,
                                                                     float x2, float y2)
        {
            //https://api.weixin.qq.com/cgi-bin/account/modifyheadimage?access_token=TOKEN
            var url  = $"{Config.ApiMpHost}/cgi-bin/account/modifyheadimage?access_token={accessToken.AsUrlData()}";
            var data = new
            {
                head_img_media_id = head_img_media_id,
                x1 = x1,
                y1 = y1,
                x2 = x2,
                y2 = y2
            };

            return(await CommonJsonSend.SendAsync <WxJsonResult>(accessToken, url, null, CommonJsonSendType.GET));
        }
Exemple #5
0
        public static async Task <GetQrcodeResult> GetQrcodeAsync(string accessTokenOrAppId, long shopId, int imgId,
                                                                  int timeOut = WxConfig.TIME_OUT)
        {
            return(await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
            {
                string urlFormat = WxConfig.ApiMpHost + "/bizwifi/qrcode/get?access_token={0}";

                var data = new
                {
                    shop_id = shopId,
                    img_id = imgId
                };

                return await CommonJsonSend.SendAsync <GetQrcodeResult>(accessToken, urlFormat, data, timeOut: timeOut);
            }, accessTokenOrAppId));
        }
Exemple #6
0
        public static async Task <GetApprovalDataJsonResult> GetApprovalDataAsync(string accessTokenOrAppKey, DateTime startTime, DateTime endTime, long next_spnum, int timeOut = WxConfig.TIME_OUT)
        {
            return(await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
            {
                var url = WxConfig.ApiMpHost + "/cgi-bin/corp/getapprovaldata?access_token={0}";

                var data = new
                {
                    starttime = DateTimeHelper.GetUnixDateTime(startTime),
                    endtime = DateTimeHelper.GetUnixDateTime(endTime),
                    next_spnum = next_spnum
                };

                return await CommonJsonSend.SendAsync <GetApprovalDataJsonResult>(accessToken, url, data, CommonJsonSendType.POST, timeOut);
            }, accessTokenOrAppKey));
        }
Exemple #7
0
        public static async Task <GetExternalContactInfoBatchResult> GetExternalContactInfoBatchAsync(string accessTokenOrAppKey, string userid, string cursor = "", int limit = 50, int timeOut = Config.TIME_OUT)
        {
            return(await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
            {
                var url = $"{Config.ApiWorkHost}/cgi-bin/externalcontact/batch/get_by_user?access_token={accessToken}";

                var data = new
                {
                    userid,
                    cursor,
                    limit
                };

                return await CommonJsonSend.SendAsync <GetExternalContactInfoBatchResult>(null, url, data, CommonJsonSendType.POST, timeOut).ConfigureAwait(false);
            }, accessTokenOrAppKey).ConfigureAwait(false));
        }
Exemple #8
0
        /// <summary>
        /// 【异步方法】获取草稿列表
        /// </summary>
        /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
        /// <param name="offset">从全部素材的该偏移位置开始返回,0表示从第一个素材 返回</param>
        /// <param name="count">返回素材的数量,取值在1到20之间</param>
        /// <param name="no_content">1 表示不返回 content 字段,0 表示正常返回,默认为 0</param>
        /// <param name="timeOut">代理请求超时时间(毫秒)</param>
        /// <returns></returns>
        public static async Task <DraftListResultJson> GetDraftListAsync(string accessTokenOrAppId, int offset, int count, int no_content = 0, int timeOut = Config.TIME_OUT)
        {
            return(await ApiHandlerWapper.TryCommonApiAsync(accessToken =>
            {
                string url = Config.ApiMpHost + "/cgi-bin/draft/batchget?access_token={0}";

                var date = new
                {
                    offset = offset,
                    count = count,
                    no_content = no_content
                };

                return CommonJsonSend.SendAsync <DraftListResultJson>(accessToken, url, date, CommonJsonSendType.POST, timeOut);
            }, accessTokenOrAppId).ConfigureAwait(false));
        }
Exemple #9
0
        public static async Task <GetSuiteTokenResult> GetSuiteTokenAsync(string suiteId, string suiteSecret, string suiteTicket, int timeOut = WxConfig.TIME_OUT)
        {
            return(await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
            {
                var url = WxConfig.ApiWorkHost + "/cgi-bin/service/get_suite_token";

                var data = new
                {
                    suite_id = suiteId,
                    suite_secret = suiteSecret,
                    suite_ticket = suiteTicket
                };

                return await CommonJsonSend.SendAsync <GetSuiteTokenResult>(null, url, data, CommonJsonSendType.POST, timeOut);
            }, suiteId));
        }
Exemple #10
0
 public static async Task <WxJsonResult> SetContactAsync(string accessTokenOrAppId, string phone, int timeOut = Config.TIME_OUT)
 {
     return(await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
     {
         var urlFormat = string.Format(Config.ApiMpHost + "/card/invoice/setbizattr?action=set_contact&access_token={0}", accessToken.AsUrlData());
         var data = new
         {
             contact = new
             {
                 phone = phone,
                 time_out = timeOut
             }
         };
         return await CommonJsonSend.SendAsync <WxJsonResult>(null, urlFormat, data, timeOut: timeOut);
     }, accessTokenOrAppId));
 }
Exemple #11
0
        public static async Task <WxJsonResult> CloseSessionAsync(string accessTokenOrAppId, string openId, string kfAccount, string text = null, int timeOut = WxConfig.TIME_OUT)
        {
            return(await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
            {
                var urlFormat = string.Format(WxConfig.ApiMpHost + "/customservice/kfsession/close?access_token={0}", accessToken.AsUrlData());

                var data = new
                {
                    openid = openId,
                    kf_account = kfAccount,
                    text = text
                };

                return await CommonJsonSend.SendAsync <WxJsonResult>(null, urlFormat, data, CommonJsonSendType.POST, timeOut: timeOut);
            }, accessTokenOrAppId));
        }
Exemple #12
0
        public static async Task <WxJsonResult> ApiConfirmAuthAsync(string componentAccessToken, string componentAppId, string authorizerAppid, int funscopeCategoryId, int confirmValue, int timeOut = Config.TIME_OUT)
        {
            var url =
                string.Format(
                    Config.ApiMpHost + "/ cgi-bin/component/api_confirm_authorization?component_access_token={0}", componentAccessToken.AsUrlData());

            var data = new
            {
                component_appid      = componentAppId,
                authorizer_appid     = authorizerAppid,
                funscope_category_id = funscopeCategoryId,
                confirm_value        = confirmValue
            };

            return(await CommonJsonSend.SendAsync <WxJsonResult>(null, url, data, CommonJsonSendType.POST, timeOut).ConfigureAwait(false));
        }
Exemple #13
0
        public static async Task <CodeResultJson> CommitAsync(string accessToken, int template_id, string ext_json, string user_version, string user_desc, int timeOut = Config.TIME_OUT)
        {
            var url = string.Format(Config.ApiMpHost + "/wxa/commit?access_token={0}", accessToken.AsUrlData());

            object data;

            data = new
            {
                template_id  = template_id,
                ext_json     = ext_json,
                user_version = user_version,
                user_desc    = user_desc
            };

            return(await CommonJsonSend.SendAsync <CodeResultJson>(null, url, data, CommonJsonSendType.POST, timeOut));
        }
Exemple #14
0
        public static async Task <WxJsonResult> UpdateCustomAsync(string accessTokenOrAppId, string kfAccount, string nickName, string passWord, int timeOut = WxConfig.TIME_OUT)
        {
            return(await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
            {
                var urlFormat = string.Format(WxConfig.ApiMpHost + "/customservice/kfaccount/update?access_token={0}", accessToken.AsUrlData());

                var data = new
                {
                    kf_account = kfAccount,
                    nickname = nickName,
                    password = passWord
                };

                return await CommonJsonSend.SendAsync <WxJsonResult>(null, urlFormat, data, CommonJsonSendType.POST, timeOut: timeOut);
            }, accessTokenOrAppId));
        }
Exemple #15
0
        public static async Task <WorkJsonResult> UpdateChatAsync(string accessTokenOrAppKey, string chatId, string name = null, string owner = null, string[] addUserList = null, string[] delUserList = null, int timeOut = Config.TIME_OUT)
        {
            return(await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
            {
                var data = new
                {
                    chatid = chatId,
                    name = name,
                    owner = owner,
                    add_user_list = addUserList,
                    del_user_list = delUserList
                };

                return await CommonJsonSend.SendAsync <WorkJsonResult>(accessToken, _urlFormatUpdate, data, CommonJsonSendType.POST, timeOut);
            }, accessTokenOrAppKey));
        }
Exemple #16
0
        public static Task <WxJsonResult> ReplyDeleteAsync(string accessTokenOrAppId, uint msg_data_id, uint?index, uint user_comment_id, string content, int timeOut = Config.TIME_OUT)
        {
            return(ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
            {
                var urlFormat = Config.ApiMpHost + "/cgi-bin/comment/reply/delete?access_token={0}";
                var data = new
                {
                    msg_data_id = msg_data_id,
                    index = index,
                    user_comment_id = user_comment_id,
                };

                JsonSetting jsonSetting = new JsonSetting(ignoreNulls: true);
                return await CommonJsonSend.SendAsync <WxJsonResult>(accessToken, urlFormat, data, timeOut: timeOut, jsonSetting: jsonSetting).ConfigureAwait(false);
            }, accessTokenOrAppId));
        }
Exemple #17
0
        public static async Task <RefreshAuthorizerTokenResult> ApiAuthorizerTokenAsync(string componentAccessToken, string componentAppId, string authorizerAppId, string authorizerRefreshToken = null, int timeOut = Config.TIME_OUT)
        {
            var url =
                string.Format(
                    Config.ApiMpHost + "/cgi-bin/component/api_authorizer_token?component_access_token={0}",
                    componentAccessToken.AsUrlData());

            var data = new
            {
                component_appid          = componentAppId,
                authorizer_appid         = authorizerAppId,
                authorizer_refresh_token = authorizerRefreshToken
            };

            return(await CommonJsonSend.SendAsync <RefreshAuthorizerTokenResult>(null, url, data, CommonJsonSendType.POST, timeOut).ConfigureAwait(false));
        }
Exemple #18
0
        public static async Task <AuthorizerOptionResult> GetAuthorizerOptionAsync(string componentAccessToken, string componentAppId, string authorizerAppId, OptionName optionName, int timeOut = Config.TIME_OUT)
        {
            var url =
                string.Format(
                    Config.ApiMpHost + "/cgi-bin/component/api_get_authorizer_option?component_access_token={0}",
                    componentAccessToken.AsUrlData());

            var data = new
            {
                component_appid  = componentAppId,
                authorizer_appid = authorizerAppId,
                option_name      = optionName
            };

            return(await CommonJsonSend.SendAsync <AuthorizerOptionResult>(null, url, data, CommonJsonSendType.POST, timeOut).ConfigureAwait(false));
        }
Exemple #19
0
        /// <summary>
        /// 【异步方法】获取图文素材列表
        /// </summary>
        /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
        /// <param name="offset">从全部素材的该偏移位置开始返回,0表示从第一个素材 返回</param>
        /// <param name="count">返回素材的数量,取值在1到20之间</param>
        /// <param name="timeOut">代理请求超时时间(毫秒)</param>
        /// <returns></returns>
        public static async Task <MediaList_NewsResult> GetNewsMediaListAsync(string accessTokenOrAppId, int offset, int count, int timeOut = Config.TIME_OUT)
        {
            return(await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
            {
                string url = string.Format(Config.ApiMpHost + "/cgi-bin/material/batchget_material?access_token={0}", accessToken.AsUrlData());

                var date = new
                {
                    type = "news",
                    offset = offset,
                    count = count
                };

                return await CommonJsonSend.SendAsync <MediaList_NewsResult>(null, url, date, CommonJsonSendType.POST, timeOut).ConfigureAwait(false);
            }, accessTokenOrAppId).ConfigureAwait(false));
        }
Exemple #20
0
        public static async Task <WxJsonResult> UpdateStatusAsync(string accessTokenOrAppId, string cardId, string code, string reimburseStatus, int timeOut = Config.TIME_OUT)
        {
            return(await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
            {
                var urlFormat = string.Format(Config.ApiMpHost + "/card/invoice/platform/updatestatus?access_token={0}", accessToken.AsUrlData());

                var data = new
                {
                    card_id = cardId,
                    code = code,
                    reimburse_status = reimburseStatus
                };

                return await CommonJsonSend.SendAsync <WxJsonResult>(null, urlFormat, data, timeOut: timeOut);
            }, accessTokenOrAppId));
        }
Exemple #21
0
        public static async Task <WxJsonResult> SendSubscribeAsync(string accessTokenOrAppId, string toUser, string templateId, TemplateMessageData data, string page = null, int timeOut = Config.TIME_OUT)
        {
            return(await WxOpenApiHandlerWapper.TryCommonApiAsync(async accessToken =>
            {
                string urlFormat = Config.ApiMpHost + "/cgi-bin/message/subscribe/send?access_token={0}";
                var submitData = new
                {
                    touser = toUser,
                    template_id = templateId,
                    page = page,
                    data = data
                };

                return await CommonJsonSend.SendAsync(accessToken, urlFormat, submitData, timeOut: timeOut);
            }, accessTokenOrAppId));
        }
Exemple #22
0
        public static async Task <GetCorpTokenResult> GetCorpTokenAsync(string suiteAccessToken, string suiteId, string authCorpId, string permanentCode, int timeOut = WxConfig.TIME_OUT)
        {
            return(await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
            {
                var url = string.Format(WxConfig.ApiWorkHost + "/cgi-bin/service/get_corp_token?suite_access_token={0}", suiteAccessToken.AsUrlData());

                var data = new
                {
                    suite_id = suiteId,
                    auth_corpid = authCorpId,
                    permanent_code = permanentCode,
                };

                return await CommonJsonSend.SendAsync <GetCorpTokenResult>(null, url, data, CommonJsonSendType.POST, timeOut);
            }, suiteAccessToken));
        }
Exemple #23
0
 public static async Task <WxJsonResult> UpdateAsync(string accessTokenOrAppId, int id, string name, int timeOut = Config.TIME_OUT)
 {
     return(await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
     {
         var urlFormat = Config.ApiMpHost + "/cgi-bin/groups/update?access_token={0}";
         var data = new
         {
             group = new
             {
                 id = id,
                 name = name
             }
         };
         return await CommonJsonSend.SendAsync(accessToken, urlFormat, data, timeOut: timeOut).ConfigureAwait(false);
     }, accessTokenOrAppId).ConfigureAwait(false));
 }
Exemple #24
0
        public static async Task <WxJsonResult> SetFinishpageAsync(string accessTokenOrAppId, long shopId, string finishPageUrl,
                                                                   int timeOut = WxConfig.TIME_OUT)
        {
            return(await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
            {
                string urlFormat = WxConfig.ApiMpHost + "/bizwifi/finishpage/set?access_token={0}";

                var data = new
                {
                    shop_id = shopId,
                    finishpage_url = finishPageUrl
                };


                return await CommonJsonSend.SendAsync <WxJsonResult>(accessToken, urlFormat, data, timeOut: timeOut);
            }, accessTokenOrAppId));
        }
Exemple #25
0
        public static async Task <GetCheckinDataJsonResult> GetCheckinDataAsync(string accessTokenOrAppKey, OpenCheckinDataType openCheckinDataType, DateTime startTime, DateTime endTime, string[] userIdList, int timeOut = WxConfig.TIME_OUT)
        {
            return(await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
            {
                var url = WxConfig.ApiMpHost + "/cgi-bin/checkin/getcheckindata?access_token={0}";

                var data = new
                {
                    opencheckindatatype = (int)openCheckinDataType,
                    starttime = DateTimeHelper.GetUnixDateTime(startTime),
                    endtime = DateTimeHelper.GetUnixDateTime(endTime),
                    useridlist = userIdList
                };

                return await CommonJsonSend.SendAsync <GetCheckinDataJsonResult>(accessToken, url, data, CommonJsonSendType.POST, timeOut);
            }, accessTokenOrAppKey));
        }
Exemple #26
0
        public static async Task <MediaList_OthersResult> GetOthersMediaListAsync(string accessTokenOrAppId, UploadMediaFileType type, int offset,
                                                                                  int count, int timeOut = WxConfig.TIME_OUT)
        {
            return(await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
            {
                string url = string.Format(WxConfig.ApiMpHost + "/cgi-bin/material/batchget_material?access_token={0}", accessToken.AsUrlData());

                var date = new
                {
                    type = type.ToString(),
                    offset = offset,
                    count = count
                };

                return await CommonJsonSend.SendAsync <MediaList_OthersResult>(null, url, date, CommonJsonSendType.POST, timeOut);
            }, accessTokenOrAppId));
        }
Exemple #27
0
        public static async Task <WxJsonResult> SetBarAsync(string accessTokenOrAppId, long shopId, int barType,
                                                            int timeOut = WxConfig.TIME_OUT)
        {
            return(await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
            {
                string urlFormat = WxConfig.ApiMpHost + "/bizwifi/bar/set?access_token={0}";

                var data = new
                {
                    shop_id = shopId,
                    bar_type = barType
                };


                return await CommonJsonSend.SendAsync <WxJsonResult>(accessToken, urlFormat, data, timeOut: timeOut);
            }, accessTokenOrAppId));
        }
Exemple #28
0
        public static async Task <ProductGetQrCodeJsonResult> GetQrCodeAsync(string accessTokenOrAppId, string keystr, string extinfo = null, string keystandard = "ean13", int qrcode_size = 100, int timeOut = WxConfig.TIME_OUT)
        {
            return(await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
            {
                var urlFormat = string.Format(WxConfig.ApiMpHost + "/scan/product/getqrcode?access_token={0}", accessToken.AsUrlData());

                var data = new
                {
                    keystandard,
                    keystr,
                    extinfo,
                    qrcode_size
                };

                return await CommonJsonSend.SendAsync <ProductGetQrCodeJsonResult>(null, urlFormat, data, CommonJsonSendType.POST, timeOut: timeOut);
            }, accessTokenOrAppId));
        }
Exemple #29
0
        public static async Task <WxJsonResult> DeleteAsync(string accessTokenOrAppId, int id, int timeOut = Config.TIME_OUT)
        {
            return(await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
            {
                var urlFormat = Config.ApiMpHost + "/cgi-bin/tags/delete?access_token={0}";

                var data = new
                {
                    tag = new
                    {
                        id = id
                    }
                };

                return await CommonJsonSend.SendAsync <WxJsonResult>(accessToken, urlFormat, data, CommonJsonSendType.POST, timeOut).ConfigureAwait(false);
            }, accessTokenOrAppId).ConfigureAwait(false));
        }
Exemple #30
0
        public static async Task <GetDialRecordJsonResult> GetDialRecordAsync(string accessTokenOrAppKey, DateTime startTime, DateTime endTime, int offset, int limit, int timeOut = WxConfig.TIME_OUT)
        {
            return(await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
            {
                var url = WxConfig.ApiMpHost + "/cgi-bin/dial/get_dial_record?access_token={0}";

                var data = new
                {
                    starttime = DateTimeHelper.GetUnixDateTime(startTime),
                    endtime = DateTimeHelper.GetUnixDateTime(endTime),
                    offset = offset,
                    limit = limit
                };

                return await CommonJsonSend.SendAsync <GetDialRecordJsonResult>(accessToken, url, data, CommonJsonSendType.POST, timeOut);
            }, accessTokenOrAppKey));
        }