Skip to content

Commit ca411e0

Browse files
authored
fix: Add labels field to PR model (#211)
1 parent eeff7bf commit ca411e0

File tree

5 files changed

+65
-13
lines changed

5 files changed

+65
-13
lines changed

src/main/java/com/spotify/github/v3/issues/Label.java

Lines changed: 40 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
* Licensed under the Apache License, Version 2.0 (the "License");
88
* you may not use this file except in compliance with the License.
99
* You may obtain a copy of the License at
10-
*
10+
*
1111
* http://www.apache.org/licenses/LICENSE-2.0
12-
*
12+
*
1313
* Unless required by applicable law or agreed to in writing, software
1414
* distributed under the License is distributed on an "AS IS" BASIS,
1515
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -20,29 +20,57 @@
2020

2121
package com.spotify.github.v3.issues;
2222

23+
import com.fasterxml.jackson.annotation.JsonProperty;
2324
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
2425
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
2526
import com.spotify.github.GithubStyle;
27+
2628
import java.net.URI;
2729
import javax.annotation.Nullable;
30+
2831
import org.immutables.value.Value;
2932

30-
/** Issue label resource */
33+
/**
34+
* Issue label resource
35+
*/
3136
@Value.Immutable
3237
@GithubStyle
3338
@JsonSerialize(as = ImmutableLabel.class)
3439
@JsonDeserialize(as = ImmutableLabel.class)
3540
public interface Label {
3641

37-
/** URL */
38-
@Nullable
39-
URI url();
42+
/**
43+
* Id
44+
*/
45+
Long id();
46+
47+
@Nullable
48+
String nodeId();
49+
50+
/**
51+
* URL
52+
*/
53+
@Nullable
54+
URI url();
55+
56+
/**
57+
* Name
58+
*/
59+
@Nullable
60+
String name();
61+
62+
/**
63+
* Color
64+
*/
65+
@Nullable
66+
String color();
4067

41-
/** Name */
42-
@Nullable
43-
String name();
68+
@Nullable
69+
String description();
4470

45-
/** Color */
46-
@Nullable
47-
String color();
71+
/**
72+
* Default
73+
*/
74+
@JsonProperty("default")
75+
boolean isDefault();
4876
}

src/main/java/com/spotify/github/v3/prs/PullRequest.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,12 @@
2424
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
2525
import com.spotify.github.GithubStyle;
2626
import com.spotify.github.v3.User;
27+
28+
import java.util.List;
2729
import java.util.Optional;
2830
import javax.annotation.Nullable;
31+
32+
import com.spotify.github.v3.issues.Label;
2933
import org.immutables.value.Value;
3034

3135
/**
@@ -80,4 +84,7 @@ public interface PullRequest extends PullRequestItem {
8084

8185
/** Is it a draft PR? */
8286
Optional<Boolean> draft();
87+
88+
@Nullable
89+
List<Label> labels();
8390
}

src/test/java/com/spotify/github/v3/prs/PullRequestTest.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ public void testDeserializationPr() throws IOException {
4747
assertThat(pr.deletions(), is(3));
4848
assertThat(pr.changedFiles(), is(5));
4949
assertThat(pr.draft(), is(Optional.of(false)));
50+
assertThat(pr.labels().size(),is(1));
51+
assertThat(pr.labels().get(0).name(),is("bug"));
52+
assertThat(pr.labels().get(0).id(),is(42L));
53+
assertThat(pr.labels().get(0).color(),is("ff0000"));
5054
}
5155

5256
@Test

src/test/resources/com/spotify/github/v3/prs/pull_request.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,16 @@
6969
"closed_at": "2013-02-12T13:22:01Z",
7070
"due_on": "2012-10-09T23:39:01Z"
7171
},
72+
"labels": [
73+
{
74+
"id": 42,
75+
"node_id": "MDU6TGFiZWw0Mg==",
76+
"url": "https://api.github.com/repos/batterseapower/pinyin-toolkit/labels/bug",
77+
"name": "bug",
78+
"color": "ff0000",
79+
"default": true
80+
}
81+
],
7282
"locked": false,
7383
"created_at": "2011-01-26T19:01:12Z",
7484
"updated_at": "2011-01-26T19:01:12Z",

src/test/resources/com/spotify/github/v3/search/issues.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,12 @@
3232
},
3333
"labels": [
3434
{
35+
"id": 42,
36+
"node_id": "MDU6TGFiZWw0Mg==",
3537
"url": "https://api.github.com/repos/batterseapower/pinyin-toolkit/labels/bug",
3638
"name": "bug",
37-
"color": "ff0000"
39+
"color": "ff0000",
40+
"default": true
3841
}
3942
],
4043
"state": "open",

0 commit comments

Comments
 (0)