Beispiel #1
0
        static async Task RunSample1Async(AppConfig appConfig)
        {
            int    accountId   = 999999999;
            string accessToken = "YOUR_OAUTH_TOKEN";

            accountId   = appConfig.AccountId;
            accessToken = appConfig.AccessToken;
            if (string.IsNullOrWhiteSpace(accessToken))
            {
                Console.WriteLine("No access token");
                return;
            }

            var basecampClient = new BasecampClient(accountId, accessToken);
            var projects       = await basecampClient.GetProjectsAsync();

            foreach (var project in projects)
            {
                Console.WriteLine($"Project {project.Name} ({project.Id})");
            }

            if (projects.NextUri != null)
            {
                var moreProjects = await basecampClient.GetMoreProjectsAsync(projects.NextUri);

                foreach (var project in moreProjects)
                {
                    Console.WriteLine($"Project {project.Name} ({project.Id})");
                }
            }
        }
Beispiel #2
0
        static async Task RunSample2Async(AppConfig appConfig)
        {
            int    accountId    = 999999999;
            string clientId     = "YOUR_CLIENT_ID";
            string clientSecret = "YOUR_CLIENT_SECRET";
            string redirectUrl  = "YOUR_REDIRECT_URL";
            string refreshToken = "YOUR_REFRESH_TOKEN";

            accountId    = appConfig.AccountId;
            clientId     = appConfig.ClientId;
            clientSecret = appConfig.ClientSecret;
            redirectUrl  = appConfig.RedirectUrl;
            refreshToken = appConfig.RefreshToken;

            var accessTokenSource = new AccessTokenSource(
                clientId: clientId,
                clientSecret: clientSecret,
                redirectUrl: redirectUrl,
                refreshToken: refreshToken
                );
            var basecampClient = new BasecampClient(accountId, accessTokenSource);


            var projects = await basecampClient.GetProjectsAsync();

            foreach (var project in projects.AsReadToEndEnumerable())
            {
                Console.WriteLine($"Project {project.Name} ({project.Id})");
            }

            var projectEnumerator = projects.GetReadToEndEnumerator();

            while (await projectEnumerator.MoveNextAsync(CancellationToken.None))
            {
                var project = projectEnumerator.Current;
                Console.WriteLine($"Project {project.Name} ({project.Id})");
            }

            var recordings = await basecampClient.GetRecordingsAsync(RecordingTypeEnum.ScheduleEntry);

            var bucketId    = recordings.First().Bucket.Id.Value;
            var recordingId = recordings.First().Id.Value;
            var events      = await basecampClient.GetEventsAsync(bucketId, recordingId);

            Console.WriteLine();
            Console.WriteLine("First Page Events:");

            foreach (var e in events)
            {
                Console.WriteLine($"Event {e.Action} ({e.Id})");
            }
        }