first commit
This commit is contained in:
@@ -0,0 +1,75 @@
|
||||
package com.intaleq.flashcall
|
||||
|
||||
import com.google.gson.annotations.SerializedName
|
||||
import retrofit2.http.*
|
||||
|
||||
// --- Data Models ---
|
||||
|
||||
data class PendingTask(
|
||||
@SerializedName("task_id") val taskId: Int?,
|
||||
@SerializedName("phone") val phone: String?,
|
||||
@SerializedName("caller_id") val callerId: String?,
|
||||
@SerializedName("otp") val otp: String?,
|
||||
@SerializedName("timeout_seconds") val timeoutSeconds: Int?
|
||||
)
|
||||
|
||||
data class CallDoneRequest(
|
||||
@SerializedName("task_id") val taskId: Int,
|
||||
@SerializedName("device_id") val deviceId: String,
|
||||
@SerializedName("app_key") val appKey: String,
|
||||
@SerializedName("result") val result: String
|
||||
)
|
||||
|
||||
data class RegisterRequest(
|
||||
@SerializedName("device_id") val deviceId: String,
|
||||
@SerializedName("phone_number") val phoneNumber: String,
|
||||
@SerializedName("sim_slot") val simSlot: Int,
|
||||
@SerializedName("app_key") val appKey: String
|
||||
)
|
||||
|
||||
data class ApiResponse(
|
||||
@SerializedName("success") val success: Boolean,
|
||||
@SerializedName("message") val message: String?,
|
||||
@SerializedName("device_id") val deviceId: String?
|
||||
)
|
||||
|
||||
// --- API Interface ---
|
||||
|
||||
interface ApiService {
|
||||
|
||||
/**
|
||||
* Polling for a new flash call task
|
||||
*/
|
||||
@GET("pending-call.php")
|
||||
suspend fun pendingCall(
|
||||
@Query("device_id") deviceId: String,
|
||||
@Query("app_key") appKey: String
|
||||
): PendingTask
|
||||
|
||||
/**
|
||||
* Polling for a new SMS task
|
||||
*/
|
||||
@GET("pending-sms.php")
|
||||
suspend fun pendingSms(
|
||||
@Query("device_id") deviceId: String,
|
||||
@Query("app_key") appKey: String
|
||||
): PendingTask
|
||||
|
||||
/**
|
||||
* Reporting the result of a flash call
|
||||
*/
|
||||
@POST("call-done.php")
|
||||
suspend fun callDone(@Body request: CallDoneRequest): ApiResponse
|
||||
|
||||
/**
|
||||
* Reporting the result of an SMS
|
||||
*/
|
||||
@POST("sms-done.php")
|
||||
suspend fun smsDone(@Body request: CallDoneRequest): ApiResponse
|
||||
|
||||
/**
|
||||
* Initial registration of the device
|
||||
*/
|
||||
@POST("register-device.php")
|
||||
suspend fun registerDevice(@Body request: RegisterRequest): ApiResponse
|
||||
}
|
||||
Reference in New Issue
Block a user