示例#1
0
        public static BacklogClient CreateTestClient()
        {
            var settings = JsonConvert.DeserializeObject <_Settings>(File.ReadAllText("client.json"));
            var config   = new BacklogClientConfig()
            {
                ThrowOnClientError = true,
            };

            var client = new BacklogClient("nbacklog", "backlog.com", config);

            client.AuthorizeAsync(new OAuth2App()
            {
                ClientId             = settings.client_id,
                ClientSecret         = settings.client_secret,
                RedirectUri          = "http://localhost:54321/",
                CredentialsCachePath = "oauth2cache.json",
            })
            .Wait();

            return(client);
        }
示例#2
0
        /// <summary>
        /// プロジェクト情報の取得
        /// </summary>
        public async void LoadProjectInfo(Action onSuccess = null)
        {
            APIData = BacklogAPIData.Load();

            // エディタが再生中かつ一時停止中だと認証時にawaitで止まってしまうので、キャッシュがない時は一時停止を解除する
            bool isPaused = EditorApplication.isPaused;

            if (EditorApplication.isPlaying)
            {
                bool isCached = File.Exists($"{Application.dataPath}/../{APIData.CacheFileName}");
                if (!isCached)
                {
                    EditorApplication.isPaused = false;
                }
            }

            // 認証
            var client = new BacklogClient(APIData.SpaceKey, APIData.Domain);
            await client.AuthorizeAsync(new OAuth2App()
            {
                ClientId             = APIData.ClientId,
                ClientSecret         = APIData.ClientSecretId,
                RedirectUri          = APIData.RedirectURI,
                CredentialsCachePath = APIData.CacheFileName,
            });

            EditorApplication.isPaused = isPaused;

            // 各種データ取得
            Space            = client.GetSpaceAsync().Result.Content;
            Project          = client.GetProjectAsync(APIData.ProjectKey).Result.Content;
            Data.TicketTypes = Project.GetTicketTypesAsync().Result.Content;
            Data.Priorities  = client.GetPriorityTypesAsync().Result.Content;
            Data.Categories  = Project.GetCategoriesAsync().Result.Content;
            Data.Milestones  = Project.GetMilestonesAsync().Result.Content;
            Data.Users       = Project.GetUsersAsync().Result.Content;

            onSuccess?.Invoke();
        }