Name: clever-java
Owner: Clever
Description: Java library for the Clever API
Created: 2017-03-17 01:45:49.0
Updated: 2017-12-16 14:31:55.0
Pushed: 2017-12-12 19:36:37.0
Homepage: null
Size: 259
Language: Java
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
Client library for the Clever API
Manually install the Clever JAR: https://github.com/Clever/clever-java/releases
rt io.swagger.client.ApiClient;
rt io.swagger.client.ApiException;
rt io.swagger.client.Configuration;
rt io.swagger.client.api.DefaultApi;
rt io.swagger.client.auth.OAuth;
rt io.swagger.client.model.*;
ic class CleverAPI {
public static void main(String[] args) {
ApiClient defaultClient = Configuration.getDefaultApiClient();
// Configure OAuth2 access token for authorization: oauth
OAuth oauth = (OAuth) defaultClient.getAuthentication("oauth");
oauth.setAccessToken("TODO: SET ME!");
DefaultApi api = new DefaultApi();
try {
StudentsResponse students = api.getStudents(10, null, null);
for (StudentResponse student : students.getData()) {
System.out.println("Student IDs: " + student.getData().getId());
}
} catch (ApiException e) {
System.err.println("Exception:");
e.printStackTrace();
}
}
Since events are polymorphic, we use the type to determine how to cast them. For example:
ic void processEvents(DefaultApi api) {
EventsResponse eventsResponse = api.getEvents(10, null, null);
for (EventResponse eventResp : eventsResponse.getData()) {
if (eventResp.getData().getType() == "students.created") {
StudentsCreated event = (StudentsCreated)eventResp.getData();
// Process the event...
}
}
Git clone swagger-codegen (https://github.com/swagger-api/swagger-codegen)
Git clone Clever's swagger-api repo (https://github.com/Clever/swagger-api)
Install Java and Maven
Are you removing some old models? Consider removing existing files from docs/
and src/
before regenerating files
Are you adding new event types? Consider override files that need to be updated in override/
Update the client version in override/pom.xml
In the root directory of the swagger repo run:
-jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate -i $PATH_TO_SWAGGER_API_REPO/v2.0-client.yml -l java -o $PATH_TO_THIS_REPO
Package the JAR
build
That will put the jar in: target/client-X.Y.Z.jar
To publish this library you need to have a ~/.m2/settings.xml
file that looks like this:
tings>
ervers>
<server>
<id>ossrh</id>
<username>clever-eng</username>
<password>SEE-1PASSWORD-FOR-TEAMS</password>
</server>
servers>
ttings>
You can get the password from 1PFT under Sonatype - Maven Repository
.
You will also need the PGP private key and passphrase for security@clever.com (ask the Security team for this!). Download the private key and set up as follows:
--import private.security.key
Then run:
release
You will need to enter the PGP passphrase 5 times during the process.
This will deploy to: https://oss.sonatype.org/content/groups/public/com/clever/client/
The jar will be synced over to the Maven central repository within the next few hours.
If you get an Inappropriate ioctl for device error
try the commands here: https://github.com/pstadler/keybase-gpg-github/pull/13/files