summaryrefslogtreecommitdiffstats
path: root/extensions/PhabBugz/lib/Project.pm
diff options
context:
space:
mode:
authordklawren <dklawren@users.noreply.github.com>2018-02-07 20:09:25 +0100
committerDylan William Hardison <dylan@hardison.net>2018-02-07 20:09:25 +0100
commit2b916fccae0df60b350369c6fc827c1c9ce1030e (patch)
tree6d2032532ca0e2431b92e7a274d314564dbbdf1f /extensions/PhabBugz/lib/Project.pm
parentc20774f3a3602a05596c7eea12edd6882097b4e4 (diff)
downloadbugzilla-2b916fccae0df60b350369c6fc827c1c9ce1030e.tar.gz
bugzilla-2b916fccae0df60b350369c6fc827c1c9ce1030e.tar.xz
Bug 1430259 - Update policy code in BMO PhabBugz extension to update custom policy if a private bugs groups have changed.
Diffstat (limited to 'extensions/PhabBugz/lib/Project.pm')
-rw-r--r--extensions/PhabBugz/lib/Project.pm97
1 files changed, 60 insertions, 37 deletions
diff --git a/extensions/PhabBugz/lib/Project.pm b/extensions/PhabBugz/lib/Project.pm
index 3ad9558ff..ec00b9532 100644
--- a/extensions/PhabBugz/lib/Project.pm
+++ b/extensions/PhabBugz/lib/Project.pm
@@ -18,37 +18,36 @@ use Bugzilla::Extension::PhabBugz::Util qw(
get_phab_bmo_ids
);
-#########################
-# Initialization #
-#########################
-
-sub new {
- my ($class, $params) = @_;
- my $self = $params ? _load($params) : {};
- bless($self, $class);
- return $self;
-}
-
-sub _load {
- my ($params) = @_;
-
- my $data = {
- queryKey => 'all',
- attachments => {
- projects => 1,
- reviewers => 1,
- subscribers => 1
- },
- constraints => $params
- };
-
- my $result = request('project.search', $data);
- if (exists $result->{result}{data} && @{ $result->{result}{data} }) {
- return $result->{result}->{data}->[0];
- }
-
- return $result;
-}
+use Types::Standard -all;
+use Type::Utils;
+
+my $SearchResult = Dict[
+ id => Int,
+ type => Str,
+ phid => Str,
+ fields => Dict[
+ name => Str,
+ slug => Str,
+ depth => Int,
+ milestone => Maybe[Str],
+ parent => Maybe[Str],
+ icon => Dict[ key => Str, name => Str, icon => Str ],
+ color => Dict[ key => Str, name => Str ],
+ dateCreated => Int,
+ dateModified => Int,
+ policy => Dict[ view => Str, edit => Str, join => Str ],
+ description => Maybe[Str]
+ ],
+ attachments => Dict[
+ members => Dict[
+ members => ArrayRef[
+ Dict[
+ phid => Str
+ ],
+ ],
+ ],
+ ],
+];
# {
# "data": [
@@ -90,12 +89,6 @@ sub _load {
# "phid": "PHID-USER-uif2miph2poiehjeqn5q"
# }
# ]
-# },
-# "ancestors": {
-# "ancestors": []
-# },
-# "watchers": {
-# "watchers": []
# }
# }
# }
@@ -115,6 +108,36 @@ sub _load {
# }
#########################
+# Initialization #
+#########################
+
+sub new {
+ my ($class, $params) = @_;
+ my $self = $params ? _load($params) : {};
+ $SearchResult->assert_valid($self);
+ return bless($self, $class);
+}
+
+sub _load {
+ my ($params) = @_;
+
+ my $data = {
+ queryKey => 'all',
+ attachments => {
+ members => 1
+ },
+ constraints => $params
+ };
+
+ my $result = request('project.search', $data);
+ if (exists $result->{result}{data} && @{ $result->{result}{data} }) {
+ return $result->{result}->{data}->[0];
+ }
+
+ return $result;
+}
+
+#########################
# Modification #
#########################