Clever/clever-java

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

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

Clever Java Library

Client library for the Clever API

Installation

Manually install the Clever JAR: https://github.com/Clever/clever-java/releases

Usage
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();
    }
}

Events Usage

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...
    }
}

Generating the JAR
  1. Git clone swagger-codegen (https://github.com/swagger-api/swagger-codegen)

  2. Git clone Clever's swagger-api repo (https://github.com/Clever/swagger-api)

  3. Install Java and Maven

  4. Are you removing some old models? Consider removing existing files from docs/ and src/ before regenerating files

  5. Are you adding new event types? Consider override files that need to be updated in override/

  6. Update the client version in override/pom.xml

  7. 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
    
  8. Package the JAR

 build

That will put the jar in: target/client-X.Y.Z.jar

Publishing

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


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.