-
Notifications
You must be signed in to change notification settings - Fork 485
added some apis #204
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
added some apis #204
Conversation
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.47</version>
</dependency>
2.added a method to get languages used in a project.
merge from source
|
Added a pom dependency: fastjson and added a method to get languages used in a project. |
gmessner
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your contribution. I do have a few requested changes:
- Remove the dependency on com.alibaba.fastjson
- Change
getLanguages()as described below. - This library follows a convention where there is a one-to-one mapping of GitLab API documentation page to an API Class, so the markdown methods belong in a new class to be called
MarkdownApiand the license template methods belong in a class calledLicensesApi
You'll need to add the 2 classes and add them to GitLabApi.java
|
|
||
| package org.gitlab4j.api; | ||
|
|
||
| import com.alibaba.fastjson.JSONObject; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no need to introduce this to the project. See my comments on getLangauge() below.
| Response response = post(expectedStatus, (Form) null, "projects", getProjectIdOrPath(projectIdOrPath), "unstar"); | ||
| return (response.readEntity(Project.class)); | ||
| } | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to introduce a new type for this, please re-implement getProjectLanguage(Integer projectId) as follows:
/**
* Get languages used in a project with percentage value.
*
* Get /projects/:id/languages
*
* @param projectId the ID of the project
* @return a Map instance with the language as the key and the percentage as the value
* @throws GitLabApiException if any exception occurs
* @since GitLab 10.8
*/
public Map<String, Float> getProjectLanguages(Integer projectId) throws GitLabApiException {
if (projectId == null) {
throw new RuntimeException("projectId cannot be null");
}
Response response = get(Response.Status.OK, null, "projects", projectId, "languages");
return (response.readEntity(new GenericType<Map<String, Float>>() { }));
}
pom.xml
Outdated
| <groupId>com.alibaba</groupId> | ||
| <artifactId>fastjson</artifactId> | ||
| <version>1.2.47</version> | ||
| </dependency> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to introduce this new library, see my comments in ProjectApi.java
|
@gmessner Thank you very much for your suggestion. I will submit it again after the revision. |
Added 2 classes and moved the corresponding methods to. Added 2 members LicensesApi & MarkdownApi to GitLabApi.java. Repaired getProjectLanguage(Integer projectId) as requested.
|
I have completed the changes.if there are any questions please tell me, I'll fix them. |
|
Great job and making the requested changes. |
|
@zhengrenjie |
No description provided.