예제 #1
0
        /// <summary>
        /// Makes a call to the specified endpoint of Accounts API, using the specified Invocation (Get, Put or Post).
        /// This call only supports requests that can be fully encoded in the URL.
        /// </summary>
        /// <param name="invocation">A delegate that will pass the </param>
        /// <param name="requestUrn">The URN to be appended to the Accounts API URL in order to
        /// obtain the full request URL.</param>
        /// <returns>An object representing the response by the Accounts API.</returns>
        /// <example>
        /// var response = await InvokeApiAsync(Put, "accounts/credit/1234?sum=100");
        ///
        /// Where "1234" is an account number and "100" is the sum to be credited to that account.
        /// </example>
        private async Task <HttpResponseMessage> InvokeApiAsync(HttpClientHelpers.EndPointInvocation invocation, string requestUrn)
        {
            HttpResponseMessage response;

            var accessToken = TokenManager.GetAccessTokens().AccessToken;

            using (var apiClient = new AccountsApiClient(_accountsApiUrl, accessToken))
            {
                response = await apiClient.Invoke(invocation, requestUrn);
            }

            return(response);
        }