use crate::{ApiResponse, error::ApiError}; use actix_web::{HttpResponse, Result, web}; use service::AppService; use session::Session; #[utoipa::path( get, path = "/api/users/me/billing", responses( (status = 200, description = "Get user billing", body = ApiResponse), (status = 401, description = "Unauthorized"), ), tag = "User" )] pub async fn user_billing( service: web::Data, session: Session, ) -> Result { let resp = service.user_billing_current(&session).await?; Ok(ApiResponse::ok(resp).to_response()) } #[utoipa::path( get, path = "/api/users/me/billing/errors", responses( (status = 200, description = "Get user billing errors", body = ApiResponse), (status = 401, description = "Unauthorized"), ), tag = "User" )] pub async fn user_billing_errors( service: web::Data, session: Session, ) -> Result { let resp = service.user_billing_errors(&session).await?; Ok(ApiResponse::ok(resp).to_response()) } #[utoipa::path( get, path = "/api/users/me/billing/history", params(("page" = Option, Query), ("per_page" = Option, Query)), responses( (status = 200, description = "Get user billing history", body = ApiResponse), (status = 401, description = "Unauthorized"), ), tag = "User" )] pub async fn user_billing_history( service: web::Data, session: Session, query: web::Query, ) -> Result { let resp = service .user_billing_history(&session, query.into_inner()) .await?; Ok(ApiResponse::ok(resp).to_response()) }