Exemplo n.º 1
0
        public AmazonFactory(IAmazonRequest amazonRequest)
        {
            amazonResponse = new AmazonResponse { Errors = new List<KeyValuePair<string, string>>() };

            amazonResponse.Errors = amazonRequest.Validate();

            if(amazonResponse.Errors.Count == 0)
            {
                if (!string.IsNullOrEmpty(amazonRequest.ListId))
                {
                    productListMapper = new ProductListMapper(amazonRequest);
                }

                if (!string.IsNullOrEmpty(amazonRequest.CustomerId))
                {
                    reviewListMapper = new ReviewListMapper(amazonRequest);
                }                
            }
        }
Exemplo n.º 2
0
        public AmazonResponse GetResponse()
        {
            var amazonResponse = new AmazonResponse {Errors = new List<KeyValuePair<string, string>>()};

            if (productListMapper != null)
            {
                if (productListMapper.GetErrors().Count != 0)
                {
                    foreach (var error in productListMapper.GetErrors())
                    {
                        amazonResponse.Errors.Add(error.Translate());
                    }
                }
                else
                {
                    amazonResponse.Products = productListMapper.GetList();
                }
            }

            if (reviewListMapper != null)
            {
                if (reviewListMapper.GetErrors().Count != 0)
                {
                    foreach (var error in reviewListMapper.GetErrors())
                    {
                        amazonResponse.Errors.Add(error.Translate());
                    }
                }
                else
                {
                    amazonResponse.Reviews = reviewListMapper.GetReviewList();
                }
            }

            return amazonResponse;
        }