Пример #1
0
        private T GetResponse <T>(IAPI api, IAuth auth, IDictionary <string, string> headers, List <KeyValuePair <string, string> > files)
            where T : YouZanResponse
        {
            var result = _YouZanClient.Invoke(api, auth, headers, files);

            return(JsonConvert.DeserializeObject <T>(result));
        }
Пример #2
0
        /// <summary>
        /// 执行API请求
        /// </summary>
        /// <typeparam name="TIn">请求参数</typeparam>
        /// <typeparam name="T">响应参数</typeparam>
        /// <param name="request">请求参数值</param>
        /// <param name="apiName">api名称</param>
        /// <param name="apiVersion">api版本</param>
        /// <param name="method">api版本</param>
        /// <param name="headers">http请求头信息</param>
        /// <param name="files">文件列表(暂不支持)</param>
        /// <returns></returns>
        protected YouZanResponse <T> ApiInvoke <T>(YouZanRequest request,
                                                   string apiName,
                                                   string apiVersion,
                                                   string method = API.METHOD_POST,
                                                   IDictionary <string, string> headers        = null,
                                                   List <KeyValuePair <string, string> > files = null)
        {
            GeneralApi generalApi = new GeneralApi();

            generalApi.SetName(apiName);
            generalApi.SetVersion(apiVersion);
            generalApi.SetHttpMethod(method);
            generalApi.SetOAuthType(OAuthEnum.TOKEN);

            GeneralApiParams apiParams = new GeneralApiParams();

            apiParams.AddParam(this.GenericParameter(request));

            generalApi.SetAPIParams(apiParams);

            string result = _YouZanClient.Invoke(generalApi, new Token(oAuthToken.Token), headers, files);

            return(JsonConvert.DeserializeObject <YouZanResponse <T> >(result));
        }