Beispiel #1
0
        public async Task <TResult> SendRequest <TResult>(ResourceBase resource)
            where TResult : class
        {
            var response = await m_request.Create(resource);

            return(await m_response.GetResponse <TResult>(response));
        }
Beispiel #2
0
        public async Task <HttpRequestMessage> Create(ResourceBase value)
        {
            var request = new HttpRequestMessage(value.Method, await RequestUri(value));

            request.Content = value.Content;
            request.Headers.Add("Authorization", (await m_partnerAccessToken.Get()).PartnerToken());

            return(request);
        }
        private async Task <HttpRequestMessage> CreateRequest(ResourceBase value)
        {
            var request = new HttpRequestMessage(value.Method, m_endpoint.Uri() + value.ResourceUri);

            if (value.Content != null)
            {
                request.Content = value.Content;
                request.Content.Headers.ContentMD5 = m_contentHash.ComputeHash(await value.Content.ReadAsByteArrayAsync());
            }

            request.Headers.Date          = m_time.UtcNow();
            request.Headers.Authorization = CreateAuthorization(value, request);

            return(request);
        }
 private AuthenticationHeaderValue CreateAuthorization(ResourceBase value, HttpRequestMessage request)
 => new AuthenticationHeaderValue(
     "Onnistuu",
     m_credentials.Identifier() + ":" +
     Convert.ToBase64String(
         m_macHash.ComputeHash(
             Encoding.UTF8.GetBytes(
                 string.Join(
                     "\n",
                     request.Method.ToString(),
                     Base64Content(request.Content),
                     ContentType(request.Content),
                     GetRequestTime(request),
                     "/" + value.ResourceUri)
                 )
             )
         )
     );
 public Task <HttpRequestMessage> Create(ResourceBase value)
 => CreateRequest(value);