B4A=true
Group=Default Group
ModulesStructureVersion=1
Type=Static Code
Version=9.9
@EndOfDesignText@
' APIModule - Utility for communicating with the PHP Backend
Sub Process_Globals
    Public ServerURL As String = "http://bustrack.merosee.com/api" ' Default for Emulator
    ' For real device, replace with your local IP like "http://192.168.1.100/bustrack/api"
End Sub

' Helper to set Auth header
Sub SetAuthHeader(job As HttpJob, token As String)
    If token <> "" Then
        job.GetRequest.SetHeader("Authorization", "Bearer " & token)
    End If
    job.GetRequest.SetHeader("Content-Type", "application/json")
End Sub

Sub GetToken As String
    If File.Exists(File.DirInternal, "token.txt") Then
        Return File.ReadString(File.DirInternal, "token.txt")
    End If
    Return ""
End Sub

Sub SaveToken(token As String)
    File.WriteString(File.DirInternal, "token.txt", token)
End Sub

Sub ClearToken
    If File.Exists(File.DirInternal, "token.txt") Then File.Delete(File.DirInternal, "token.txt")
End Sub
