-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from wiaio/development
Tested against live endpoint
- Loading branch information
Showing
49 changed files
with
2,007 additions
and
244 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,13 @@ | ||
language: java | ||
|
||
jdk: | ||
- openjdk6 | ||
- openjdk7 | ||
- oraclejdk7 | ||
- oraclejdk8 | ||
|
||
- openjdk6 | ||
- openjdk7 | ||
- oraclejdk7 | ||
- oraclejdk8 | ||
install: mvn install -Dgpg.skip=true -DskipTests | ||
|
||
notifications: | ||
email: | ||
on_success: never | ||
|
||
slack: | ||
secure: LOJ5Om++3aQqHzKmEUeZL4TNvBlZ/v8MvSMcq7npfCV9hSb3IvmoNhBhAR9xYvNjEQb/okCMLLtxQe2m/QNMH84EM6wxq0+suZedwMY10zRkNV90d/nfHQPgZFvJJuD3Wm3kr0JB45lt8ClxN2njFYf7JDhGeyu8XeXti+9QZixrhhJfuxoZEmgUXLCfKMVUgvM4kfAduV2wvedXHx5RIz1dMrOK0JPUsbzPQZwt6Pb1hCPcVuhlOgo/F4Rer0jkdJ3tXrK5Xki2rRtax0LLqHgh+JFB+IpJovMPIMoAJ5/tZDMigQLqQvOWcS2zBXSv+mENXj7ZUknrna4aVQ8DGnUjk6bPPUjdRZIWGQNqI1LMUsf/SPB3OWUol2VaApdGH93D5L9BGN9mA3fH+4LijFs4ttbKt9DBMUlug6WOr7teuYlnq0v2O9XJpUh+vpeQCerho2j9fLGyoEj31S89SF/v/PsJtuVkETR8eu2qMJK5T3FL7jzqaYIXQFemtaOqqfsqm+Ju+tKIZN9aCsOAcnORggnMTebe5AzYfxkN4F0O746/nFLFDNeu6fNUYx2cXRDFB1pADYBZygbQ0yfDRq80W9CYuSPzqbbcvy1EJoRysc5lORFvK0xBqiOPR253WIP6hoRcBqLdK/k9tqyUAcMASJqpSJMk4yGmzCp0tiU= | ||
sudo: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
package io.wia; | ||
|
||
import io.wia.exception.APIConnectionException; | ||
import io.wia.exception.APIException; | ||
import io.wia.exception.AuthenticationException; | ||
import io.wia.exception.InvalidRequestException; | ||
import io.wia.model.Whoami; | ||
import org.apache.log4j.LogManager; | ||
import org.apache.log4j.Logger; | ||
import org.eclipse.paho.client.mqttv3.MqttException; | ||
|
||
public abstract class Wia { | ||
private static Logger logger = LogManager.getLogger(Wia.class); | ||
|
||
public static final String LIVE_REST_API_BASE = "https://api.wia.io"; | ||
public static final String LIVE_STREAM_API_ENDPOINT = "tcp://api.wia.io:1883"; | ||
|
||
public static final String VERSION = "0.1.0"; | ||
public static volatile String apiVersion; | ||
|
||
private static volatile String secretKey; | ||
|
||
private static volatile Whoami clientInfo; | ||
|
||
private static volatile String restApiBase = LIVE_REST_API_BASE; | ||
private static volatile String streamApiEndpoint = LIVE_STREAM_API_ENDPOINT; | ||
|
||
public static void overrideRestApiBase(final String overriddenRestApiBase) { | ||
restApiBase = overriddenRestApiBase; | ||
} | ||
|
||
public static String getRestApiBase() { | ||
return restApiBase; | ||
} | ||
|
||
public static void overrideStreamApiEndpoint(final String overriddenStreamApiEndpoint) { | ||
streamApiEndpoint = overriddenStreamApiEndpoint; | ||
} | ||
|
||
public static String getStreamApiEndpoint() { | ||
return streamApiEndpoint; | ||
} | ||
|
||
public static void connectToStream() throws MqttException { | ||
if (!WiaStreamClient.getInstance().isConnected()) { | ||
WiaStreamClient.getInstance().connect(); | ||
} | ||
} | ||
|
||
public static void disconnectFromStream() throws MqttException { | ||
WiaStreamClient.getInstance().disconnect(); | ||
} | ||
|
||
public static boolean isConnectedToStream() { | ||
return WiaStreamClient.getInstance().isConnected(); | ||
} | ||
|
||
public static void setSecretKey(String s) { | ||
secretKey = s; | ||
|
||
try { | ||
clientInfo = Whoami.retrieve(); | ||
} catch (AuthenticationException e) { | ||
e.printStackTrace(); | ||
} catch (InvalidRequestException e) { | ||
e.printStackTrace(); | ||
} catch (APIConnectionException e) { | ||
e.printStackTrace(); | ||
} catch (APIException e) { | ||
e.printStackTrace(); | ||
} | ||
} | ||
|
||
public static String getSecretKey() { | ||
return secretKey; | ||
} | ||
|
||
public static Whoami getClientInfo() { | ||
return clientInfo; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package io.wia; | ||
|
||
public class WiaClient { | ||
private static WiaClient instance = null; | ||
|
||
protected WiaClient() { | ||
|
||
} | ||
|
||
public static WiaClient getInstance() { | ||
if(instance == null) { | ||
instance = new WiaClient(); | ||
} | ||
return instance; | ||
} | ||
|
||
public void overrideRestApiBase(final String overriddenRestApiBase) { | ||
Wia.overrideRestApiBase(overriddenRestApiBase); | ||
} | ||
|
||
public void overrideStreamApiEndpoint(final String overriddenStreamApiEndpoint) { | ||
Wia.overrideStreamApiEndpoint(overriddenStreamApiEndpoint); | ||
} | ||
} |
Oops, something went wrong.