public object Run()
        {
            var request  = new RetrievePlanRequest(_planRepo.DoesPlanIdExist, _planRepo.RetrievePlan, _id);
            var response = request.Handle();

            if (response.Plan.Token != _token)
            {
                return(new ErrorViewModel {
                    ErrorMessage = "Invalid access token for editing the plan"
                });
            }

            if (!string.IsNullOrEmpty(response.ErrorMessage))
            {
                return(new ErrorViewModel {
                    ErrorMessage = response.ErrorMessage
                });
            }

            var result = Mapper.Map <PlanFormViewModel>(response.Plan);

            var choreOne = result.Chores.FirstOrDefault();

            result.StartDate = choreOne?.StartDay ?? DateTime.Now;

            return(result);
        }
示例#2
0
        public void Should_Retrieve_Plan()
        {
            string randomString = DateTime.Now.ToString("yyyyMMddHHmmssfff");
            CreateProductRequest createProductRequest = new CreateProductRequest
            {
                Description    = "product-description",
                Locale         = Locale.TR.ToString(),
                Name           = $"product-name-{randomString}",
                ConversationId = "123456789"
            };

            ResponseData <ProductResource> createProductResponse = Product.Create(createProductRequest, _options);

            CreatePlanRequest createPlanRequest = new CreatePlanRequest()
            {
                Locale               = Locale.TR.ToString(),
                Name                 = $"plan-name-{randomString}",
                ConversationId       = "123456789",
                TrialPeriodDays      = 3,
                Price                = "5.23",
                CurrencyCode         = Currency.TRY.ToString(),
                PaymentInterval      = PaymentInterval.WEEKLY.ToString(),
                RecurrenceCount      = 12,
                PaymentIntervalCount = 1,
                PlanPaymentType      = PlanPaymentType.RECURRING.ToString(),
                ProductReferenceCode = createProductResponse.Data.ReferenceCode
            };

            ResponseData <PlanResource> createPlanResponse = Plan.Create(createPlanRequest, _options);

            RetrievePlanRequest request = new RetrievePlanRequest()
            {
                Locale                   = Locale.TR.ToString(),
                ConversationId           = "123456789",
                PricingPlanReferenceCode = createPlanResponse.Data.ReferenceCode
            };

            ResponseData <PlanResource> response = Plan.Retrieve(request, _options);

            PrintResponse(response);

            Assert.AreEqual(response.Status, Status.SUCCESS.ToString());
            Assert.AreEqual($"plan-name-{randomString}", response.Data.Name);
            Assert.AreEqual("5.23", response.Data.Price.RemoveTrailingZeros());
            Assert.AreEqual(Currency.TRY.ToString(), response.Data.CurrencyCode);
            Assert.AreEqual(createProductResponse.Data.ReferenceCode, response.Data.ProductReferenceCode);
            Assert.AreEqual(PaymentInterval.WEEKLY.ToString(), response.Data.PaymentInterval);
            Assert.AreEqual(1, response.Data.PaymentIntervalCount);
            Assert.AreEqual(3, response.Data.TrialPeriodDays);
            Assert.AreEqual(PlanPaymentType.RECURRING.ToString(), response.Data.PlanPaymentType);
            Assert.AreEqual(12, response.Data.RecurrenceCount);
            Assert.AreEqual("ACTIVE", response.Data.Status);
            Assert.IsNotNull(response.Data.ReferenceCode);
            Assert.IsNotNull(response.Data.CreatedDate);
            Assert.IsNotNull(response.SystemTime);
            Assert.Null(response.ErrorMessage);
        }
示例#3
0
        public object Run()
        {
            var request  = new RetrievePlanRequest(_planRepo.DoesPlanIdExist, _planRepo.RetrievePlan, _id);
            var response = request.Handle();

            if (!string.IsNullOrEmpty(response.ErrorMessage))
            {
                return(new ErrorViewModel {
                    ErrorMessage = response.ErrorMessage
                });
            }

            return(Mapper.Map <PlanViewModel>(response.Plan));
        }
        public void Should_Retrieve_Plan()
        {
            RetrievePlanRequest request = new RetrievePlanRequest()
            {
                Locale                   = Locale.TR.ToString(),
                ConversationId           = "123456789",
                PricingPlanReferenceCode = "pricingPlanReferenceCode"
            };

            ResponseData <PlanResource> response = Plan.Retrieve(request, options);

            PrintResponse(response);

            Assert.AreEqual(response.Status, Status.SUCCESS.ToString());
            Assert.AreEqual(Currency.TRY.ToString(), response.Data.CurrencyCode);
            Assert.IsNotNull(response.Data.ReferenceCode);
            Assert.IsNotNull(response.Data.CreatedDate);
            Assert.IsNotNull(response.SystemTime);
            Assert.Null(response.ErrorMessage);
        }
示例#5
0
        public static ResponseData <PlanResource> Retrieve(RetrievePlanRequest request, Options options)
        {
            string uri = $"{options.BaseUrl}/v2/subscription/pricing-plans/{request.PricingPlanReferenceCode}";

            return(RestHttpClientV2.Create().Get <ResponseData <PlanResource> >(uri, GetHttpHeadersWithUrlParams(request, uri, options)));
        }