All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.evotext.clever.util.Connect Maven / Gradle / Ivy

Go to download

The Clever-Java project is a Java wrapper for the Clever.com API for keeping educational applications rostered and up-to-date.

There is a newer version: 2.0.0
Show newest version
package com.evotext.clever.util;

import org.json.JSONObject;

import com.evotext.clever.requests.CleverRequestInterface;
import com.goebl.david.Webb;
import com.goebl.david.WebbException;

public class Connect {

	public static JSONObject get(CleverRequestInterface request)
	{
		String creds = "Bearer " + request.getToken();
		Webb webb = Webb.create();
		webb.setDefaultHeader(Webb.HDR_AUTHORIZATION, creds);
		JSONObject jsonObject = null;
		try 
		{
			jsonObject = webb.get(request.getUrl())
				.params(request.getParameters())
				.ensureSuccess()
				.asJsonObject()
				.getBody();
		}
		catch (WebbException we)
		{
			System.out.println(we);
			jsonObject = new JSONObject();
		}
		return jsonObject;
	}
	
	

	
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy