コード例 #1
0
        public static async Task SetupClient(TestContext context)
        {
            generalConfig = GeneralConfig.Instance.Value;
            var conf = new BacklogJpConfigure(generalConfig.SpaceKey);

            conf.ApiKey = generalConfig.ApiKey;
            client      = new BacklogClientFactory(conf).NewClient();
            var users = await client.GetUsersAsync();

            projectKey = generalConfig.ProjectKey;
            var project = await client.GetProjectAsync(projectKey);

            projectId = project.Id;

            gitConfig = GitConfig.Instance.Value;

            ownUser = await client.GetMyselfAsync();

            var numericUserIds = (await client.GetUsersAsync()).ToDictionary(x => x.UserId, x => x.Id);

            notifiedNumericUserIds = new[]
            { gitConfig.NotifiedUserId1, gitConfig.NotifiedUserId2, gitConfig.NotifiedUserId3 }
            .Select(x => numericUserIds[x])
            .ToArray();

            assigneeUserIds = new[]
            { gitConfig.AssigneeUserId1, gitConfig.AssigneeUserId2, gitConfig.AssigneeUserId3 }
            .Select(x => numericUserIds[x])
            .ToArray();
        }
コード例 #2
0
 internal GroupActivityContent(JObject data, BacklogClient client, ActivityAction action)
     : base(action)
 {
     Groups = (data.Value <JArray>("parties") ?? Enumerable.Empty <object>()).Cast <JObject>()
              .Select(x => new GroupSummary(x.ToObject <_GroupSummary>()))
              .ToArray();
 }
コード例 #3
0
        internal Ticket(_Ticket data, Project project, BacklogClient client)
            : base(data.id)
        {
            Project        = project;
            Key            = data.issueKey;
            KeyId          = data.keyId;
            Type           = client.ItemsCache.Update(data.issueType?.id, () => new TicketType(data.issueType, project));
            Summary        = data.summary;
            Description    = data.description;
            Resolution     = client.ItemsCache.Update(data.resolution?.id, () => new Resolution(data.resolution));
            Priority       = client.ItemsCache.Update(data.priority?.id, () => new Priority(data.priority));
            Status         = client.ItemsCache.Update(data.status?.id, () => new Status(data.status));
            Assignee       = client.ItemsCache.Update(data.assignee?.id, () => new User(data.assignee, client));
            Categories     = data.category.Select(x => client.ItemsCache.Update(x.id, () => new Category(x))).ToArray();
            Versions       = data.versions.Select(x => client.ItemsCache.Update(x.id, () => new Milestone(x, project))).ToArray();
            Milestones     = data.milestone.Select(x => client.ItemsCache.Update(x.id, () => new Milestone(x, project))).ToArray();
            StartDate      = data.startDate?.Date;
            DueDate        = data.dueDate?.Date;
            EstimatedHours = data.estimatedHours;
            ActualHours    = data.actualHours;
            ParentTicketId = data.parentIssueId;
            Creator        = client.ItemsCache.Update(data.createdUser?.id, () => new User(data.createdUser, client));
            Created        = data.created;
            LastUpdater    = client.ItemsCache.Update(data.updatedUser?.id, () => new User(data.updatedUser, client));
            LastUpdated    = data.updated;
            CustomFields   = data.customFields.Select(x => new CustomFieldValue(x)).ToArray();
            Attachments    = data.attachments.Select(x => new Attachment(x, this)).ToArray();
            SharedFiles    = data.sharedFiles.Select(x => new SharedFile(x, project)).ToArray();
            Stars          = data.stars.Select(x => new Star(x, client)).ToArray();

            _client = client;
        }
コード例 #4
0
ファイル: Notification.cs プロジェクト: iranika/NBacklog
 internal Notification(_Notification data, BacklogClient client)
     : base(data.id)
 {
     IsAlreadyRead         = data.alreadyRead;
     Reason                = (NotificationReason)data.reason;
     User                  = client.ItemsCache.Update(data.user?.id, () => new User(data.user, client));
     IsResourceAlreadyRead = data.resourceAlreadyRead;
 }
コード例 #5
0
ファイル: Attachment.cs プロジェクト: iranika/NBacklog
 internal Attachment(_Attachment data, BacklogClient client)
     : base(data.id)
 {
     Name    = data.name;
     Size    = data.size;
     Creator = client.ItemsCache.Update(data.createdUser?.id, () => new User(data.createdUser, client));
     Created = data.created;
     _client = client;
 }
コード例 #6
0
        public static async Task SetupClient(TestContext context)
        {
            generalConfig = GeneralConfig.Instance.Value;
            var conf = new BacklogJpConfigure(generalConfig.SpaceKey);

            conf.ApiKey = generalConfig.ApiKey;
            client      = new BacklogClientFactory(conf).NewClient();
            var users = await client.GetUsersAsync();
        }
コード例 #7
0
 internal ProjectUserActivityContent(JObject data, BacklogClient client, ActivityAction action)
     : base(action)
 {
     Users = (data.Value <JArray>("revisions") ?? Enumerable.Empty <object>()).Cast <JObject>()
             .Select(x => x.ToObject <_User>())
             .Select(x => client.ItemsCache.Update(x.id, () => new UserSummary(x)))
             .ToArray();
     Comment = data.Value <string>("comment");
 }
コード例 #8
0
 internal Star(_Star data, BacklogClient client)
     : base(data.id)
 {
     Comment = data.comment;
     Url     = data.url;
     Title   = data.title;
     Creator = client.ItemsCache.Update(data.presenter?.id, () => new User(data.presenter, client));
     Created = data.created;
 }
コード例 #9
0
ファイル: User.cs プロジェクト: hal1932/NBacklog
 internal User(JObject data, BacklogClient client)
     : base(data.Value <int>("id"))
 {
     UserId      = data.Value <string>("userId");
     Name        = data.Value <string>("name");
     Role        = (UserRole)data.Value <int>("roleType");
     Language    = data.Value <string>("lang");
     MailAddress = data.Value <string>("mailAddress");
     _client     = client;
 }
コード例 #10
0
 internal Group(_Group data, BacklogClient client)
     : base(data.id)
 {
     Name         = data.name;
     Members      = data.members.Select(x => client.ItemsCache.Update(x.id, () => new User(x, client))).ToArray();
     DisplayOrder = data.displayOrder;
     Creator      = client.ItemsCache.Update(data.createdUser?.id, () => new User(data.createdUser, client));
     Created      = data.created;
     LastUpdater  = client.ItemsCache.Update(data.updatedUser?.id, () => new User(data.updatedUser, client));
     LastUpdated  = data.updated;
     _client      = client;
 }
コード例 #11
0
        internal Project(_Project data, BacklogClient client)
            : base(data.id)
        {
            Key                 = data.projectKey;
            Name                = data.name;
            IsChartEnabled      = data.chartEnabled;
            IsSubtaskingEnabled = data.subtaskingEnabled;
            CanProjectLeaderEditProjectLeader = data.projectLeaderCanEditProjectLeader;
            TextFormattingRule = data.textFormattingRule;
            IsArchived         = data.archived;

            Client = client;
        }
コード例 #12
0
 internal Space(_Space data, BacklogClient client)
     : base(-1)
 {
     _client            = client;
     Key                = data.spaceKey;
     Name               = data.name;
     OwnerId            = data.ownerId;
     Language           = data.lang;
     TimeZone           = data.timezone;
     ReportSendTime     = data.reportSendTime;
     TextFormattingRule = data.textFormattingRule;
     Created            = data.created;
     Updated            = data.updated;
 }
コード例 #13
0
        public static async Task SetupClient(TestContext context)
        {
            generalConfig = GeneralConfig.Instance.Value;
            var conf = new BacklogJpConfigure(generalConfig.SpaceKey);

            conf.ApiKey = generalConfig.ApiKey;
            client      = new BacklogClientFactory(conf).NewClient();
            var users = await client.GetUsersAsync();

            projectKey = generalConfig.ProjectKey;
            var project = await client.GetProjectAsync(projectKey);

            projectId = project.Id;

            ownUser = await client.GetMyselfAsync();
        }
コード例 #14
0
ファイル: User.cs プロジェクト: hal1932/NBacklog
        internal User(_User data, BacklogClient client)
            : base(data.id)
        {
            UserId      = data.userId;
            Name        = data.name;
            Role        = (UserRole)data.roleType;
            Language    = data.lang;
            MailAddress = data.mailAddress;

            if (data.nulabAccount != null)
            {
                NulabAccount = new NulabAccount(data.nulabAccount);
            }

            _client = client;
        }
コード例 #15
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);
        }
コード例 #16
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();
        }
コード例 #17
0
 internal Group(int id, string name, BacklogClient client)
     : base(id)
 {
     Name = name;
 }
コード例 #18
0
        internal Activity(_Activity data, BacklogClient client)
            : base(data.id)
        {
            Project = client.ItemsCache.Update(data.project.id, () => new Project(data.project, client));
            Type    = (ActivityEvent)data.type;
            Creator = client.ItemsCache.Update(data.createdUser.id, () => new User(data.createdUser, client));
            Created = data.created;

            var contentData = data.content;

            switch (Type)
            {
                #region File
            case ActivityEvent.FileAdded:
                Content = new FileActivityContent(contentData, ActivityAction.Added);
                break;

            case ActivityEvent.FileDeleted:
                Content = new FileActivityContent(contentData, ActivityAction.Deleted);
                break;

            case ActivityEvent.FileUpdated:
                Content = new FileActivityContent(contentData, ActivityAction.Updated);
                break;
                #endregion

                #region Git
            case ActivityEvent.GitPullRequestAdded:
                Content = new GitPullRequestActivityContent(contentData, Project, ActivityAction.Added);
                break;

            case ActivityEvent.GitPullRequestCommented:
                Content = new GitPullRequestActivityContent(contentData, Project, ActivityAction.Commented);
                break;

            case ActivityEvent.GitPullRequestMerged:
                Content = new GitPullRequestActivityContent(contentData, Project, ActivityAction.Merged);
                break;

            case ActivityEvent.GitPullRequestUpdated:
                Content = new GitPullRequestActivityContent(contentData, Project, ActivityAction.Updated);
                break;

            case ActivityEvent.GitPushed:
                Content = new GitPushedActivityContent(contentData, Project);
                break;

            case ActivityEvent.GitRepositoryCreated:
                Content = new GitRepositoryCreatedActivityContent(contentData, Project);
                break;
                #endregion

                #region SVN
            case ActivityEvent.SvnCommitted:
                Content = new SvnCommittedActivityContent(contentData);
                break;
                #endregion

                #region Project
            case ActivityEvent.ProjectUserAdded:
                Content = new ProjectUserActivityContent(contentData, client, ActivityAction.Added);
                break;

            case ActivityEvent.ProjectUserRemoved:
                Content = new ProjectUserActivityContent(contentData, client, ActivityAction.Removed);
                break;

            case ActivityEvent.ProjectGroupAdded:
                Content = new GroupActivityContent(contentData, client, ActivityAction.Added);
                break;

            case ActivityEvent.ProjectGroupRemoved:
                Content = new GroupActivityContent(contentData, client, ActivityAction.Removed);
                break;
                #endregion

                #region Ticket
            case ActivityEvent.NotifyAdded:
                Content = new TicketActivityContent(contentData, ActivityAction.NotifyAdded);
                break;

            case ActivityEvent.TicketCommented:
                Content = new TicketActivityContent(contentData, ActivityAction.Commented);
                break;

            case ActivityEvent.TicketCreated:
                Content = new TicketActivityContent(contentData, ActivityAction.Created);
                break;

            case ActivityEvent.TicketDeleted:
                Content = new TicketActivityContent(contentData, ActivityAction.Deleted);
                break;

            case ActivityEvent.TicketMultiUpdated:
                Content = new TicketActivityContent(contentData, ActivityAction.MultiUpdated);
                break;

            case ActivityEvent.TicketUpdated:
                Content = new TicketActivityContent(contentData, ActivityAction.Updated);
                break;
                #endregion

                #region Wiki
            case ActivityEvent.WikiCreated:
                Content = new WikiActivityContent(contentData, Project, ActivityAction.Created);
                break;

            case ActivityEvent.WikiDeleted:
                Content = new WikiActivityContent(contentData, Project, ActivityAction.Deleted);
                break;

            case ActivityEvent.WikiUpdated:
                Content = new WikiActivityContent(contentData, Project, ActivityAction.Updated);
                break;
                #endregion

                #region Milestone
            case ActivityEvent.MilestoneAdded:
                Content = new MilestoneActivityContent(contentData, ActivityAction.Added);
                break;

            case ActivityEvent.MilestoneDeleted:
                Content = new MilestoneActivityContent(contentData, ActivityAction.Deleted);
                break;

            case ActivityEvent.MilestoneUpdated:
                Content = new MilestoneActivityContent(contentData, ActivityAction.Updated);
                break;
                #endregion

            default:
                throw new ArgumentException($"invalid content type: {Type}");
            }
        }
コード例 #19
0
        internal static async Task <BacklogResponse <Star> > AddTo(object parameters, BacklogClient client)
        {
            var response = await client.GetAsync("/api/v2/stars", parameters).ConfigureAwait(false);

            return(await client.CreateResponseAsync <Star, _Star>(
                       response,
                       HttpStatusCode.NoContent,
                       data => new Star(data, client)).ConfigureAwait(false));
        }
コード例 #20
0
 internal LoginUser(_User data, BacklogClient client)
     : base(data, client)
 {
 }