interface ApiService { // Auth @POST("auth/send-otp") suspend fun sendOtp(@Body body: SendOtpRequest): ApiResponse @POST("auth/verify-otp") suspend fun verifyOtp(@Body body: VerifyOtpRequest): ApiResponse // Buses @GET("buses/search") suspend fun searchBuses( @Query("from_city_id") fromCityId: Int, @Query("to_city_id") toCityId: Int, @Query("journey_date") journeyDate: String, @Query("bus_type") busType: String? = null, @Query("sort") sort: String = "departure" ): ApiResponse // Seats @GET("seats/status") suspend fun getSeatStatus(@Query("trip_id") tripId: Int): ApiResponse @POST("seats/hold") suspend fun holdSeats(@Body body: HoldSeatRequest): ApiResponse // Bookings @POST("bookings/create") suspend fun createBooking(@Body body: CreateBookingRequest): ApiResponse @GET("bookings/list") suspend fun getBookings( @Query("page") page: Int = 1, @Query("status") status: String? = null ): ApiResponse @GET("bookings/ticket") suspend fun getTicket(@Query("booking_ref") ref: String): ApiResponse @POST("bookings/cancel") suspend fun cancelBooking(@Body body: CancelRequest): ApiResponse // Wallet @GET("wallet/balance") suspend fun getWalletBalance(): ApiResponse @GET("wallet/transactions") suspend fun getTransactions(@Query("page") page: Int = 1): ApiResponse // Tracking @GET("tracking/live-location") suspend fun getLiveLocation(@Query("trip_id") tripId: Int): ApiResponse // Notifications @GET("notifications/list") suspend fun getNotifications(): ApiResponse } // Retrofit client setup object ApiClient { private const val BASE_URL = "https://yourdomain.com/api/v1/" val retrofit: Retrofit by lazy { Retrofit.Builder() .baseUrl(BASE_URL) .client(buildOkHttp()) .addConverterFactory(GsonConverterFactory.create()) .build() } private fun buildOkHttp(): OkHttpClient { return OkHttpClient.Builder() .addInterceptor { chain -> val token = PrefsManager.getJwtToken() val req = chain.request().newBuilder() .addHeader("Authorization", "Bearer $token") .addHeader("X-Api-Version", "1.0") .addHeader("X-Device-ID", DeviceManager.getDeviceId()) .build() chain.proceed(req) } .addInterceptor(HttpLoggingInterceptor().setLevel( if (BuildConfig.DEBUG) HttpLoggingInterceptor.Level.BODY else HttpLoggingInterceptor.Level.NONE )) .connectTimeout(30, TimeUnit.SECONDS) .readTimeout(30, TimeUnit.SECONDS) .build() } val apiService: ApiService by lazy { retrofit.create(ApiService::class.java) } }