예제 #1
0
        public async Task EnsureWorkspaceIsOnPlan(IUser user, long workspaceId, PricingPlans plan)
        {
            if (planOfDefaultWorkspaceById.TryGetValue(workspaceId, out var lastPlan) && lastPlan == plan)
            {
                return;
            }

            planOfDefaultWorkspaceById[workspaceId] = plan;

            await WorkspaceHelper.SetSubscription(user, workspaceId, plan);
        }
예제 #2
0
        public async Task EnsureDefaultWorkspaceIsOnPlan(ITogglApi api, PricingPlans plan)
        {
            if (planOfDefaultWorkspaceByApi.TryGetValue(api, out var lastPlan) && lastPlan == plan)
            {
                return;
            }

            planOfDefaultWorkspaceByApi[api] = plan;

            if (!userByApi.TryGetValue(api, out var user))
            {
                user = await api.User.Get();

                userByApi[api] = user;
            }

            await EnsureDefaultWorkspaceIsOnPlan(user, plan);
        }
예제 #3
0
        public static async Task SetSubscription(IUser user, long workspaceId, PricingPlans plan)
        {
            var json = $"{{\"pricing_plan_id\":{(int)plan}}}";

            await makeRequest($"https://toggl.space/api/v9/workspaces/{workspaceId}/subscription", HttpMethod.Post, user, json);
        }
예제 #4
0
            public async void CreatingTaskWorksForAllPricingPlansOtherThanTheFreePlan(PricingPlans plan)
            {
                var(togglApi, user) = await SetupTestUser();

                await plans.EnsureDefaultWorkspaceIsOnPlan(user, plan);

                var project = createProject(togglApi, user.DefaultWorkspaceId).Wait();

                Action creatingTask = () => createTask(togglApi, project, user.Id).Wait();

                creatingTask.ShouldNotThrow();
            }
예제 #5
0
 private static Dictionary <string, Pricing> GetPricingDictionary(PricingPlans pricing)
 {
     return(pricing.Plans.ToDictionary(plan => plan.Id));
 }
예제 #6
0
 public Task EnsureDefaultWorkspaceIsOnPlan(IUser user, PricingPlans plan)
 => EnsureWorkspaceIsOnPlan(user, user.DefaultWorkspaceId.Value, plan);
예제 #7
0
 private static Dictionary <string, Pricing> GetPricingDictionary(PricingPlans pricing)
 {
     return(pricing.Plans.Where(plan => PlanIncludesVpn(plan) && IsPlanPrimary(plan)).ToDictionary(plan => plan.Id));
 }