Created
November 8, 2020 07:37
-
-
Save IT-Berater/68a82ab6bcc387021e01b68f8d8613f0 to your computer and use it in GitHub Desktop.
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
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