Example #1
0
        public new static async Task <ApiFile> FromMessage(HttpResponseMessage message)
        {
            var response = new ApiFile
            {
                Message = message,
            };

            if (message.IsSuccessStatusCode)
            {
                response.Data = await message.Content.ReadAsStreamAsync();
            }
            else
            {
                response.HandleFailedCall();
            }

            return(response);
        }
Example #2
0
        private async Task <ApiFile> SendHttpFile(Func <HttpRequestMessage> requestFunc)
        {
            try
            {
                var request = requestFunc();
                await SetAuthHeader(request, false);

                var response = await httpClient.SendAsync(request);

                return(await ApiFile.FromMessage(response));
            }
            catch (Exception ex)
            {
                return(new ApiFile()
                {
                    Error = new ApiError {
                        Message = GetRecursiveErrorMessage(ex)
                    }
                });
            }
        }