Ana içeriğe geç

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​

ParametreTipZorunluAçıklama
venueIdstringEvetVenue ID (query parametresi olarak veya token'dan alınır)
statusstringHayırKullanıcı durumu filtresi (active, blocked, expired)
macAddressstringHayırMAC adresi filtresi
pageintegerHayırSayfa numarası (varsayılan: 1)
limitintegerHayırSayfa 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​

ParametreTipZorunluAçıklama
idstringEvetKullanıcı ID

Query Parametreleri​

ParametreTipZorunluAçıklama
venueIdstringHayırVenue 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​

AlanTipZorunluAçıklama
namestringEvetKullanıcı adı
loginMethodstringEvetGiriş yöntemi (username_password, guest)
venueIdsarrayEvetVenue ID'leri dizisi
usernamestringKoşulluKullanıcı adı (loginMethod = username_password ise zorunlu)
passwordstringKoşulluŞifre (loginMethod = username_password ise zorunlu)
emailstringHayırE-posta adresi
phonestringHayırTelefon numarası
macAddressstringHayırMAC adresi
expiresAtstring (ISO 8601)HayırSon kullanma tarihi (sadece username_password için)
metadataobjectHayırEk metadata

Önemli Notlar:

  • loginMethod username_password ise username ve password zorunludur
  • 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​

ParametreTipZorunluAçıklama
idstringEvetKullanıcı ID

Query Parametreleri​

ParametreTipZorunluAçıklama
venueIdstringHayırVenue ID (opsiyonel)

Request Body​

Tüm alanlar opsiyoneldir. Sadece güncellenmek istenen alanlar gönderilmelidir.

AlanTipAçıklama
namestringKullanıcı adı
usernamestringKullanıcı adı (username_password için)
emailstringE-posta adresi
phonestringTelefon numarası
venueIdsarrayVenue ID'leri dizisi
expiresAtstring (ISO 8601) | nullSon kullanma tarihi (null ise süresiz)
statusstringKullanıcı durumu (active, blocked, expired)
metadataobjectEk metadata

Önemli Notlar:

  • Expired (süresi dolmuş) kullanıcılar düzenlenemez
  • loginMethod değ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​

ParametreTipZorunluAçıklama
idstringEvetKullanıcı ID

Query Parametreleri​

ParametreTipZorunluAçıklama
venueIdstringHayırVenue 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​

ParametreTipZorunluAçıklama
idstringEvetKullanıcı ID

Request Body (Opsiyonel)​

AlanTipZorunluAçıklama
venueIdstringHayırVenue 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​