cubesensors-for-java

A Java library for reading data from the CubeSensors API

License

License

Categories

Categories

Java Languages
GroupId

GroupId

com.w3asel
ArtifactId

ArtifactId

cubesensors-for-java
Last Version

Last Version

0.9.3
Release Date

Release Date

Type

Type

jar
Description

Description

cubesensors-for-java
A Java library for reading data from the CubeSensors API
Project URL

Project URL

https://github.com/1337joe/cubesensors-for-java
Source Code Management

Source Code Management

https://github.com/1337joe/cubesensors-for-java

Download cubesensors-for-java

How to add to project

<!-- https://jarcasting.com/artifacts/com.w3asel/cubesensors-for-java/ -->
<dependency>
    <groupId>com.w3asel</groupId>
    <artifactId>cubesensors-for-java</artifactId>
    <version>0.9.3</version>
</dependency>
// https://jarcasting.com/artifacts/com.w3asel/cubesensors-for-java/
implementation 'com.w3asel:cubesensors-for-java:0.9.3'
// https://jarcasting.com/artifacts/com.w3asel/cubesensors-for-java/
implementation ("com.w3asel:cubesensors-for-java:0.9.3")
'com.w3asel:cubesensors-for-java:jar:0.9.3'
<dependency org="com.w3asel" name="cubesensors-for-java" rev="0.9.3">
  <artifact name="cubesensors-for-java" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.w3asel', module='cubesensors-for-java', version='0.9.3')
)
libraryDependencies += "com.w3asel" % "cubesensors-for-java" % "0.9.3"
[com.w3asel/cubesensors-for-java "0.9.3"]

Dependencies

compile (4)

Group / Artifact Type Version
org.scribe : scribe jar 1.3.5
com.fasterxml.jackson.core : jackson-core jar 2.3.2
com.fasterxml.jackson.core : jackson-databind jar 2.3.2
org.slf4j : slf4j-api jar 1.7.7

runtime (1)

Group / Artifact Type Version
org.slf4j : slf4j-log4j12 Optional jar 1.7.7

test (1)

Group / Artifact Type Version
junit : junit jar 4.12

Project Modules

There are no modules declared in this project.

#Cubesensors for Java

A Java library for reading data from the CubeSensors API

##Authorization Usage

This library extends Scribe to use the CubeSensors OAuth authentication. That means that creating an OAuthService object is as simple as putting your app API key in cubesensors.properties and calling:

OAuthService service = new ServiceBuilder()
		.provider(CubeSensorsAuthApi.class)
		.apiKey(CubeSensorsProperties.getAppKey())
		.apiSecret(CubeSensorsProperties.getAppSecret())
		.signatureType(SignatureType.QueryString)
		.build();

That defaults to using 'oob' for the callback, meaning the api will provide the user with the verifier string in the web browser instead of calling your app to pass it directly. Specifying a callback should be as simple as adding .callback("your url here") to the builder.

For usage examples and instructions on getting an access token see TestAuth.java.

##API Usage

Once you've got an access token you can start querying the API for data. See TestApi.java for full examples, but all it takes to get the current state of a cube is:

// create the API instance for a given accessToken
CubeSensorsApiV1 api = new CubeSensorsApiV1(accessToken);
// get the list of devices
List<Device> devices = api.getDevices();
// print current state information for the first device
System.out.print(api.getCurrent(devices.get(0).getUid()));

##Maven dependency tag (available on Maven Central)

<dependency>
  <groupId>com.w3asel</groupId>
  <artifactId>cubesensors-for-java</artifactId>
  <version>0.9.3</version>
</dependency>

##Notes

The CubeSensors API is still in development. As far as I can tell everything in this library currently works, but updates may be needed if the API itself changes.

I'm using the Java 8 java.time package for dates/times. If there's demand it shoudn't be hard to put together a branch that either uses the old time classes or Joda-Time.

Versions

Version
0.9.3
0.9.2