예제 #1
0
        public Plan ToSDKPlan()
        {
            if (sdkPlan != null)
            {
                return(sdkPlan);
            }
            else if (apiPlan != null)
            {
                PlanBuilder builder = PlanBuilder.NewPlan(apiPlan.Name)
                                      .WithContract(apiPlan.Contract)
                                      .WithData(apiPlan.Data)
                                      .WithId(apiPlan.Id)
                                      .WithCycle(apiPlan.Cycle)
                                      .WithDescription(apiPlan.Description)
                                      .WithFeatures(apiPlan.Features)
                                      .WithGroup(apiPlan.Group)
                                      .WithOriginal(apiPlan.Original)
                                      .WithPrice(new PriceConverter(apiPlan.Price).ToSDKPrice());
                if (apiPlan.FreeCycles != null)
                {
                    builder.WithFreeCycles(apiPlan.FreeCycles.Count, apiPlan.FreeCycles.Cycle);
                }

                if (apiPlan.Quotas != null && apiPlan.Quotas.Count > 0)
                {
                    foreach (API.Quota quota in apiPlan.Quotas)
                    {
                        builder.WithQuota(quota.Cycle, quota.Limit, quota.Scope, quota.Target);
                    }
                }

                return(builder.Build());
            }
            else
            {
                return(null);
            }
        }