Aller au contenu principal

Guide de test des API de promotion

Ce document explique comment tester les différents types de promotions disponibles dans l'API.

Types de promotions disponibles

1. Promotion WEEKEND_UBSI

Description : Promotion spéciale pour le week-end avec réduction variable selon le niveau de fidélité.

Paramètres :

  • templateCategorie (obligatoire) : Doit être "WEEKEND_UBSI"
  • categorieProduit (optionnel) : Catégorie de produit ciblée (ex: "HIGH_TECH")
  • idClients (optionnel) : Tableau d'IDs clients spécifiques

Exemple de requête :

# Sans catégorie de produit
curl -X POST "http://localhost:3000/api/publique/promotions/promotions-clients" \
-H "Content-Type: application/json" \
-d '{"templateCategorie": "WEEKEND_UBSI"}'

# Avec catégorie de produit
curl -X POST "http://localhost:3000/api/publique/promotions/promotions-clients" \
-H "Content-Type: application/json" \
-d '{"templateCategorie": "WEEKEND_UBSI", "categorieProduit": "HIGH_TECH"}'

2. Promotion ANNIVERSAIRE

Description : Promotion envoyée pour les anniversaires des clients.

Paramètres :

  • templateCategorie (obligatoire) : Doit être "ANNIVERSAIRE"
  • idClients (obligatoire) : Tableau contenant l'ID du client concerné
  • categorieProduit (optionnel) : Catégorie de produit ciblée

Exemple de requête :

curl -X POST "http://localhost:3000/api/publique/promotions/promotions-clients" \
-H "Content-Type: application/json" \
-d '{"templateCategorie": "ANNIVERSAIRE", "idClients": ["client123"]}'

3. Promotion INACTIF

Description : Promotion pour les clients inactifs.

Paramètres :

  • templateCategorie (obligatoire) : Doit être "INACTIF"
  • idClients (obligatoire) : Tableau d'IDs clients inactifs

Exemple de requête :

curl -X POST "http://localhost:3000/api/publique/promotions/promotions-clients" \
-H "Content-Type: application/json" \
-d '{"templateCategorie": "INACTIF", "idClients": ["client456", "client789"]}'

Réponses attendues

Succès (201)

{
"statusCode": 201,
"message": "Promotion [TYPE] créée et emails envoyés avec succès",
"data": {
"message": "Promotions [TYPE] créées avec succès pour X niveaux de fidélisation",
"resultats": [
{
"niveau": "Standard",
"promotion": { ... },
"emailResult": { ... }
}
]
}
}

Erreur (400)

{
"statusCode": 400,
"message": "Paramètres invalides",
"error": "Bad Request"
}

Variables de template disponibles

Pour WEEKEND_UBSI

  • discountPercentage : Pourcentage de réduction (sans le %)
  • offerLink : Lien vers l'offre
  • startDate : Date de début (YYYY-MM-DD)
  • endDate : Date de fin (YYYY-MM-DD)

Pour ANNIVERSAIRE

  • clientName : Nom du client
  • discount : Montant de la réduction
  • validUntil : Date de validité

Conseils de test

  1. Tester sans catégorie : Vérifiez que le système gère correctement l'absence de catégorie
  2. Tester avec des IDs clients : Vérifiez le ciblage spécifique
  3. Vérifier les logs : Les logs contiennent des informations détaillées sur le traitement

Logs à surveiller

  • Création des promotions
  • Envoi des emails
  • Erreurs éventuelles

Exemples de commandes PowerShell

# Tester une promotion WEEKEND_UBSI sans catégorie
$headers = @{"Content-Type" = "application/json"}
$body = '{"templateCategorie":"WEEKEND_UBSI"}'
Invoke-RestMethod -Uri "http://localhost:3000/api/publique/promotions/promotions-clients" -Method Post -Headers $headers -Body $body

# Tester une promotion WEEKEND_UBSI avec catégorie
$body = '{"templateCategorie":"WEEKEND_UBSI","categorieProduit":"HIGH_TECH"}'
Invoke-RestMethod -Uri "http://localhost:3000/api/publique/promotions/promotions-clients" -Method Post -Headers $headers -Body $body

# Tester une promotion ANNIVERSAIRE
$body = '{"templateCategorie":"ANNIVERSAIRE","idClients":["client123"]}'
Invoke-RestMethod -Uri "http://localhost:3000/api/publique/promotions/promotions-clients" -Method Post -Headers $headers -Body $body