Hotspot Kullanıcıları
Hotspot kullanıcı yönetimi API endpoint'leri. Bu endpoint'ler ile hotspot kullanıcılarını oluşturabilir, listeleyebilir, güncelleyebilir ve silebilirsiniz.
Endpoint'ler
Kullanıcıları Listele
Hotspot kullanıcılarını listeler. Filtreleme ve sayfalama desteği vardır.
GET /api/v1/hotspot-users
Query Parametreleri
| Parametre | Tip | Zorunlu | Açıklama |
|---|---|---|---|
venueId | string | Evet | Venue ID (query parametresi olarak veya token'dan alınır) |
status | string | Hayır | Kullanıcı durumu filtresi (active, blocked, expired) |
macAddress | string | Hayır | MAC adresi filtresi |
page | integer | Hayır | Sayfa numarası (varsayılan: 1) |
limit | integer | Hayır | Sayfa başına kayıt sayısı (varsayılan: 20, maksimum: 100) |
Örnek İstek
curl -X GET "http://localhost:3000/api/v1/hotspot-users?venueId=507f1f77bcf86cd799439011&status=active&page=1&limit=20" \
-H "Authorization: Bearer your-api-token-here"
Örnek Yanıt
{
"success": true,
"data": [
{
"_id": "507f1f77bcf86cd799439011",
"name": "John Doe",
"username": "johndoe",
"email": "john@example.com",
"phone": "+905551234567",
"loginMethod": "username_password",
"venueIds": ["507f1f77bcf86cd799439011"],
"status": "active",
"expiresAt": "2024-12-31T23:59:59Z",
"devices": [],
"metadata": {},
"createdAt": "2024-01-01T00:00:00Z",
"updatedAt": "2024-01-01T00:00:00Z"
}
],
"pagination": {
"page": 1,
"limit": 20,
"total": 100,
"pages": 5
}
}
Kullanıcı Detayı Getir
Belirtilen ID'ye sahip hotspot kullanıcısının detaylarını getirir.
GET /api/v1/hotspot-users/:id
Path Parametreleri
| Parametre | Tip | Zorunlu | Açıklama |
|---|---|---|---|
id | string | Evet | Kullanıcı ID |
Query Parametreleri
| Parametre | Tip | Zorunlu | Açıklama |
|---|---|---|---|
venueId | string | Hayır | Venue ID (opsiyonel) |
Örnek İstek
curl -X GET "http://localhost:3000/api/v1/hotspot-users/507f1f77bcf86cd799439011" \
-H "Authorization: Bearer your-api-token-here"
Örnek Yanıt
{
"success": true,
"data": {
"_id": "507f1f77bcf86cd799439011",
"name": "John Doe",
"username": "johndoe",
"email": "john@example.com",
"phone": "+905551234567",
"loginMethod": "username_password",
"venueIds": ["507f1f77bcf86cd799439011"],
"status": "active",
"expiresAt": "2024-12-31T23:59:59Z",
"devices": [
{
"macAddress": "AA:BB:CC:DD:EE:FF",
"name": "iPhone 13",
"status": "active",
"firstSeenAt": "2024-01-01T00:00:00Z",
"lastSeenAt": "2024-01-01T00:00:00Z"
}
],
"metadata": {},
"createdAt": "2024-01-01T00:00:00Z",
"updatedAt": "2024-01-01T00:00:00Z"
}
}
Yeni Kullanıcı Oluştur
Yeni bir hotspot kullanıcısı oluşturur.
POST /api/v1/hotspot-users
Request Body
| Alan | Tip | Zorunlu | Açıklama |
|---|---|---|---|
name | string | Evet | Kullanıcı adı |
loginMethod | string | Evet | Giriş yöntemi (username_password, guest) |
venueIds | array | Evet | Venue ID'leri dizisi |
username | string | Koşullu | Kullanıcı adı (loginMethod = username_password ise zorunlu) |
password | string | Koşullu | Şifre (loginMethod = username_password ise zorunlu) |
email | string | Hayır | E-posta adresi |
phone | string | Hayır | Telefon numarası |
macAddress | string | Hayır | MAC adresi |
expiresAt | string (ISO 8601) | Hayır | Son kullanma tarihi (sadece username_password için) |
metadata | object | Hayır | Ek metadata |
Önemli Notlar:
loginMethodusername_passwordiseusernamevepasswordzorunludur- Aynı venue için aynı username/email/phone kullanılamaz (expired kullanıcılar hariç)
- Token'a bağlı venue varsa, sadece o venue kullanılabilir
Örnek İstek
curl -X POST "http://localhost:3000/api/v1/hotspot-users" \
-H "Authorization: Bearer your-api-token-here" \
-H "Content-Type: application/json" \
-d '{
"name": "John Doe",
"loginMethod": "username_password",
"username": "johndoe",
"password": "securePassword123",
"email": "john@example.com",
"phone": "+905551234567",
"venueIds": ["507f1f77bcf86cd799439011"],
"expiresAt": "2024-12-31T23:59:59Z"
}'
Örnek Yanıt
{
"success": true,
"message": "Hotspot kullanıcısı başarıyla oluşturuldu",
"data": {
"_id": "507f1f77bcf86cd799439011",
"name": "John Doe",
"username": "johndoe",
"email": "john@example.com",
"phone": "+905551234567",
"loginMethod": "username_password",
"venueIds": ["507f1f77bcf86cd799439011"],
"status": "active",
"expiresAt": "2024-12-31T23:59:59Z",
"devices": [],
"metadata": {},
"createdAt": "2024-01-01T00:00:00Z",
"updatedAt": "2024-01-01T00:00:00Z"
}
}
Kullanıcı Güncelle
Mevcut bir hotspot kullanıcısını günceller.
PUT /api/v1/hotspot-users/:id
Path Parametreleri
| Parametre | Tip | Zorunlu | Açıklama |
|---|---|---|---|
id | string | Evet | Kullanıcı ID |
Query Parametreleri
| Parametre | Tip | Zorunlu | Açıklama |
|---|---|---|---|
venueId | string | Hayır | Venue ID (opsiyonel) |
Request Body
Tüm alanlar opsiyoneldir. Sadece güncellenmek istenen alanlar gönderilmelidir.
| Alan | Tip | Açıklama |
|---|---|---|
name | string | Kullanıcı adı |
username | string | Kullanıcı adı (username_password için) |
email | string | E-posta adresi |
phone | string | Telefon numarası |
venueIds | array | Venue ID'leri dizisi |
expiresAt | string (ISO 8601) | null | Son kullanma tarihi (null ise süresiz) |
status | string | Kullanıcı durumu (active, blocked, expired) |
metadata | object | Ek metadata |
Önemli Notlar:
- Expired (süresi dolmuş) kullanıcılar düzenlenemez
loginMethoddeğiştirilemez- Kullanıcı aktif konumdan çıkartılırsa (active -> blocked/expired), otomatik olarak unauth job oluşturulur
Örnek İstek
curl -X PUT "http://localhost:3000/api/v1/hotspot-users/507f1f77bcf86cd799439011" \
-H "Authorization: Bearer your-api-token-here" \
-H "Content-Type: application/json" \
-d '{
"name": "John Doe Updated",
"email": "john.updated@example.com",
"status": "active"
}'
Örnek Yanıt
{
"success": true,
"message": "Kullanıcı başarıyla güncellendi",
"data": {
"_id": "507f1f77bcf86cd799439011",
"name": "John Doe Updated",
"username": "johndoe",
"email": "john.updated@example.com",
"phone": "+905551234567",
"loginMethod": "username_password",
"venueIds": ["507f1f77bcf86cd799439011"],
"status": "active",
"expiresAt": "2024-12-31T23:59:59Z",
"devices": [],
"metadata": {},
"createdAt": "2024-01-01T00:00:00Z",
"updatedAt": "2024-01-01T12:00:00Z"
}
}
Kullanıcı Sil
Belirtilen ID'ye sahip hotspot kullanıcısını siler.
DELETE /api/v1/hotspot-users/:id
Path Parametreleri
| Parametre | Tip | Zorunlu | Açıklama |
|---|---|---|---|
id | string | Evet | Kullanıcı ID |
Query Parametreleri
| Parametre | Tip | Zorunlu | Açıklama |
|---|---|---|---|
venueId | string | Hayır | Venue ID (opsiyonel) |
Not: Kullanıcı silinmeden önce aktif session'lar varsa, otomatik olarak unauth job oluşturulur.
Örnek İstek
curl -X DELETE "http://localhost:3000/api/v1/hotspot-users/507f1f77bcf86cd799439011" \
-H "Authorization: Bearer your-api-token-here"
Örnek Yanıt
{
"success": true,
"message": "Kullanıcı başarıyla silindi"
}
Kullanıcı Session'larını Expire Et
Belirtilen kullanıcının aktif session'larını expire eder ve kullanıcıyı expired durumuna alır.
POST /api/v1/hotspot-users/:id/expire
Path Parametreleri
| Parametre | Tip | Zorunlu | Açıklama |
|---|---|---|---|
id | string | Evet | Kullanıcı ID |
Request Body (Opsiyonel)
| Alan | Tip | Zorunlu | Açıklama |
|---|---|---|---|
venueId | string | Hayır | Venue ID (opsiyonel, kullanıcının ilk venue'si kullanılır) |
Not: Aktif session'lar varsa, otomatik olarak unauth job oluşturulur.
Örnek İstek
curl -X POST "http://localhost:3000/api/v1/hotspot-users/507f1f77bcf86cd799439011/expire" \
-H "Authorization: Bearer your-api-token-here" \
-H "Content-Type: application/json"
Örnek Yanıt
{
"success": true,
"message": "Kullanıcı ve session'lar başarıyla expire edildi",
"data": {
"expiredSessions": 3,
"user": {
"_id": "507f1f77bcf86cd799439011",
"name": "John Doe",
"status": "expired",
...
}
}
}
Veri Modelleri
HotspotUser
{
_id: string; // Kullanıcı ID
name: string; // Kullanıcı adı
username?: string; // Kullanıcı adı (username_password için)
email?: string; // E-posta adresi
phone?: string; // Telefon numarası
loginMethod: "username_password" | "guest" | "social" | "sms";
venueIds: string[]; // Venue ID'leri dizisi
status: "active" | "blocked" | "expired";
expiresAt?: string; // Son kullanma tarihi (ISO 8601)
devices: Device[]; // Kullanıcıya bağlı cihazlar
metadata: object; // Ek metadata
createdAt: string; // Oluşturulma tarihi (ISO 8601)
updatedAt: string; // Güncellenme tarihi (ISO 8601)
}
Device
{
macAddress: string; // MAC adresi
name?: string; // Cihaz adı
status: "active" | "expired";
firstSeenAt: string; // İlk görülme tarihi (ISO 8601)
lastSeenAt: string; // Son görülme tarihi (ISO 8601)
}
Hata Durumları
400 Bad Request
Validasyon hatası veya hatalı istek:
{
"success": false,
"message": "Validation error",
"errors": [
{
"field": "username",
"message": "Kullanıcı adı gereklidir"
}
]
}
404 Not Found
Kullanıcı bulunamadı:
{
"success": false,
"message": "Kullanıcı bulunamadı"
}
Kullanım Örnekleri
JavaScript/TypeScript
// Kullanıcıları listele
const listUsers = async (venueId: string, token: string) => {
const response = await fetch(
`http://localhost:3000/api/v1/hotspot-users?venueId=${venueId}`,
{
headers: {
'Authorization': `Bearer ${token}`,
'Content-Type': 'application/json'
}
}
);
return await response.json();
};
// Yeni kullanıcı oluştur
const createUser = async (userData: any, token: string) => {
const response = await fetch(
'http://localhost:3000/api/v1/hotspot-users',
{
method: 'POST',
headers: {
'Authorization': `Bearer ${token}`,
'Content-Type': 'application/json'
},
body: JSON.stringify(userData)
}
);
return await response.json();
};
Python
import requests
# Kullanıcıları listele
def list_users(venue_id: str, token: str):
url = f"http://localhost:3000/api/v1/hotspot-users"
headers = {
'Authorization': f'Bearer {token}',
'Content-Type': 'application/json'
}
params = {'venueId': venue_id}
response = requests.get(url, headers=headers, params=params)
return response.json()
# Yeni kullanıcı oluştur
def create_user(user_data: dict, token: str):
url = "http://localhost:3000/api/v1/hotspot-users"
headers = {
'Authorization': f'Bearer {token}',
'Content-Type': 'application/json'
}
response = requests.post(url, headers=headers, json=user_data)
return response.json()
Sonraki Adımlar
- API Referansı - Tüm endpoint'lerin detaylı listesi
- Kimlik Doğrulama - Token yönetimi ve güvenlik