public AmendResponseHolder DoAddProductAmendment(String subscriptionId, DateTime effectiveDate, String productRatePlanId, AmendOptions ao = null, PreviewOptions po = null)
        {
            AmendRequest amendRequest = new AmendRequest();
            Amendment amendment = new Amendment();

            amendment.Name = "Add Product Amendment";
            amendment.Type = "NewProduct";
            amendment.ContractEffectiveDate = effectiveDate;
            amendment.ContractEffectiveDateSpecified = true;
            amendment.SubscriptionId = subscriptionId;

            RatePlanData ratePlanData = new RatePlanData();
            RatePlan ratePlan = new RatePlan();
            ratePlan.ProductRatePlanId = productRatePlanId;
            ratePlanData.RatePlan = ratePlan;

            amendment.RatePlanData = ratePlanData;
            if (ao != null)
            {
                amendRequest.AmendOptions = ao;
            }
            if (po != null)
            {
                amendRequest.PreviewOptions = po;
            }
            amendRequest.Amendments = new Amendment[] { amendment };
            return zs.Amend(new List<AmendRequest> { amendRequest })[0];
        }
Пример #2
0
        public SubscribeRequest CreatSubscriptionRequest(DateTime date)
        {
            String rateplanid = CreateRatePlanToSubscribe();

            SubscribeRequest subrequest = new SubscribeRequest();

            subrequest.Account = MakeTestAccount();
            subrequest.BillToContact = MakeTestContact();
            subrequest.PaymentMethod = MakeTestPaymentMethod();
            SubscriptionData sd = new SubscriptionData();

            sd.Subscription = MakeTestSubscription(date);
            RatePlanData rpd = new RatePlanData();
            RatePlan rp = new RatePlan();
            rp.ProductRatePlanId = rateplanid;
            rpd.RatePlan = rp;
            sd.RatePlanData = new RatePlanData[] { rpd };
            subrequest.SubscriptionData = sd;

            return subrequest;
        }
        public SubscribeResponseHolder SubscribeWithExisitingAccount(String accountId, List<ProductRatePlanHolder> productRatePlans, Subscription sub, PreviewOptions po, SubscribeOptions so)
        {
            SubscribeRequest subscribeRequest = new SubscribeRequest();
            subscribeRequest.SubscribeOptions = so;
            subscribeRequest.PreviewOptions = po;

            Account acc = new Account();
            acc.Id = accountId;
            subscribeRequest.Account = acc;

            SubscriptionData subData = new SubscriptionData();
            sub.AccountId = accountId;
            subData.Subscription = sub;

            List<RatePlanData> rpdList = new List<RatePlanData>();

            foreach (ProductRatePlanHolder prph in productRatePlans)
            {

                RatePlanData ratePlanData = new RatePlanData();
                RatePlan ratePlan = new RatePlan();
                ratePlan.ProductRatePlanId = prph.ProductRatePlan.Id;
                ratePlanData.RatePlan = ratePlan;
                List<RatePlanChargeData> rpcData = new List<RatePlanChargeData>();
                foreach(ProductRatePlanChargeHolder prpch in prph.ProductRatePlanCharges)
                {
                    ProductRatePlanCharge prpc = prpch.ProductRatePlanCharge;
                    //set quantity and add chargeData if applicable
                    if ((prpc.ChargeModel.Equals("Per Unit Pricing") || prpc.ChargeModel.Equals("Tiered Pricing") || prpc.ChargeModel.Equals("Volume Pricing")))
                    {
                        RatePlanChargeData ratePlanChargeData = new RatePlanChargeData();
                        RatePlanCharge ratePlanCharge = new RatePlanCharge();
                        ratePlanCharge.ProductRatePlanChargeId = prpc.Id;
                        ratePlanCharge.QuantitySpecified = true;
                        ratePlanCharge.Quantity = prpc.DefaultQuantity;
                        ratePlanChargeData.RatePlanCharge = ratePlanCharge;
                        rpcData.Add(ratePlanChargeData);
                    }
                }
                if (rpcData.Count != 0)
                {
                    ratePlanData.RatePlanChargeData = rpcData.ToArray();
                }
                rpdList.Add(ratePlanData);

            }

            subData.RatePlanData = rpdList.ToArray();
            subscribeRequest.SubscriptionData = subData;
            return zs.Subscribe(new List<SubscribeRequest>{subscribeRequest})[0];
        }
        /*public ResponseHolder GetCurrentSubscription(String subscriptionId)
        {
            String subscriptionQuery = "SELECT Id,Name,Status,Version,PreviousSubscriptionId,ContractEffectiveDate,TermStartDate FROM Subscription WHERE AccountId='" + subscriptionId + "' AND Status='Active'AND Status='Active'";
            Subscription activeSubscription = (Subscription)zs.Query(subscriptionQuery).Objects[0];

            String RatePlanString = "SELECT Id,Name,ProductRatePlanId FROM RatePlan WHERE SubscriptionId='" + activeSubscription.Id + "'";
            ResponseHolder ratePlans = zs.Query(RatePlanString);

            foreach (zObject ratePlan in ratePlans.Objects)
            {

            }
        }*/
        public SubscribeResponseHolder Subscribe(Account acc, Contact con, PaymentMethod pay, List<ProductRatePlanHolder> productRatePlans, Subscription sub, PreviewOptions po, SubscribeOptions so)
        {
            SubscribeRequest subscribeRequest = new SubscribeRequest();
            subscribeRequest.SubscribeOptions = so;
            subscribeRequest.PreviewOptions = po;

            subscribeRequest.Account = acc;
            subscribeRequest.BillToContact = con;
            //Payment Method isn't required to subscribe
            if (pay != null)
            {
                subscribeRequest.PaymentMethod = pay;
            }

            SubscriptionData subData = new SubscriptionData();
            sub.AccountId = acc.Id;
            subData.Subscription = sub;
            List<RatePlanData> rpdList = new List<RatePlanData>();

            foreach (ProductRatePlanHolder prph in productRatePlans)
            {

                RatePlanData ratePlanData = new RatePlanData();
                RatePlan ratePlan = new RatePlan();
                ratePlan.ProductRatePlanId = prph.ProductRatePlan.Id;
                ratePlanData.RatePlan = ratePlan;
                List<RatePlanChargeData> rpcData = new List<RatePlanChargeData>();
                if (prph.ProductRatePlanCharges != null)
                {
                    foreach (ProductRatePlanChargeHolder prpch in prph.ProductRatePlanCharges)
                    {
                        ProductRatePlanCharge prpc = prpch.ProductRatePlanCharge;
                        //set quantity and add chargeData if applicable
                        if ((prpc.ChargeModel.Equals("Per Unit Pricing") || prpc.ChargeModel.Equals("Tiered Pricing") || prpc.ChargeModel.Equals("Volume Pricing")))
                        {
                            RatePlanChargeData ratePlanChargeData = new RatePlanChargeData();
                            RatePlanCharge ratePlanCharge = new RatePlanCharge();
                            ratePlanCharge.ProductRatePlanChargeId = prpc.Id;
                            ratePlanCharge.QuantitySpecified = true;
                            ratePlanCharge.Quantity = prpc.DefaultQuantity;
                            ratePlanChargeData.RatePlanCharge = ratePlanCharge;
                            rpcData.Add(ratePlanChargeData);
                        }
                    }
                }
                if (rpcData.Count != 0)
                {
                    ratePlanData.RatePlanChargeData = rpcData.ToArray();
                }
                rpdList.Add(ratePlanData);

            }

            subData.RatePlanData = rpdList.ToArray();
            subscribeRequest.SubscriptionData = subData;
            return zs.Subscribe(new List<SubscribeRequest> { subscribeRequest })[0];
        }
Пример #5
0
        protected RatePlanData[] makeRatePlanData(ProductRatePlanCharge[] charges)
        {
            RatePlanData[] data = new RatePlanData[charges.Length];

            for (int i = 0; i < charges.Length; i++)
            {
                ProductRatePlanCharge charge = charges[i];
                RatePlanData ratePlanData = new RatePlanData();

                RatePlan ratePlan = new RatePlan();
                ratePlanData.RatePlan = ratePlan;
                ratePlan.AmendmentType = "NewProduct";
                ratePlan.ProductRatePlanId = charge.ProductRatePlanId;

                RatePlanChargeData ratePlanChargeData = new RatePlanChargeData();
                ratePlanData.RatePlanChargeData = new RatePlanChargeData[] { ratePlanChargeData };

                RatePlanCharge ratePlanCharge = new RatePlanCharge();
                ratePlanChargeData.RatePlanCharge = ratePlanCharge;

                ratePlanCharge.ProductRatePlanChargeId = charge.Id;
                // if it has a default quantity, default to 1
                if (charge.DefaultQuantitySpecified)
                {
                    ratePlanCharge.Quantity = 1;
                }
                ratePlanCharge.QuantitySpecified = true;
                ratePlanCharge.TriggerEvent = "ServiceActivation";

                data[i] = ratePlanData;
            }

            return data;
        }
        private RatePlanData[] makeRatePlanData(ProductRatePlanCharge charge)
        {
            var ratePlanData = new RatePlanData();

            var ratePlan = new RatePlan();
            ratePlanData.RatePlan = ratePlan;
            ratePlan.AmendmentType = "NewProduct";
            ratePlan.ProductRatePlanId = charge.ProductRatePlanId;

            var ratePlanChargeData = new RatePlanChargeData();
            ratePlanData.RatePlanChargeData = new[] {ratePlanChargeData};

            var ratePlanCharge = new RatePlanCharge();
            ratePlanChargeData.RatePlanCharge = ratePlanCharge;

            ratePlanCharge.ProductRatePlanChargeId = charge.Id;
            ratePlanCharge.Quantity = 1;
            ratePlanCharge.QuantitySpecified = true;
            ratePlanCharge.TriggerEvent = "ServiceActivation";

            return new[] {ratePlanData};
        }