14
14
import com .github .api .v2 .services .constant .GitHubApiUrls ;
15
15
import com .github .api .v2 .services .constant .ParameterNames ;
16
16
import com .github .api .v2 .services .constant .GitHubApiUrls .GitHubApiUrlBuilder ;
17
- import com .google .gson .JsonElement ;
17
+ import com .google .gson .JsonObject ;
18
18
import com .google .gson .reflect .TypeToken ;
19
19
20
20
/**
@@ -31,19 +31,19 @@ public void addComment(String userName, String repositoryName,
31
31
String apiUrl = builder .withField (ParameterNames .USER_NAME , userName ).withField (ParameterNames .REPOSITORY_NAME , repositoryName ).withField (ParameterNames .ISSUE_NUMBER , String .valueOf (issueNumber )).buildUrl ();
32
32
Map <String , String > parameters = new HashMap <String , String >();
33
33
parameters .put (ParameterNames .COMMENT , comment );
34
- JsonElement json = unmarshall (callApiPost (apiUrl , parameters ));
34
+ JsonObject json = unmarshall (callApiPost (apiUrl , parameters ));
35
35
36
- unmarshall (new TypeToken <Comment >(){}, json .getAsJsonObject (). get ("comment" ));
36
+ unmarshall (new TypeToken <Comment >(){}, json .get ("comment" ));
37
37
}
38
38
39
39
@ Override
40
40
public List <String > addLabel (String userName , String repositoryName ,
41
41
int issueNumber , String label ) {
42
42
GitHubApiUrlBuilder builder = createGitHubApiUrlBuilder (GitHubApiUrls .IssueApiUrls .ADD_LABEL_URL );
43
43
String apiUrl = builder .withField (ParameterNames .USER_NAME , userName ).withField (ParameterNames .REPOSITORY_NAME , repositoryName ).withField (ParameterNames .LABEL , label ).withField (ParameterNames .ISSUE_NUMBER , String .valueOf (issueNumber )).buildUrl ();
44
- JsonElement json = unmarshall (callApiPost (apiUrl , EMPTY_PARAMETERS ));
44
+ JsonObject json = unmarshall (callApiPost (apiUrl , EMPTY_PARAMETERS ));
45
45
46
- return unmarshall (new TypeToken <List <String >>(){}, json .getAsJsonObject (). get ("labels" ));
46
+ return unmarshall (new TypeToken <List <String >>(){}, json .get ("labels" ));
47
47
}
48
48
49
49
@ Override
@@ -70,48 +70,48 @@ public Issue getIssue(String userName, String repositoryName,
70
70
int issueNumber ) {
71
71
GitHubApiUrlBuilder builder = createGitHubApiUrlBuilder (GitHubApiUrls .IssueApiUrls .GET_ISSUE_URL );
72
72
String apiUrl = builder .withField (ParameterNames .USER_NAME , userName ).withField (ParameterNames .REPOSITORY_NAME , repositoryName ).withField (ParameterNames .ISSUE_NUMBER , String .valueOf (issueNumber )).buildUrl ();
73
- JsonElement json = unmarshall (callApiGet (apiUrl ));
73
+ JsonObject json = unmarshall (callApiGet (apiUrl ));
74
74
75
- return unmarshall (new TypeToken <Issue >(){}, json .getAsJsonObject (). get ("issue" ));
75
+ return unmarshall (new TypeToken <Issue >(){}, json .get ("issue" ));
76
76
}
77
77
78
78
@ Override
79
79
public List <Comment > getIssueComments (String userName ,
80
80
String repositoryName , int issueNumber ) {
81
81
GitHubApiUrlBuilder builder = createGitHubApiUrlBuilder (GitHubApiUrls .IssueApiUrls .GET_ISSUE_COMMENTS_URL );
82
82
String apiUrl = builder .withField (ParameterNames .USER_NAME , userName ).withField (ParameterNames .REPOSITORY_NAME , repositoryName ).withField (ParameterNames .ISSUE_NUMBER , String .valueOf (issueNumber )).buildUrl ();
83
- JsonElement json = unmarshall (callApiGet (apiUrl ));
83
+ JsonObject json = unmarshall (callApiGet (apiUrl ));
84
84
85
- return unmarshall (new TypeToken <List <Comment >>(){}, json .getAsJsonObject (). get ("comments" ));
85
+ return unmarshall (new TypeToken <List <Comment >>(){}, json .get ("comments" ));
86
86
}
87
87
88
88
@ Override
89
89
public List <String > getIssueLabels (String userName , String repositoryName ) {
90
90
GitHubApiUrlBuilder builder = createGitHubApiUrlBuilder (GitHubApiUrls .IssueApiUrls .GET_ISSUE_LABELS_URL );
91
91
String apiUrl = builder .withField (ParameterNames .USER_NAME , userName ).withField (ParameterNames .REPOSITORY_NAME , repositoryName ).buildUrl ();
92
- JsonElement json = unmarshall (callApiGet (apiUrl ));
92
+ JsonObject json = unmarshall (callApiGet (apiUrl ));
93
93
94
- return unmarshall (new TypeToken <List <String >>(){}, json .getAsJsonObject (). get ("labels" ));
94
+ return unmarshall (new TypeToken <List <String >>(){}, json .get ("labels" ));
95
95
}
96
96
97
97
@ Override
98
98
public List <Issue > getIssues (String userName , String repositoryName ,
99
99
State state ) {
100
100
GitHubApiUrlBuilder builder = createGitHubApiUrlBuilder (GitHubApiUrls .IssueApiUrls .GET_ISSUES_URL );
101
101
String apiUrl = builder .withField (ParameterNames .USER_NAME , userName ).withField (ParameterNames .REPOSITORY_NAME , repositoryName ).withFieldEnum (ParameterNames .STATE , state ).buildUrl ();
102
- JsonElement json = unmarshall (callApiGet (apiUrl ));
102
+ JsonObject json = unmarshall (callApiGet (apiUrl ));
103
103
104
- return unmarshall (new TypeToken <List <Issue >>(){}, json .getAsJsonObject (). get ("issues" ));
104
+ return unmarshall (new TypeToken <List <Issue >>(){}, json .get ("issues" ));
105
105
}
106
106
107
107
@ Override
108
108
public List <String > removeLabel (String userName , String repositoryName ,
109
109
int issueNumber , String label ) {
110
110
GitHubApiUrlBuilder builder = createGitHubApiUrlBuilder (GitHubApiUrls .IssueApiUrls .REMOVE_LABEL_URL );
111
111
String apiUrl = builder .withField (ParameterNames .USER_NAME , userName ).withField (ParameterNames .REPOSITORY_NAME , repositoryName ).withField (ParameterNames .LABEL , label ).withField (ParameterNames .ISSUE_NUMBER , String .valueOf (issueNumber )).buildUrl ();
112
- JsonElement json = unmarshall (callApiPost (apiUrl , EMPTY_PARAMETERS ));
112
+ JsonObject json = unmarshall (callApiPost (apiUrl , EMPTY_PARAMETERS ));
113
113
114
- return unmarshall (new TypeToken <List <String >>(){}, json .getAsJsonObject (). get ("labels" ));
114
+ return unmarshall (new TypeToken <List <String >>(){}, json .get ("labels" ));
115
115
}
116
116
117
117
@ Override
@@ -127,9 +127,9 @@ public List<Issue> searchIssues(String userName, String repositoryName,
127
127
State state , String keyword ) {
128
128
GitHubApiUrlBuilder builder = createGitHubApiUrlBuilder (GitHubApiUrls .IssueApiUrls .SEARCH_ISSUES_URL );
129
129
String apiUrl = builder .withField (ParameterNames .USER_NAME , userName ).withField (ParameterNames .REPOSITORY_NAME , repositoryName ).withFieldEnum (ParameterNames .STATE , state ).withField (ParameterNames .KEYWORD , keyword ).buildUrl ();
130
- JsonElement json = unmarshall (callApiGet (apiUrl ));
130
+ JsonObject json = unmarshall (callApiGet (apiUrl ));
131
131
132
- return unmarshall (new TypeToken <List <Issue >>(){}, json .getAsJsonObject (). get ("issues" ));
132
+ return unmarshall (new TypeToken <List <Issue >>(){}, json .get ("issues" ));
133
133
}
134
134
135
135
@ Override
0 commit comments