/*
 * SPDX-License-Identifier: GPL-3.0-or-later
 */
package com.runicgateway.app.data.api

import com.runicgateway.app.data.api.dto.NotificationStreamsDto
import com.runicgateway.app.data.api.dto.NotificationSubscriptionsDto
import com.runicgateway.app.data.api.dto.PushDeviceDto
import com.runicgateway.app.data.api.dto.RegisterDeviceRequest
import retrofit2.http.Body
import retrofit2.http.DELETE
import retrofit2.http.GET
import retrofit2.http.POST
import retrofit2.http.PUT
import retrofit2.http.Path

/**
 * The opt-in push surface under `/auth/me` (PLAN.md §11, M7 Part 2): device
 * (endpoint) registration and per-user stream subscriptions. Every call rides the
 * main client, so [com.runicgateway.app.core.net.AuthInterceptor] attaches the
 * bearer and [com.runicgateway.app.core.net.TokenAuthenticator] refreshes on 401 —
 * registration only ever succeeds while signed in.
 */
interface NotificationsApi {

    @POST("api/v1/auth/me/devices")
    suspend fun registerDevice(@Body body: RegisterDeviceRequest): PushDeviceDto

    @GET("api/v1/auth/me/devices")
    suspend fun listDevices(): List<PushDeviceDto>

    @DELETE("api/v1/auth/me/devices/{id}")
    suspend fun deleteDevice(@Path("id") id: Long): Unit

    @GET("api/v1/auth/me/notifications/streams")
    suspend fun streams(): NotificationStreamsDto

    @GET("api/v1/auth/me/notifications/subscriptions")
    suspend fun subscriptions(): NotificationSubscriptionsDto

    @PUT("api/v1/auth/me/notifications/subscriptions")
    suspend fun putSubscriptions(@Body body: NotificationSubscriptionsDto): NotificationSubscriptionsDto
}
