Beispiel #1
0
        private static async System.Threading.Tasks.Task Main(string[] args)
        {
            try
            {
                await Config.Read(ConfigFile);

                var token       = Config.GetValue(Constants.APIKey);
                var projectName = Config.GetValue(Constants.DefaultProjectName, Constants.Inbox);
                var user        = new Todoist.Net.TodoistClient(token);
                var projects    = await user.Projects.GetAsync();

                var project = projects.FirstOrDefault(p => p.Name == (projectName ?? Constants.Inbox));
                var content = string.Join(" ", args);
                var item    = new Item(content)
                {
                    ProjectId = project?.Id
                };
                Console.WriteLine($"Adding '{content}'");
                await user.Items.AddAsync(item);

                Console.WriteLine("Done");
            }
            finally
            {
                await Config.Write(ConfigFile);
            }
        }
        async void Connect(string githubUrl, string githubToken, string todoistToken)
        {
            m_client             = new Octokit.GitHubClient(new Octokit.ProductHeaderValue("github-todoist"), new Uri(githubUrl));
            m_client.Credentials = new Octokit.Credentials(githubToken);

            m_currentUser = await m_client.User.Current();

            GithubUserName.Content    = String.Format("Connected: {0}", m_currentUser.Login);
            GithubUserName.Foreground = Brushes.Green;

            var allRepos = await m_client.Repository.GetAllForCurrent();

            Repository.Items.Clear();
            foreach (var repo in allRepos)
            {
                var repoItem = new RepositoryItem()
                {
                    name = repo.FullName, id = repo.Id
                };
                Repository.Items.Add(repoItem);
            }

            m_todoistClient = new Todoist.Net.TodoistClient(todoistToken);

            var projects = await m_todoistClient.Projects.GetAsync();

            TodoistProjects.Items.Clear();
            foreach (var project in projects)
            {
                var todoistItem = new TodoistItem()
                {
                    name = project.Name, id = project.Id
                };
                TodoistProjects.Items.Add(todoistItem);
            }
        }