Beispiel #1
0
        protected async Task <T> GetDataFromApiOutAsyn <T, TParam>(
            string resources,
            Method methodApi             = Method.POST,
            List <string[]> headers      = null,
            List <string[]> queryStrings = null,
            params TParam[] arrParam) where T : new()
        {
            RestApi api = new RestApi(BaseURL);

            api.Method = methodApi;

            if (headers == null)
            {
                headers = new List <string[]>();
            }

            headers.Add(new[] { "UserName", ConfigurationManager.AppSettings["UserNameWebAPI"] });
            headers.Add(new[] { "Password", ConfigurationManager.AppSettings["PasswordWebAPI"] });

            List <Parameter> parameters = null;

            if (arrParam != null && arrParam.Length > 0)
            {
                // add list param to rest api
                foreach (TParam param in arrParam)
                {
                    api.AddParameter <TParam>(param, ref parameters);
                }
            }

            var response = await api.ExecuteResponseAsyn <T>(resources, headers, queryStrings, null, (parameters != null ? parameters.ToArray() : null));

            return(response);
        }
Beispiel #2
0
        protected T GetDataFromApiOut <T>(
            string resources,
            Method methodApi             = Method.POST,
            List <string[]> headers      = null,
            List <string[]> queryStrings = null) where T : new()
        {
            RestApi api = new RestApi(BaseURL);

            api.Method = methodApi;

            if (headers == null)
            {
                headers = new List <string[]>();
            }

            headers.Add(new[] { "UserName", ConfigurationManager.AppSettings["UserNameWebAPI"] });
            headers.Add(new[] { "Password", ConfigurationManager.AppSettings["PasswordWebAPI"] });

            return(api.ExecuteResponse <T>(resources, headers, queryStrings, null, null));
        }
        protected async Task <T> GetDataFromApiOutAsyn <T>(
            string resources,
            Method methodApi             = Method.POST,
            List <string[]> headers      = null,
            List <string[]> queryStrings = null) where T : new()
        {
            RestApi api = new RestApi(BaseURL);

            api.Method = methodApi;

            if (headers == null)
            {
                headers = new List <string[]>();
            }

            headers.Add(new[] { "UserName", ConfigurationManager.AppSettings["UserNameEVoucherAPI"] });
            headers.Add(new[] { "Password", ConfigurationManager.AppSettings["PasswordEVoucherAPI"] });

            var response = await api.ExecuteResponseAsyn <T>(resources, headers, queryStrings, null, null);

            return(response);
        }