/// <summary>
 /// Method to valid input data
 /// </summary>
 /// <param name="exchangeRateRequest"></param>
 /// <param name="exchangeRateResponse"></param>
 /// <returns></returns>
 private ExchangeRateResponse ValidateInput(ExchangeRateRequest exchangeRateRequest, ExchangeRateResponse exchangeRateResponse)
 {
     try
     {
         if (exchangeRateRequest == null)
         {
             exchangeRateResponse.Error = new ErrorResponse
             {
                 ErrorCode    = HttpStatusCode.NoContent,
                 ErrorMessage = ExchangeRateConstant.InvalidInut
             };
         }
         else if (exchangeRateRequest.BaseCurrency == null || string.IsNullOrEmpty(exchangeRateRequest.BaseCurrency.Trim()))
         {
             exchangeRateResponse.Error = new ErrorResponse
             {
                 ErrorCode    = HttpStatusCode.PartialContent,
                 ErrorMessage = ExchangeRateConstant.InvalidBaseCurency
             };
         }
         else if (exchangeRateRequest.TargetCurrency == null || string.IsNullOrEmpty(exchangeRateRequest.TargetCurrency.Trim()))
         {
             exchangeRateResponse.Error = new ErrorResponse
             {
                 ErrorCode    = HttpStatusCode.PartialContent,
                 ErrorMessage = ExchangeRateConstant.InvalidTargetCurrency
             };
         }
         else if (exchangeRateRequest.Dates == null || exchangeRateRequest.Dates.Length == 0)
         {
             exchangeRateResponse.Error = new ErrorResponse
             {
                 ErrorCode    = HttpStatusCode.PartialContent,
                 ErrorMessage = ExchangeRateConstant.InvalidDates
             };
         }
         return(exchangeRateResponse);
     }
     catch (Exception)
     {
         throw;
     }
 }
        public ExchangeRateResponse GetExchangeRateInformation(ExchangeRateRequest exchangeRateRequest)
        {
            var exchangeRateResponse = new ExchangeRateResponse();

            try
            {
                exchangeRateResponse = ValidateInput(exchangeRateRequest, exchangeRateResponse);
                if (exchangeRateResponse.Error == null)
                {
                    var exchangerateinput = new ExchangeRateInput
                    {
                        BaseCurrency   = exchangeRateRequest.BaseCurrency,
                        TargetCurrency = exchangeRateRequest.TargetCurrency,
                        Dates          = exchangeRateRequest.Dates
                    };
                    var result = _exchangeRateManager.GetExchangeRateInformation(exchangerateinput);
                    if (result.Error == null)
                    {
                        exchangeRateResponse.MinRate     = result.MinRate;
                        exchangeRateResponse.MaxRate     = result.MaxRate;
                        exchangeRateResponse.AverageRate = result.AverageRate;
                    }
                    else
                    {
                        exchangeRateResponse.Error = new ErrorResponse
                        {
                            ErrorCode    = result.Error.ErrorCode,
                            ErrorMessage = result.Error.ErrorMessage
                        };
                    }
                }
            }
            catch (Exception ex)
            {
                exchangeRateResponse.Error = new ErrorResponse
                {
                    ErrorCode    = HttpStatusCode.InternalServerError,
                    ErrorMessage = ex.Message
                };
            }
            return(exchangeRateResponse);
        }
Beispiel #3
0
        public ExchangeRateResponse ExchangeRate(ExchangeRateRequest request)
        {
            lock (lockTheEntireGraph)
            {
                var response = new ExchangeRateResponse();

                var spt = new BellmanFord <ExchangeCurrency>(graph, request.Source);
                if (spt.HasNegativeCycle())
                {
                    response.IsCycle = true;

                    var cycle = spt.NegativeCycle();
                    response.Cycle = EdgesToVertexes(cycle);
                    return(response); // TODO: cycle ==> arbitrage opportunity
                }
                if (spt.HasPathTo(request.Destination))
                {
                    response.IsHasPath = true;

                    var    path           = spt.PathTo(request.Destination);
                    var    vertexesOnPath = EdgesToVertexes(path);
                    double rate           = 1;
                    foreach (var edge in path)
                    {
                        rate *= Math.Exp(-edge.Weight);
                    }

                    response.Source      = request.Source;
                    response.Destination = request.Destination;
                    response.Rate        = rate;
                    response.Path        = vertexesOnPath;
                    return(response);
                }
                if (!spt.HasPathTo(request.Destination))
                {
                    response.IsHasPath = false;
                    return(response);
                }

                throw new NotImplementedException();
            }
        }
Beispiel #4
0
 public ExchangeRateSDK(ExchangeRateRequest exchangeRateRequest, OpenExchangeRateConfig config)
 {
     _Exr           = exchangeRateRequest;
     _configuration = config;
 }
Beispiel #5
0
        /// <summary>
        /// Generate dynamic currency conversion transactions. Sale, return and lookup exchange rate with dynamic currency conversion option.
        /// </summary>
        /// <exception cref="Org.OpenAPITools.Client.ApiException">Thrown when fails to make API call</exception>
        /// <param name="contentType">Content type.</param>
        /// <param name="clientRequestId">A client-generated ID for request tracking and signature creation, unique per request.  This is also used for idempotency control. We recommend 128-bit UUID format.</param>
        /// <param name="apiKey">Key given to merchant after boarding associating their requests with the appropriate app in Apigee.</param>
        /// <param name="timestamp">Epoch timestamp in milliseconds in the request from a client system. Used for Message Signature generation and time limit (5 mins).</param>
        /// <param name="exchangeRateRequest">Accepted request types: DCCExchangeRateRequest and DynamicPricingExchangeRateRequest.</param>
        /// <param name="messageSignature">Used to ensure the request has not been tampered with during transmission. The Message-Signature is the Base64 encoded HMAC hash (SHA256 algorithm with the API Secret as the key.) For more information, refer to the supporting documentation on the Developer Portal. (optional)</param>
        /// <param name="region">Indicates the region where the client wants the transaction to be processed. This will override the default processing region identified for the client. Available options are argentina, brazil, germany, india and northamerica. Region specific store setup and APIGEE boarding is required in order to use an alternate region for processing. (optional)</param>
        /// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
        /// <returns>Task of ApiResponse (ExchangeRateResponse)</returns>
        public async System.Threading.Tasks.Task <Org.OpenAPITools.Client.ApiResponse <ExchangeRateResponse> > GetExchangeRateWithHttpInfoAsync(string contentType, string clientRequestId, string apiKey, long timestamp, ExchangeRateRequest exchangeRateRequest, string messageSignature = default(string), string region = default(string), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken))
        {
            // verify the required parameter 'contentType' is set
            if (contentType == null)
            {
                throw new Org.OpenAPITools.Client.ApiException(400, "Missing required parameter 'contentType' when calling CurrencyConversionApi->GetExchangeRate");
            }

            // verify the required parameter 'clientRequestId' is set
            if (clientRequestId == null)
            {
                throw new Org.OpenAPITools.Client.ApiException(400, "Missing required parameter 'clientRequestId' when calling CurrencyConversionApi->GetExchangeRate");
            }

            // verify the required parameter 'apiKey' is set
            if (apiKey == null)
            {
                throw new Org.OpenAPITools.Client.ApiException(400, "Missing required parameter 'apiKey' when calling CurrencyConversionApi->GetExchangeRate");
            }

            // verify the required parameter 'exchangeRateRequest' is set
            if (exchangeRateRequest == null)
            {
                throw new Org.OpenAPITools.Client.ApiException(400, "Missing required parameter 'exchangeRateRequest' when calling CurrencyConversionApi->GetExchangeRate");
            }


            Org.OpenAPITools.Client.RequestOptions localVarRequestOptions = new Org.OpenAPITools.Client.RequestOptions();

            string[] _contentTypes = new string[] {
                "application/json"
            };

            // to determine the Accept header
            string[] _accepts = new string[] {
                "application/json"
            };


            var localVarContentType = Org.OpenAPITools.Client.ClientUtils.SelectHeaderContentType(_contentTypes);

            if (localVarContentType != null)
            {
                localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType);
            }

            var localVarAccept = Org.OpenAPITools.Client.ClientUtils.SelectHeaderAccept(_accepts);

            if (localVarAccept != null)
            {
                localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept);
            }

            localVarRequestOptions.HeaderParameters.Add("Content-Type", Org.OpenAPITools.Client.ClientUtils.ParameterToString(contentType));          // header parameter
            localVarRequestOptions.HeaderParameters.Add("Client-Request-Id", Org.OpenAPITools.Client.ClientUtils.ParameterToString(clientRequestId)); // header parameter
            localVarRequestOptions.HeaderParameters.Add("Api-Key", Org.OpenAPITools.Client.ClientUtils.ParameterToString(apiKey));                    // header parameter
            localVarRequestOptions.HeaderParameters.Add("Timestamp", Org.OpenAPITools.Client.ClientUtils.ParameterToString(timestamp));               // header parameter
            if (messageSignature != null)
            {
                localVarRequestOptions.HeaderParameters.Add("Message-Signature", Org.OpenAPITools.Client.ClientUtils.ParameterToString(messageSignature)); // header parameter
            }
            if (region != null)
            {
                localVarRequestOptions.HeaderParameters.Add("Region", Org.OpenAPITools.Client.ClientUtils.ParameterToString(region)); // header parameter
            }
            localVarRequestOptions.Data = exchangeRateRequest;


            // make the HTTP request

            var localVarResponse = await this.AsynchronousClient.PostAsync <ExchangeRateResponse>("/exchange-rates", localVarRequestOptions, this.Configuration, cancellationToken).ConfigureAwait(false);

            if (this.ExceptionFactory != null)
            {
                Exception _exception = this.ExceptionFactory("GetExchangeRate", localVarResponse);
                if (_exception != null)
                {
                    throw _exception;
                }
            }

            return(localVarResponse);
        }
Beispiel #6
0
        /// <summary>
        /// Generate dynamic currency conversion transactions. Sale, return and lookup exchange rate with dynamic currency conversion option.
        /// </summary>
        /// <exception cref="Org.OpenAPITools.Client.ApiException">Thrown when fails to make API call</exception>
        /// <param name="contentType">Content type.</param>
        /// <param name="clientRequestId">A client-generated ID for request tracking and signature creation, unique per request.  This is also used for idempotency control. We recommend 128-bit UUID format.</param>
        /// <param name="apiKey">Key given to merchant after boarding associating their requests with the appropriate app in Apigee.</param>
        /// <param name="timestamp">Epoch timestamp in milliseconds in the request from a client system. Used for Message Signature generation and time limit (5 mins).</param>
        /// <param name="exchangeRateRequest">Accepted request types: DCCExchangeRateRequest and DynamicPricingExchangeRateRequest.</param>
        /// <param name="messageSignature">Used to ensure the request has not been tampered with during transmission. The Message-Signature is the Base64 encoded HMAC hash (SHA256 algorithm with the API Secret as the key.) For more information, refer to the supporting documentation on the Developer Portal. (optional)</param>
        /// <param name="region">Indicates the region where the client wants the transaction to be processed. This will override the default processing region identified for the client. Available options are argentina, brazil, germany, india and northamerica. Region specific store setup and APIGEE boarding is required in order to use an alternate region for processing. (optional)</param>
        /// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
        /// <returns>Task of ExchangeRateResponse</returns>
        public async System.Threading.Tasks.Task <ExchangeRateResponse> GetExchangeRateAsync(string contentType, string clientRequestId, string apiKey, long timestamp, ExchangeRateRequest exchangeRateRequest, string messageSignature = default(string), string region = default(string), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken))
        {
            Org.OpenAPITools.Client.ApiResponse <ExchangeRateResponse> localVarResponse = await GetExchangeRateWithHttpInfoAsync(contentType, clientRequestId, apiKey, timestamp, exchangeRateRequest, messageSignature, region, cancellationToken).ConfigureAwait(false);

            return(localVarResponse.Data);
        }
Beispiel #7
0
 /// <summary>
 /// Generate dynamic currency conversion transactions. Sale, return and lookup exchange rate with dynamic currency conversion option.
 /// </summary>
 /// <exception cref="Org.OpenAPITools.Client.ApiException">Thrown when fails to make API call</exception>
 /// <param name="contentType">Content type.</param>
 /// <param name="clientRequestId">A client-generated ID for request tracking and signature creation, unique per request.  This is also used for idempotency control. We recommend 128-bit UUID format.</param>
 /// <param name="apiKey">Key given to merchant after boarding associating their requests with the appropriate app in Apigee.</param>
 /// <param name="timestamp">Epoch timestamp in milliseconds in the request from a client system. Used for Message Signature generation and time limit (5 mins).</param>
 /// <param name="exchangeRateRequest">Accepted request types: DCCExchangeRateRequest and DynamicPricingExchangeRateRequest.</param>
 /// <param name="messageSignature">Used to ensure the request has not been tampered with during transmission. The Message-Signature is the Base64 encoded HMAC hash (SHA256 algorithm with the API Secret as the key.) For more information, refer to the supporting documentation on the Developer Portal. (optional)</param>
 /// <param name="region">Indicates the region where the client wants the transaction to be processed. This will override the default processing region identified for the client. Available options are argentina, brazil, germany, india and northamerica. Region specific store setup and APIGEE boarding is required in order to use an alternate region for processing. (optional)</param>
 /// <returns>ExchangeRateResponse</returns>
 public ExchangeRateResponse GetExchangeRate(string contentType, string clientRequestId, string apiKey, long timestamp, ExchangeRateRequest exchangeRateRequest, string messageSignature = default(string), string region = default(string))
 {
     Org.OpenAPITools.Client.ApiResponse <ExchangeRateResponse> localVarResponse = GetExchangeRateWithHttpInfo(contentType, clientRequestId, apiKey, timestamp, exchangeRateRequest, messageSignature, region);
     return(localVarResponse.Data);
 }
        /// <summary>
        /// Sets the exchangeRates.
        /// </summary>
        /// <param name="request">The request.</param>
        /// <returns></returns>
        public ExchangeRateResponse SetExchangeRates(ExchangeRateRequest request)
        {
            var response = new ExchangeRateResponse();

            var exchangeRateEntity = request.ExchangeRate;

            if (request.Action != PersistType.Delete)
            {
                if (!exchangeRateEntity.Validate())
                {
                    foreach (var error in exchangeRateEntity.ValidationErrors)
                    {
                        response.Message += error + Environment.NewLine;
                    }
                    response.Acknowledge = AcknowledgeType.Failure;
                    return(response);
                }
            }
            try
            {
                if (request.Action == PersistType.Insert)
                {
                    using (var scope = new TransactionScope())
                    {
                        //Split exchangeRateEntity.BudgetSourceCode ra mảng để xác định số lần insert
                        var budgetSources = exchangeRateEntity.BudgetSourceCode.Split(',');
                        foreach (string t in budgetSources)
                        {
                            var exchangeRates = ExchangeRateDao.GetExchangeRatesByDateAndBudgetSource(exchangeRateEntity.FromDate, exchangeRateEntity.ToDate, t);
                            if (exchangeRates != null)
                            {
                                response.Acknowledge = AcknowledgeType.Failure;
                                response.Message     = @"Tỷ giá từ ngày " + exchangeRateEntity.FromDate.ToShortDateString() + @" đến ngày " + exchangeRateEntity.ToDate.ToShortDateString() + " của nguồn " + t + " đã tồn tại !";
                                return(response);
                            }
                            exchangeRateEntity.BudgetSourceCode = t;
                            exchangeRateEntity.Description      = "Tỷ giá nguồn " + t + " - Từ ngày " + exchangeRateEntity.FromDate.ToShortDateString() + " Đến ngày " + exchangeRateEntity.ToDate.ToShortDateString();
                            exchangeRateEntity.ExchangeRateId   = ExchangeRateDao.InsertExchangeRate(exchangeRateEntity);
                        }
                        scope.Complete();
                        response.Message = null;
                    }
                }
                else if (request.Action == PersistType.Update)
                {
                    //Kiem tra trung du lieu
                    //lay gia tri cua BudgetSourceCode, dung ham string de split, sau do kiem tra:
                    //1. Neu Count > 1 thi kiem tra phan tu 1 va 2 co giong nhau ko, neu giong nhau thi khong kiem tra gia tri trung, neu khac nhau thi qua buoc 3
                    //2. Kiem tra gia tri trung bang cach truyen vao phan tu thu 2 de kiem tra
                    using (var scope = new TransactionScope())
                    {
                        var budgetSources = exchangeRateEntity.BudgetSourceCode.Split(',');
                        if (budgetSources.Length == 2)
                        {
                            if (budgetSources[0] == budgetSources[1])
                            {
                                exchangeRateEntity.BudgetSourceCode = budgetSources[0];
                                response.Message = ExchangeRateDao.UpdateExchangeRate(exchangeRateEntity);
                            }
                            else
                            {
                                var exchangeRates =
                                    ExchangeRateDao.GetExchangeRatesByDateAndBudgetSource(exchangeRateEntity.FromDate,
                                                                                          exchangeRateEntity.ToDate, budgetSources[1]);
                                if (exchangeRates != null)
                                {
                                    response.Acknowledge = AcknowledgeType.Failure;
                                    response.Message     = @"Tỷ giá từ ngày " +
                                                           exchangeRateEntity.FromDate.ToShortDateString() + @" đến ngày " +
                                                           exchangeRateEntity.ToDate.ToShortDateString() + " của nguồn " +
                                                           budgetSources[1] + " đã tồn tại !";
                                    return(response);
                                }
                                exchangeRateEntity.BudgetSourceCode = budgetSources[1];
                                response.Message = ExchangeRateDao.UpdateExchangeRate(exchangeRateEntity);
                            }
                        }
                        if (response.Message == null)
                        {
                            scope.Complete();
                        }
                    }
                }
                else
                {
                    var exchangeRateForUpdate = ExchangeRateDao.GetExchangeRate(request.ExchangeRateId);
                    response.Message = ExchangeRateDao.DeleteExchangeRate(exchangeRateForUpdate);
                }
            }
            catch (Exception ex)
            {
                response.Acknowledge = AcknowledgeType.Failure;
                response.Message     = ex.Message;
                return(response);
            }
            response.ExchangeRateId = exchangeRateEntity != null ? exchangeRateEntity.ExchangeRateId : 0;
            if (response.Message == null)
            {
                response.Acknowledge  = AcknowledgeType.Success;
                response.RowsAffected = 1;
            }
            else
            {
                response.Acknowledge  = AcknowledgeType.Failure;
                response.RowsAffected = 0;
            }

            return(response);
        }
 public Task <ExchangeRateResponse> GetExchangeRateAsync(ExchangeRateRequest ExchangeRateRqst)
 {
     throw new NotImplementedException();
 }
Beispiel #10
0
        /// <summary>
        /// Generate dynamic currency conversion transactions. Sale, return and lookup exchange rate with dynamic currency conversion option.
        /// </summary>
        /// <exception cref="Org.OpenAPITools.Client.ApiException">Thrown when fails to make API call</exception>
        /// <param name="contentType">Content type.</param>
        /// <param name="clientRequestId">A client-generated ID for request tracking and signature creation, unique per request.  This is also used for idempotency control. We recommend 128-bit UUID format.</param>
        /// <param name="apiKey">Key given to merchant after boarding associating their requests with the appropriate app in Apigee.</param>
        /// <param name="timestamp">Epoch timestamp in milliseconds in the request from a client system. Used for Message Signature generation and time limit (5 mins).</param>
        /// <param name="exchangeRateRequest">Accepted request types: DCCExchangeRateRequest and DynamicPricingExchangeRateRequest.</param>
        /// <param name="messageSignature">Used to ensure the request has not been tampered with during transmission. The Message-Signature is the Base64 encoded HMAC hash (SHA256 algorithm with the API Secret as the key.) For more information, refer to the supporting documentation on the Developer Portal. (optional)</param>
        /// <param name="region">Indicates the region where the client wants the transaction to be processed. This will override the default processing region identified for the client. Available options are argentina, brazil, germany, india and northamerica. Region specific store setup and APIGEE boarding is required in order to use an alternate region for processing. (optional)</param>
        /// <returns>Task of ApiResponse (ExchangeRateResponse)</returns>
        public async System.Threading.Tasks.Task <Org.OpenAPITools.Client.ApiResponse <ExchangeRateResponse> > GetExchangeRateAsyncWithHttpInfo(string contentType, string clientRequestId, string apiKey, long timestamp, ExchangeRateRequest exchangeRateRequest, string messageSignature = null, string region = null)
        {
            // verify the required parameter 'contentType' is set
            if (contentType == null)
            {
                throw new Org.OpenAPITools.Client.ApiException(400, "Missing required parameter 'contentType' when calling CurrencyConversionApi->GetExchangeRate");
            }

            // verify the required parameter 'clientRequestId' is set
            if (clientRequestId == null)
            {
                throw new Org.OpenAPITools.Client.ApiException(400, "Missing required parameter 'clientRequestId' when calling CurrencyConversionApi->GetExchangeRate");
            }

            // verify the required parameter 'apiKey' is set
            if (apiKey == null)
            {
                throw new Org.OpenAPITools.Client.ApiException(400, "Missing required parameter 'apiKey' when calling CurrencyConversionApi->GetExchangeRate");
            }

            // verify the required parameter 'timestamp' is set
            if (timestamp == null)
            {
                throw new Org.OpenAPITools.Client.ApiException(400, "Missing required parameter 'timestamp' when calling CurrencyConversionApi->GetExchangeRate");
            }

            // verify the required parameter 'exchangeRateRequest' is set
            if (exchangeRateRequest == null)
            {
                throw new Org.OpenAPITools.Client.ApiException(400, "Missing required parameter 'exchangeRateRequest' when calling CurrencyConversionApi->GetExchangeRate");
            }


            Org.OpenAPITools.Client.RequestOptions requestOptions = new Org.OpenAPITools.Client.RequestOptions();

            String[] @contentTypes = new String[] {
                "application/json"
            };

            // to determine the Accept header
            String[] @accepts = new String[] {
                "application/json"
            };

            foreach (var _contentType in @contentTypes)
            {
                requestOptions.HeaderParameters.Add("Content-Type", _contentType);
            }

            foreach (var accept in @accepts)
            {
                requestOptions.HeaderParameters.Add("Accept", accept);
            }

            if (contentType != null)
            {
                requestOptions.HeaderParameters.Add("Content-Type", Org.OpenAPITools.Client.ClientUtils.ParameterToString(contentType)); // header parameter
            }
            if (clientRequestId != null)
            {
                requestOptions.HeaderParameters.Add("Client-Request-Id", Org.OpenAPITools.Client.ClientUtils.ParameterToString(clientRequestId)); // header parameter
            }
            if (apiKey != null)
            {
                requestOptions.HeaderParameters.Add("Api-Key", Org.OpenAPITools.Client.ClientUtils.ParameterToString(apiKey)); // header parameter
            }
            if (timestamp != null)
            {
                requestOptions.HeaderParameters.Add("Timestamp", Org.OpenAPITools.Client.ClientUtils.ParameterToString(timestamp)); // header parameter
            }
            if (messageSignature != null)
            {
                requestOptions.HeaderParameters.Add("Message-Signature", Org.OpenAPITools.Client.ClientUtils.ParameterToString(messageSignature)); // header parameter
            }
            if (region != null)
            {
                requestOptions.HeaderParameters.Add("Region", Org.OpenAPITools.Client.ClientUtils.ParameterToString(region)); // header parameter
            }
            requestOptions.Data = exchangeRateRequest;


            // make the HTTP request

            var response = await this.AsynchronousClient.PostAsync <ExchangeRateResponse>("/exchange-rates", requestOptions, this.Configuration);

            if (this.ExceptionFactory != null)
            {
                Exception exception = this.ExceptionFactory("GetExchangeRate", response);
                if (exception != null)
                {
                    throw exception;
                }
            }

            return(response);
        }
Beispiel #11
0
        /// <summary>
        /// Generate dynamic currency conversion transactions. Sale, return and lookup exchange rate with dynamic currency conversion option.
        /// </summary>
        /// <exception cref="Org.OpenAPITools.Client.ApiException">Thrown when fails to make API call</exception>
        /// <param name="contentType">Content type.</param>
        /// <param name="clientRequestId">A client-generated ID for request tracking and signature creation, unique per request.  This is also used for idempotency control. We recommend 128-bit UUID format.</param>
        /// <param name="apiKey">Key given to merchant after boarding associating their requests with the appropriate app in Apigee.</param>
        /// <param name="timestamp">Epoch timestamp in milliseconds in the request from a client system. Used for Message Signature generation and time limit (5 mins).</param>
        /// <param name="exchangeRateRequest">Accepted request types: DCCExchangeRateRequest and DynamicPricingExchangeRateRequest.</param>
        /// <param name="messageSignature">Used to ensure the request has not been tampered with during transmission. The Message-Signature is the Base64 encoded HMAC hash (SHA256 algorithm with the API Secret as the key.) For more information, refer to the supporting documentation on the Developer Portal. (optional)</param>
        /// <param name="region">Indicates the region where the client wants the transaction to be processed. This will override the default processing region identified for the client. Available options are argentina, brazil, germany, india and northamerica. Region specific store setup and APIGEE boarding is required in order to use an alternate region for processing. (optional)</param>
        /// <returns>Task of ExchangeRateResponse</returns>
        public async System.Threading.Tasks.Task <ExchangeRateResponse> GetExchangeRateAsync(string contentType, string clientRequestId, string apiKey, long timestamp, ExchangeRateRequest exchangeRateRequest, string messageSignature = null, string region = null)
        {
            Org.OpenAPITools.Client.ApiResponse <ExchangeRateResponse> localVarResponse = await GetExchangeRateAsyncWithHttpInfo(contentType, clientRequestId, apiKey, timestamp, exchangeRateRequest, messageSignature, region);

            return(localVarResponse.Data);
        }
 private static string GetCacheKey(ExchangeRateRequest request, string rateProvider)
 {
     return($"{rateProvider}_{request.From.Value}_{request.To.Value}_{request.Date:d}");
 }
 public Task <bool> TryGetAsync(ExchangeRateRequest model, out decimal rate, string rateProvider)
 {
     return(Task.FromResult(_storage.TryGetValue(GetCacheKey(model, rateProvider), out rate)));
 }