GET /api/menages/{id}
Obtem as informacoes detalhadas de um agregado familiar.
Endpoint
GET /api/menages/{id}
Parametros de URL
| Parametro | Tipo | Descricao |
|---|---|---|
| id | integer | Identificador do agregado familiar |
Headers
| Header | Valor | Obrigatorio |
|---|---|---|
| Authorization | Bearer {token} | Sim |
Resposta de sucesso
Codigo: 200 OK
{
"@context": "/api/contexts/Menage",
"@id": "/api/menages/1",
"@type": "Menage",
"id": 1,
"codeMenage": "MEN-2024-00001",
"tailleMenage": 5,
"scorePmt": "45.67",
"statut": "actif",
"latitude": "14.7167",
"longitude": "-17.4677",
"altitude": "12.5",
"precisionGps": "5.0",
"nbEnfants04": 1,
"nbEnfants514": 2,
"nbAdultes1564": 2,
"nbPersonnes65Plus": 0,
"nbHandicapes": 0,
"nbActifsOccupes": 2,
"chefMenage": {
"@id": "/api/chef_menages/1",
"@type": "ChefMenage",
"id": 1,
"nomComplet": "Mamadou Diallo",
"sexe": "M",
"age": 45,
"niveauEducation": "secondaire",
"occupationPrincipale": "commerce",
"statutMatrimonial": "marie",
"telephone": "771234567",
"numeroMobileMoney": "771234567",
"compteBancaire": null
},
"logement": {
"@id": "/api/logements/1",
"@type": "Logement",
"typeLogement": "maison",
"statutOccupation": "proprietaire",
"nbPieces": 4,
"materiauMur": "ciment",
"materiauToit": "tole",
"materiauSol": "ciment",
"sourceEau": "robinet",
"typeToilette": "wc_chasse",
"sourceEclairage": "electricite",
"combustibleCuisine": "gaz"
},
"region": {
"@id": "/api/regions/1",
"@type": "Region",
"id": 1,
"nom": "Dakar",
"code": "DK"
},
"secteur": {
"@id": "/api/secteurs/1",
"@type": "Secteur",
"id": 1,
"nom": "Secteur 1"
},
"commune": {
"@id": "/api/communes/1",
"@type": "Commune",
"id": 1,
"nom": "Commune 1"
},
"localite": {
"@id": "/api/localites/1",
"@type": "Localite",
"id": 1,
"nom": "Localite 1"
},
"beneficiaire": {
"@id": "/api/beneficiaires/1",
"@type": "Beneficiaire",
"id": 1,
"actif": true,
"modePaiement": "orange_money"
},
"membres": [
{
"@id": "/api/membre_menages/1",
"nomComplet": "Fatou Diallo",
"lienParente": "epouse",
"sexe": "F",
"age": 38
},
{
"@id": "/api/membre_menages/2",
"nomComplet": "Ibrahima Diallo",
"lienParente": "fils",
"sexe": "M",
"age": 15
}
],
"createdAt": "2024-01-15T10:30:00+00:00",
"updatedAt": "2024-01-20T14:15:00+00:00",
"createdBy": {
"@id": "/api/users/1",
"email": "admin@pch-sig.sn"
}
}
Respostas de erro
404 Not Found
{
"@context": "/api/contexts/Error",
"@type": "hydra:Error",
"hydra:title": "An error occurred",
"hydra:description": "Item not found for \"/api/menages/999\""
}
403 Forbidden
{
"@context": "/api/contexts/Error",
"@type": "hydra:Error",
"hydra:title": "An error occurred",
"hydra:description": "Access Denied."
}
Exemplos
cURL
curl https://sig.ucp-pch.org/api/menages/1 \
-H "Authorization: Bearer TOKEN"
JavaScript
const getMenage = async (id) => {
const response = await fetch(
`https://sig.ucp-pch.org/api/menages/${id}`,
{
headers: {
'Authorization': `Bearer ${localStorage.getItem('token')}`
}
}
);
if (response.status === 404) {
throw new Error('Agregado familiar nao encontrado');
}
return response.json();
};
// Utilizacao
try {
const menage = await getMenage(1);
console.log(`Chefe: ${menage.chefMenage.nomComplet}`);
console.log(`Tamanho: ${menage.tailleMenage} pessoas`);
console.log(`Pontuacao PMT: ${menage.scorePmt}`);
} catch (error) {
console.error(error.message);
}
Python
import requests
def get_menage(token, menage_id):
response = requests.get(
f'https://sig.ucp-pch.org/api/menages/{menage_id}',
headers={'Authorization': f'Bearer {token}'}
)
if response.status_code == 404:
raise Exception('Agregado familiar nao encontrado')
return response.json()
# Utilizacao
menage = get_menage(token, 1)
print(f"Codigo: {menage['codeMenage']}")
print(f"Chefe: {menage['chefMenage']['nomComplet']}")
print(f"Regiao: {menage['region']['nom']}")
Campos da resposta
Agregado familiar
| Campo | Tipo | Descricao |
|---|---|---|
| id | integer | Identificador unico |
| codeMenage | string | Codigo unico do agregado |
| tailleMenage | integer | Numero de pessoas |
| scorePmt | string | Pontuacao PMT (decimal) |
| statut | string | Estado (actif, inactif, en_attente) |
| latitude, longitude | string | Coordenadas GPS |
Chefe de familia
| Campo | Tipo | Descricao |
|---|---|---|
| nomComplet | string | Nome completo |
| sexe | string | M ou F |
| age | integer | Idade |
| telephone | string | Numero de telefone |
| niveauEducation | string | Nivel de educacao |
| occupationPrincipale | string | Atividade principal |
Habitacao
| Campo | Tipo | Descricao |
|---|---|---|
| typeLogement | string | Tipo (casa, apartamento, etc.) |
| nbPieces | integer | Numero de divisoes |
| materiauMur | string | Material das paredes |
| sourceEau | string | Fonte de agua |
Notas
- A resposta inclui todas as relacoes (chefe, habitacao, membros, beneficiario)
- As coordenadas GPS sao retornadas como cadeias de caracteres (decimal)
- O campo
membrescontem a lista de membros do agregado excepto o chefe