package JSON_Unpack;

import Credentials.UserCredentials;
import Files.WriteFile;
import HttpCall.HttpGet;
import org.json.JSONArray;

//Get a list of all devices
public class GeneralCall4AllDevices {

  public static String FetchAll(String token) throws Exception {
    String extension = "devices";
    UserCredentials userCredentials = new UserCredentials();
    WriteFile writingIntoFile = new WriteFile();

    String baseURL = userCredentials.getBaseURL();
    String homeRoot = UserCredentials.getHomeRoot();
    String devUrl = userCredentials.getDevUrl();
    HttpGet httpCall = new HttpGet();

    String fetchAll = httpCall.HttpGetCall(
      devUrl + extension + "?access_token=" + token,
      token
    );
    writingIntoFile.WriteFile(homeRoot + extension + "Output.json", fetchAll);

    return fetchAll;
  }
}
