Skip to content

Instantly share code, notes, and snippets.

@IT-Berater
Created November 8, 2020 07:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save IT-Berater/68a82ab6bcc387021e01b68f8d8613f0 to your computer and use it in GitHub Desktop.
Save IT-Berater/68a82ab6bcc387021e01b68f8d8613f0 to your computer and use it in GitHub Desktop.
package de.wenzlaff.ubidots;
import java.util.ArrayList;
import java.util.List;
import com.ubidots.ApiClient;
import com.ubidots.DataSource;
import com.ubidots.Variable;
/**
* Java Ubitods CSV Client.
*
* @author Thomas Wenzlaff
*/
public class UbidotsClient {
private static final String API_KEY = "BBFF-"; // aus dem Menü: My Profil - Api Credential
public static void main(String[] args) {
Variable[] alleVariablen = getAlleVariablen(API_KEY);
List<CsvView> alleCsv = toCsv(alleVariablen);
for (CsvView csvView : alleCsv) {
String titel = csvView.getTitel();
System.out.println(titel);
System.out.println(csvView);
}
}
private static List<CsvView> toCsv(Variable[] alleVariablen) {
List<CsvView> alleCsv = new ArrayList<>();
for (Variable v : alleVariablen) {
CsvView csv = new CsvView();
csv.setValue(v);
alleCsv.add(csv);
}
return alleCsv;
}
private static Variable[] getAlleVariablen(String apiKey) {
ApiClient api = new ApiClient(apiKey);
DataSource[] dataSources = api.getDataSources();
Variable[] alleVariablen = dataSources[0].getVariables(); // pi-bplus
return alleVariablen;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment