{"openapi":"3.0.0","info":{"title":"API Nice'Immob - Gestion des biens immobiliers","description":"API complète pour la gestion des biens immobiliers, paiements, et notifications","version":"1.0.0","contact":{"name":"Support Nice'Immob","email":"support@nicepaygroup.com"},"license":{"name":"Propriétaire","url":"https://nicepaygroup.com"}},"servers":[{"url":"https://nicepaygroup.com/NiceImmob/Endpoints","description":"Serveur de production"},{"url":"http://localhost/NiceImmob/Endpoints","description":"Serveur de développement"}],"tags":[{"name":"Auth","description":"Authentification et gestion des comptes"},{"name":"Properties","description":"Gestion des biens immobiliers"},{"name":"Units","description":"Gestion des unités/logements"},{"name":"Payments","description":"Gestion des paiements"},{"name":"Notifications","description":"Gestion des notifications"},{"name":"Dashboard","description":"Tableau de bord"}],"components":{"securitySchemes":{"BearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"JWT"}},"schemas":{"UserRegister":{"type":"object","required":["first_name","last_name","phone","email","password"],"properties":{"first_name":{"type":"string","example":"Jean"},"last_name":{"type":"string","example":"Dupont"},"phone":{"type":"string","example":"+22501234567"},"email":{"type":"string","format":"email","example":"jean.dupont@email.com"},"password":{"type":"string","format":"password","minLength":8,"example":"MonPassword123"},"profile_photo":{"type":"string","example":"https://example.com/photo.jpg"},"account_number":{"type":"string","example":"CI123456789"},"preferred_payment_method":{"type":"string","enum":["NicePay","Wave","OM","MobileMoney","BankTransfer"]},"address":{"type":"string","example":"Abidjan, Côte d'Ivoire"}}},"UserLogin":{"type":"object","required":["email","password"],"properties":{"email":{"type":"string","format":"email","example":"jean.dupont@email.com"},"password":{"type":"string","format":"password","example":"MonPassword123"}}},"AuthResponse":{"type":"object","properties":{"message":{"type":"string"},"user_id":{"type":"integer"},"token":{"type":"string"},"user":{"type":"object","properties":{"id":{"type":"integer"},"first_name":{"type":"string"},"last_name":{"type":"string"}}}}},"ManagerRegister":{"type":"object","required":["first_name","last_name","phone","email","password"],"properties":{"first_name":{"type":"string","example":"Marc"},"last_name":{"type":"string","example":"Kouadio"},"phone":{"type":"string","example":"+22507876543"},"email":{"type":"string","format":"email","example":"marc.kouadio@email.com"},"password":{"type":"string","format":"password","minLength":8},"permissions":{"type":"object","properties":{"add_property":{"type":"boolean"},"edit_property":{"type":"boolean"},"validate_payments":{"type":"boolean"}}}}},"OTPRequest":{"type":"object","required":["email"],"properties":{"email":{"type":"string","format":"email"}}},"OTPVerify":{"type":"object","required":["email","otp_code"],"properties":{"email":{"type":"string","format":"email"},"otp_code":{"type":"string","minLength":6,"maxLength":6}}},"Property":{"type":"object","required":["name","address","property_type"],"properties":{"name":{"type":"string","example":"Immeuble Djibril"},"address":{"type":"string","example":"Riviera Abatta"},"zone":{"type":"string","example":"Riviera"},"property_type":{"type":"string","enum":["immeuble","appartement","villa","bureau","autre"],"example":"immeuble"},"total_units":{"type":"integer","minimum":0,"example":10}}},"PropertyResponse":{"allOf":[{"$ref":"#/components/schemas/Property"},{"type":"object","properties":{"id":{"type":"integer"},"owner_id":{"type":"integer"},"is_active":{"type":"boolean"},"created_at":{"type":"string","format":"date-time"},"updated_at":{"type":"string","format":"date-time"},"occupied_units":{"type":"integer"},"total_units":{"type":"integer"}}}]},"Unit":{"type":"object","required":["property_id","unit_identifier","monthly_rent","payment_due_day"],"properties":{"property_id":{"type":"integer","example":1},"unit_identifier":{"type":"string","example":"Appart 1A"},"room_count":{"type":"integer","minimum":0,"example":3},"tenant_name":{"type":"string","example":"M. Kouadio"},"tenant_phone":{"type":"string","example":"+22501020304"},"tenant_email":{"type":"string","format":"email","example":"kouadio@email.com"},"monthly_rent":{"type":"number","format":"float","minimum":0,"example":150000},"payment_due_day":{"type":"integer","minimum":1,"maximum":31,"example":5},"reminder_days":{"type":"integer","minimum":0,"example":5},"preferred_payment_method":{"type":"string","enum":["NicePay","Wave","OM","Cash","MobileMoney","BankTransfer"]},"account_number":{"type":"string","example":"CI123456789"},"mobile_money":{"type":"string","example":"+22501020304"},"early_discount_percentage":{"type":"number","format":"float","minimum":0,"maximum":100,"example":5},"early_discount_day":{"type":"integer","minimum":1,"maximum":31,"example":25},"late_penalty_percentage":{"type":"number","format":"float","minimum":0,"maximum":100,"example":10},"late_penalty_day":{"type":"integer","minimum":1,"maximum":31,"example":10},"is_occupied":{"type":"boolean","example":true}}},"UnitResponse":{"allOf":[{"$ref":"#/components/schemas/Unit"},{"type":"object","properties":{"id":{"type":"integer"},"property_name":{"type":"string"},"property_address":{"type":"string"},"created_at":{"type":"string","format":"date-time"},"updated_at":{"type":"string","format":"date-time"},"latest_payment":{"type":"object","properties":{"payment_status":{"type":"string"},"payment_date":{"type":"string","format":"date"},"amount":{"type":"number"},"due_date":{"type":"string","format":"date"}}},"payment_history":{"type":"array","items":{"$ref":"#/components/schemas/PaymentResponse"}}}}]},"Payment":{"type":"object","required":["unit_id","tenant_name","amount","payment_date","due_date"],"properties":{"unit_id":{"type":"integer","example":1},"tenant_name":{"type":"string","example":"M. Kouadio"},"amount":{"type":"number","format":"float","minimum":0,"example":150000},"payment_date":{"type":"string","format":"date","example":"2024-01-05"},"due_date":{"type":"string","format":"date","example":"2024-01-05"},"payment_method":{"type":"string","enum":["NicePay","Wave","OM","Cash","MobileMoney","BankTransfer","other"],"example":"NicePay"},"transaction_id":{"type":"string","example":"TX123456"},"notes":{"type":"string","example":"Paiement du loyer de janvier"}}},"PaymentResponse":{"allOf":[{"$ref":"#/components/schemas/Payment"},{"type":"object","properties":{"id":{"type":"integer"},"payment_status":{"type":"string","enum":["payé","en_attente","en_retard"]},"proof_image":{"type":"string"},"is_confirmed":{"type":"boolean"},"confirmed_by":{"type":"integer"},"confirmation_date":{"type":"string","format":"date-time"},"created_at":{"type":"string","format":"date-time"},"updated_at":{"type":"string","format":"date-time"},"unit_identifier":{"type":"string"},"property_name":{"type":"string"}}}]},"PaymentConfirm":{"type":"object","properties":{"confirmed":{"type":"boolean","example":true}}},"DashboardOverview":{"type":"object","properties":{"overview":{"type":"object","properties":{"total_properties":{"type":"integer"},"total_tenants":{"type":"integer"},"monthly_revenue":{"type":"number"},"late_payments":{"type":"integer"},"active_alerts":{"type":"integer"}}},"recent_payments":{"type":"array","items":{"$ref":"#/components/schemas/PaymentResponse"}},"property_distribution":{"type":"array","items":{"type":"object","properties":{"property_name":{"type":"string"},"total_units":{"type":"integer"},"occupied_units":{"type":"integer"}}}}}},"Notification":{"type":"object","properties":{"id":{"type":"integer"},"notification_type":{"type":"string","enum":["payment_reminder","late_penalty","early_discount","payment_confirmation","payment_received","report","system"]},"title":{"type":"string"},"message":{"type":"string"},"is_read":{"type":"boolean"},"is_sent":{"type":"boolean"},"created_at":{"type":"string","format":"date-time"}}},"NotificationSend":{"type":"object","required":["unit_id","title","message"],"properties":{"unit_id":{"type":"integer"},"title":{"type":"string","example":"Rappel de paiement"},"message":{"type":"string","example":"Votre loyer est dû le 5 du mois"},"notification_type":{"type":"string","enum":["payment_reminder","late_penalty","early_discount","payment_confirmation","payment_received"]}}}},"responses":{"UnauthorizedError":{"description":"Token d'authentification invalide","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string","example":"Token invalide ou expiré"}}}}}},"NotFoundError":{"description":"Ressource non trouvée","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string","example":"Ressource non trouvée"}}}}}},"ValidationError":{"description":"Erreur de validation","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string","example":"Champs requis manquants: email, password"}}}}}}}},"security":[{"BearerAuth":[]}],"paths":{"/auth/register":{"post":{"tags":["Auth"],"summary":"Inscription d'un nouveau propriétaire","description":"Crée un nouveau compte propriétaire","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/UserRegister"}}}},"responses":{"201":{"description":"Compte créé avec succès","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AuthResponse"}}}},"409":{"description":"Email déjà utilisé","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string","example":"Cet email est déjà utilisé"}}}}}}}}},"/auth/login":{"post":{"tags":["Auth"],"summary":"Connexion propriétaire","description":"Authentification d'un propriétaire existant","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/UserLogin"}}}},"responses":{"200":{"description":"Connexion réussie","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AuthResponse"}}}},"401":{"description":"Email ou mot de passe incorrect","$ref":"#/components/responses/ValidationError"}}}},"/auth/register-manager":{"post":{"tags":["Auth"],"summary":"Créer un gestionnaire","description":"Crée un compte gestionnaire lié au propriétaire","security":[{"BearerAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ManagerRegister"}}}},"responses":{"201":{"description":"Gestionnaire créé avec succès","content":{"application/json":{"schema":{"type":"object","properties":{"message":{"type":"string"},"manager_id":{"type":"integer"}}}}}},"401":{"$ref":"#/components/responses/UnauthorizedError"}}}},"/auth/send-otp":{"post":{"tags":["Auth"],"summary":"Envoyer un code OTP","description":"Envoie un code de vérification par email","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/OTPRequest"}}}},"responses":{"200":{"description":"OTP envoyé avec succès","content":{"application/json":{"schema":{"type":"object","properties":{"message":{"type":"string"},"email":{"type":"string"}}}}}}}}},"/auth/verify-otp":{"post":{"tags":["Auth"],"summary":"Vérifier le code OTP","description":"Vérifie le code OTP reçu par email","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/OTPVerify"}}}},"responses":{"200":{"description":"OTP vérifié avec succès","content":{"application/json":{"schema":{"type":"object","properties":{"message":{"type":"string"}}}}}}}}},"/properties":{"get":{"tags":["Properties"],"summary":"Liste des biens","description":"Récupère tous les biens du propriétaire","security":[{"BearerAuth":[]}],"parameters":[{"in":"query","name":"status","schema":{"type":"string","enum":["active","inactive"]},"description":"Filtrer par statut"}],"responses":{"200":{"description":"Liste des biens","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/PropertyResponse"}}}}},"401":{"$ref":"#/components/responses/UnauthorizedError"}}},"post":{"tags":["Properties"],"summary":"Créer un bien","description":"Ajoute un nouveau bien immobilier","security":[{"BearerAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Property"}}}},"responses":{"201":{"description":"Bien créé avec succès","content":{"application/json":{"schema":{"type":"object","properties":{"message":{"type":"string"},"property_id":{"type":"integer"}}}}}},"401":{"$ref":"#/components/responses/UnauthorizedError"}}}},"/properties/{id}":{"get":{"tags":["Properties"],"summary":"Détails d'un bien","description":"Récupère les détails d'un bien spécifique","security":[{"BearerAuth":[]}],"parameters":[{"in":"path","name":"id","required":true,"schema":{"type":"integer"},"description":"ID du bien"}],"responses":{"200":{"description":"Détails du bien","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PropertyResponse"}}}},"401":{"$ref":"#/components/responses/UnauthorizedError"},"404":{"$ref":"#/components/responses/NotFoundError"}}},"put":{"tags":["Properties"],"summary":"Modifier un bien","description":"Met à jour les informations d'un bien","security":[{"BearerAuth":[]}],"parameters":[{"in":"path","name":"id","required":true,"schema":{"type":"integer"},"description":"ID du bien"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Property"}}}},"responses":{"200":{"description":"Bien mis à jour avec succès","content":{"application/json":{"schema":{"type":"object","properties":{"message":{"type":"string"}}}}}},"401":{"$ref":"#/components/responses/UnauthorizedError"},"404":{"$ref":"#/components/responses/NotFoundError"}}},"delete":{"tags":["Properties"],"summary":"Supprimer un bien","description":"Supprime un bien immobilier","security":[{"BearerAuth":[]}],"parameters":[{"in":"path","name":"id","required":true,"schema":{"type":"integer"},"description":"ID du bien"}],"responses":{"200":{"description":"Bien supprimé avec succès","content":{"application/json":{"schema":{"type":"object","properties":{"message":{"type":"string"}}}}}},"401":{"$ref":"#/components/responses/UnauthorizedError"},"404":{"$ref":"#/components/responses/NotFoundError"}}}},"/units":{"get":{"tags":["Units"],"summary":"Liste des unités","description":"Récupère toutes les unités/logements du propriétaire","security":[{"BearerAuth":[]}],"parameters":[{"in":"query","name":"property_id","schema":{"type":"integer"},"description":"Filtrer par ID de propriété"},{"in":"query","name":"occupied","schema":{"type":"boolean"},"description":"Filtrer par occupation"}],"responses":{"200":{"description":"Liste des unités","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/UnitResponse"}}}}},"401":{"$ref":"#/components/responses/UnauthorizedError"}}},"post":{"tags":["Units"],"summary":"Créer une unité","description":"Ajoute une nouvelle unité/logement","security":[{"BearerAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Unit"}}}},"responses":{"201":{"description":"Unité créée avec succès","content":{"application/json":{"schema":{"type":"object","properties":{"message":{"type":"string"},"unit_id":{"type":"integer"}}}}}},"401":{"$ref":"#/components/responses/UnauthorizedError"}}}},"/units/{id}":{"get":{"tags":["Units"],"summary":"Détails d'une unité","description":"Récupère les détails d'une unité spécifique avec historique des paiements","security":[{"BearerAuth":[]}],"parameters":[{"in":"path","name":"id","required":true,"schema":{"type":"integer"},"description":"ID de l'unité"}],"responses":{"200":{"description":"Détails de l'unité","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UnitResponse"}}}},"401":{"$ref":"#/components/responses/UnauthorizedError"},"404":{"$ref":"#/components/responses/NotFoundError"}}},"put":{"tags":["Units"],"summary":"Modifier une unité","description":"Met à jour les informations d'une unité","security":[{"BearerAuth":[]}],"parameters":[{"in":"path","name":"id","required":true,"schema":{"type":"integer"},"description":"ID de l'unité"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Unit"}}}},"responses":{"200":{"description":"Unité mise à jour avec succès","content":{"application/json":{"schema":{"type":"object","properties":{"message":{"type":"string"}}}}}},"401":{"$ref":"#/components/responses/UnauthorizedError"},"404":{"$ref":"#/components/responses/NotFoundError"}}},"delete":{"tags":["Units"],"summary":"Supprimer une unité","description":"Supprime une unité/logement","security":[{"BearerAuth":[]}],"parameters":[{"in":"path","name":"id","required":true,"schema":{"type":"integer"},"description":"ID de l'unité"}],"responses":{"200":{"description":"Unité supprimée avec succès","content":{"application/json":{"schema":{"type":"object","properties":{"message":{"type":"string"}}}}}},"401":{"$ref":"#/components/responses/UnauthorizedError"},"404":{"$ref":"#/components/responses/NotFoundError"}}}},"/payments":{"get":{"tags":["Payments"],"summary":"Liste des paiements","description":"Récupère tous les paiements du propriétaire avec filtres","security":[{"BearerAuth":[]}],"parameters":[{"in":"query","name":"status","schema":{"type":"string","enum":["payé","en_attente","en_retard"]},"description":"Filtrer par statut"},{"in":"query","name":"unit_id","schema":{"type":"integer"},"description":"Filtrer par unité"},{"in":"query","name":"date_from","schema":{"type":"string","format":"date"},"description":"Date de début"},{"in":"query","name":"date_to","schema":{"type":"string","format":"date"},"description":"Date de fin"}],"responses":{"200":{"description":"Liste des paiements","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/PaymentResponse"}}}}},"401":{"$ref":"#/components/responses/UnauthorizedError"}}},"post":{"tags":["Payments"],"summary":"Enregistrer un paiement","description":"Enregistre un nouveau paiement avec preuve (photo)","security":[{"BearerAuth":[]}],"requestBody":{"required":true,"content":{"multipart/form-data":{"schema":{"type":"object","required":["unit_id","tenant_name","amount","payment_date","due_date"],"properties":{"unit_id":{"type":"integer"},"tenant_name":{"type":"string"},"amount":{"type":"number"},"payment_date":{"type":"string","format":"date"},"due_date":{"type":"string","format":"date"},"payment_method":{"type":"string","enum":["NicePay","Wave","OM","Cash","MobileMoney","BankTransfer","other"]},"transaction_id":{"type":"string"},"proof_image":{"type":"string","format":"binary"},"notes":{"type":"string"}}}}}},"responses":{"201":{"description":"Paiement enregistré avec succès","content":{"application/json":{"schema":{"type":"object","properties":{"message":{"type":"string"},"payment_id":{"type":"integer"},"status":{"type":"string"}}}}}},"401":{"$ref":"#/components/responses/UnauthorizedError"}}}},"/payments/{id}/confirm":{"put":{"tags":["Payments"],"summary":"Confirmer un paiement","description":"Confirme un paiement (pour le propriétaire ou gestionnaire)","security":[{"BearerAuth":[]}],"parameters":[{"in":"path","name":"id","required":true,"schema":{"type":"integer"},"description":"ID du paiement"}],"responses":{"200":{"description":"Paiement confirmé avec succès","content":{"application/json":{"schema":{"type":"object","properties":{"message":{"type":"string"}}}}}},"401":{"$ref":"#/components/responses/UnauthorizedError"},"404":{"$ref":"#/components/responses/NotFoundError"}}}},"/dashboard":{"get":{"tags":["Dashboard"],"summary":"Tableau de bord","description":"Récupère les statistiques et données du tableau de bord","security":[{"BearerAuth":[]}],"responses":{"200":{"description":"Données du tableau de bord","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DashboardOverview"}}}},"401":{"$ref":"#/components/responses/UnauthorizedError"}}}},"/dashboard/summary":{"get":{"tags":["Dashboard"],"summary":"Résumé mensuel","description":"Récupère le résumé des paiements par mois","security":[{"BearerAuth":[]}],"parameters":[{"in":"query","name":"month","schema":{"type":"integer","minimum":1,"maximum":12},"description":"Mois (1-12)"},{"in":"query","name":"year","schema":{"type":"integer"},"description":"Année"}],"responses":{"200":{"description":"Résumé mensuel","content":{"application/json":{"schema":{"type":"object","properties":{"period":{"type":"object","properties":{"month":{"type":"integer"},"year":{"type":"integer"}}},"property_revenue":{"type":"array","items":{"type":"object","properties":{"property_name":{"type":"string"},"total_revenue":{"type":"number"},"payment_count":{"type":"integer"},"late_payments":{"type":"integer"}}}},"payment_statistics":{"type":"object","properties":{"total_payments":{"type":"integer"},"paid_count":{"type":"integer"},"pending_count":{"type":"integer"},"late_count":{"type":"integer"},"total_amount":{"type":"number"},"average_amount":{"type":"number"}}}}}}}},"401":{"$ref":"#/components/responses/UnauthorizedError"}}}},"/notifications":{"get":{"tags":["Notifications"],"summary":"Liste des notifications","description":"Récupère toutes les notifications du propriétaire","security":[{"BearerAuth":[]}],"parameters":[{"in":"query","name":"unread","schema":{"type":"boolean"},"description":"Filtrer les notifications non lues"},{"in":"query","name":"limit","schema":{"type":"integer","minimum":1,"maximum":100},"description":"Nombre de résultats par page"},{"in":"query","name":"offset","schema":{"type":"integer","minimum":0},"description":"Offset pour la pagination"}],"responses":{"200":{"description":"Liste des notifications","content":{"application/json":{"schema":{"type":"object","properties":{"notifications":{"type":"array","items":{"$ref":"#/components/schemas/Notification"}},"unread_count":{"type":"integer"},"total":{"type":"integer"}}}}}},"401":{"$ref":"#/components/responses/UnauthorizedError"}}},"post":{"tags":["Notifications"],"summary":"Envoyer une notification","description":"Envoie une notification à un locataire","security":[{"BearerAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/NotificationSend"}}}},"responses":{"200":{"description":"Notification envoyée avec succès","content":{"application/json":{"schema":{"type":"object","properties":{"message":{"type":"string"},"notification_id":{"type":"integer"}}}}}},"401":{"$ref":"#/components/responses/UnauthorizedError"},"404":{"$ref":"#/components/responses/NotFoundError"}}}},"/notifications/{id}/read":{"put":{"tags":["Notifications"],"summary":"Marquer une notification comme lue","description":"Marque une notification spécifique comme lue","security":[{"BearerAuth":[]}],"parameters":[{"in":"path","name":"id","required":true,"schema":{"type":"integer"},"description":"ID de la notification"}],"responses":{"200":{"description":"Notification marquée comme lue","content":{"application/json":{"schema":{"type":"object","properties":{"message":{"type":"string"}}}}}},"401":{"$ref":"#/components/responses/UnauthorizedError"},"404":{"$ref":"#/components/responses/NotFoundError"}}}},"/notifications/read-all":{"put":{"tags":["Notifications"],"summary":"Marquer toutes les notifications comme lues","description":"Marque toutes les notifications du propriétaire comme lues","security":[{"BearerAuth":[]}],"responses":{"200":{"description":"Toutes les notifications marquées comme lues","content":{"application/json":{"schema":{"type":"object","properties":{"message":{"type":"string"}}}}}},"401":{"$ref":"#/components/responses/UnauthorizedError"}}}}}}