/// <summary> /// Delete 请求 /// </summary> /// <typeparam name="TParameter"></typeparam> /// <typeparam name="TResult"></typeparam> /// <param name="apiUrl"></param> /// <param name="parameter"></param> /// <param name="uriParameters"></param> /// <returns></returns> public static OperateResult <TResult> Delete <TParameter, TResult>(string apiUrl, TParameter parameter, Dictionary <string, string> uriParameters = null) { try { RequestSetting setting = LoadDefaultSetting( new RequestSettingWithJsonContent <TParameter>(parameter) { Method = "DELETE" }, apiUrl); if (uriParameters == null) { uriParameters = new Dictionary <string, string>(); } if (!string.IsNullOrWhiteSpace(Token)) { setting.Headers.Add(HttpRequestHeader.Authorization, string.Format("Basic {0}", Token)); } setting = setting.SetUriParameters(uriParameters); return(GetResult <OperateResult <TResult> >(setting)); } catch (Exception ex) { // LoggerFactory.Create(ERPModule.POSClient.GetModuleName(), ).Warn("网络请求发生错误!", ex); return(new OperateResult <TResult>() { Code = "500", Message = "网络请求发生错误,请检查网络是否正常!" + ex.Message }); } }
public static TResult Post <TParameter, TResult>(TParameter parameter, Dictionary <string, string> uriParameters = null, string apiUrl = SubmitUrl) where TResult : class { RequestSetting setting = LoadDefaultSetting( new RequestSettingWithJsonContent <TParameter>(parameter) { Method = "POST" }, apiUrl, AppKey, MasterSecret); if (uriParameters == null) { uriParameters = new Dictionary <string, string>(); } setting = setting.SetUriParameters(uriParameters); return(GetResult <TResult>(setting)); }
public static ApiRetrunResult <TResult> Post <TParameter, TResult>(string apiUrl, TParameter parameter, Dictionary <string, string> uriParameters = null) where TResult : class { RequestSetting setting = LoadDefaultSetting( new RequestSettingWithJsonContent <TParameter>(parameter) { Method = "POST" }, apiUrl); if (uriParameters == null) { uriParameters = new Dictionary <string, string>(); } if (!string.IsNullOrWhiteSpace(Token)) { uriParameters.Add("token", Token); } setting = setting.SetUriParameters(uriParameters); return(GetResult <ApiRetrunResult <TResult> >(setting)); }