public async Task <string> DeleteAsync(string endpoint, string fields, Action <HttpRequestMessage> AuthenticateRequest = null)
        {
            HttpResponseMessage response = await _client.DeleteAsync($"{endpoint}{fields}");

            var responseString = await response.Content.ReadAsStringAsync();

            if (!response.IsSuccessStatusCode)
            {
                throw SocialMediaApiExceptionFactory.CreateSocialMediaApiException(responseString);
            }

            return(responseString);
        }
        public async Task <string> PostFileAsync(string endpoint, MultipartFormDataContent content, Action <HttpRequestMessage> AuthenticateRequest = null)
        {
            HttpResponseMessage response = await _client.PostAsync(endpoint, content);

            var responseString = await response.Content.ReadAsStringAsync();

            if (!response.IsSuccessStatusCode)
            {
                throw SocialMediaApiExceptionFactory.CreateSocialMediaApiException(responseString);
            }

            return(responseString);
        }
        public async Task <string> PostAsync(string endpoint, Dictionary <string, string> payload, Action <HttpRequestMessage> AuthenticateRequest = null)
        {
            var content = new FormUrlEncodedContent(payload);
            HttpResponseMessage response = await _client.PostAsync(endpoint, content);

            var responseString = await response.Content.ReadAsStringAsync();

            if (!response.IsSuccessStatusCode)
            {
                throw SocialMediaApiExceptionFactory.CreateSocialMediaApiException(responseString);
            }

            return(responseString);
        }
Esempio n. 4
0
        public async Task <string> DeleteAsync(string endpoint, string fields, Action <HttpRequestMessage> AuthenticateRequest)
        {
            HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Delete, GetApiUrl(endpoint));

            AuthenticateRequest(request);

            HttpResponseMessage response = await _client.SendAsync(request);

            string responseString = await response.Content.ReadAsStringAsync();

            if (!response.IsSuccessStatusCode)
            {
                throw SocialMediaApiExceptionFactory.CreateSocialMediaApiException(responseString);
            }

            return(responseString);
        }
Esempio n. 5
0
        public async Task <string> PostAsync(string endpoint, Dictionary <string, string> payload, Action <HttpRequestMessage> AuthenticateRequest)
        {
            HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, GetApiUrl(endpoint));

            request.Content = new FormUrlEncodedContent(payload);
            AuthenticateRequest(request);

            HttpResponseMessage response = await _client.SendAsync(request);

            string responseString = await response.Content.ReadAsStringAsync();

            if (!response.IsSuccessStatusCode)
            {
                throw SocialMediaApiExceptionFactory.CreateSocialMediaApiException(responseString);
            }

            return(responseString);
        }