package com.merosee.bustrack.driver;


import anywheresoftware.b4a.BA;
import anywheresoftware.b4a.BALayout;
import anywheresoftware.b4a.debug.*;

public class apimodule {
private static apimodule mostCurrent = new apimodule();
public static Object getObject() {
    throw new RuntimeException("Code module does not support this method.");
}
 public anywheresoftware.b4a.keywords.Common __c = null;
public static String _serverurl = "";
public com.merosee.bustrack.driver.main _main = null;
public com.merosee.bustrack.driver.starter _starter = null;
public com.merosee.bustrack.driver.trackingservice _trackingservice = null;
public com.merosee.bustrack.driver.routeselectionfunctions _routeselectionfunctions = null;
public com.merosee.bustrack.driver.httputils2service _httputils2service = null;
public static String  _cleartoken(anywheresoftware.b4a.BA _ba) throws Exception{
 //BA.debugLineNum = 26;BA.debugLine="Sub ClearToken";
 //BA.debugLineNum = 27;BA.debugLine="If File.Exists(File.DirInternal, \"token.txt\")";
if (anywheresoftware.b4a.keywords.Common.File.Exists(anywheresoftware.b4a.keywords.Common.File.getDirInternal(),"token.txt")) { 
anywheresoftware.b4a.keywords.Common.File.Delete(anywheresoftware.b4a.keywords.Common.File.getDirInternal(),"token.txt");};
 //BA.debugLineNum = 28;BA.debugLine="End Sub";
return "";
}
public static String  _gettoken(anywheresoftware.b4a.BA _ba) throws Exception{
 //BA.debugLineNum = 15;BA.debugLine="Sub GetToken As String";
 //BA.debugLineNum = 16;BA.debugLine="If File.Exists(File.DirInternal, \"token.txt\")";
if (anywheresoftware.b4a.keywords.Common.File.Exists(anywheresoftware.b4a.keywords.Common.File.getDirInternal(),"token.txt")) { 
 //BA.debugLineNum = 17;BA.debugLine="Return File.ReadString(File.DirInternal, \"";
if (true) return anywheresoftware.b4a.keywords.Common.File.ReadString(anywheresoftware.b4a.keywords.Common.File.getDirInternal(),"token.txt");
 };
 //BA.debugLineNum = 19;BA.debugLine="Return \"\"";
if (true) return "";
 //BA.debugLineNum = 20;BA.debugLine="End Sub";
return "";
}
public static String  _process_globals() throws Exception{
 //BA.debugLineNum = 2;BA.debugLine="Sub Process_Globals";
 //BA.debugLineNum = 3;BA.debugLine="Public ServerURL As String = \"https://bustrack";
_serverurl = "https://bustrack.merosee.com/api";
 //BA.debugLineNum = 5;BA.debugLine="End Sub";
return "";
}
public static String  _savetoken(anywheresoftware.b4a.BA _ba,String _token) throws Exception{
 //BA.debugLineNum = 22;BA.debugLine="Sub SaveToken(token As String)";
 //BA.debugLineNum = 23;BA.debugLine="File.WriteString(File.DirInternal, \"token.txt\"";
anywheresoftware.b4a.keywords.Common.File.WriteString(anywheresoftware.b4a.keywords.Common.File.getDirInternal(),"token.txt",_token);
 //BA.debugLineNum = 24;BA.debugLine="End Sub";
return "";
}
public static String  _setauthheader(anywheresoftware.b4a.BA _ba,com.merosee.bustrack.driver.httpjob _job,String _token) throws Exception{
 //BA.debugLineNum = 8;BA.debugLine="Sub SetAuthHeader(job As HttpJob, token As String)";
 //BA.debugLineNum = 9;BA.debugLine="If token <> \"\" Then";
if ((_token).equals("") == false) { 
 //BA.debugLineNum = 10;BA.debugLine="job.GetRequest.SetHeader(\"Authorization\",";
_job._getrequest /*anywheresoftware.b4h.okhttp.OkHttpClientWrapper.OkHttpRequest*/ ().SetHeader("Authorization","Bearer "+_token);
 };
 //BA.debugLineNum = 12;BA.debugLine="job.GetRequest.SetHeader(\"Content-Type\", \"appl";
_job._getrequest /*anywheresoftware.b4h.okhttp.OkHttpClientWrapper.OkHttpRequest*/ ().SetHeader("Content-Type","application/json");
 //BA.debugLineNum = 13;BA.debugLine="End Sub";
return "";
}
}
