Retorna o feed de atividades do usuário
curl --request GET \
--url https://api.example.com/timeline{
"items": [
{
"id": "evt_001",
"type": "purchase",
"title": "Compra registrada",
"description": "Você ganhou 150 pontos",
"points": 150,
"empresa": {
"id": "emp_123",
"name": "Pizzaria Exemplo",
"logo_url": "https://..."
},
"metadata": {
"nfce_id": "nfce_456",
"valor_total": 75.00
},
"created_at": "2024-06-20T19:30:00Z"
},
{
"id": "evt_002",
"type": "reward",
"title": "Prêmio resgatado",
"description": "Pizza Margherita Grande",
"points": -200,
"empresa": {
"id": "emp_123",
"name": "Pizzaria Exemplo",
"logo_url": "https://..."
},
"metadata": {
"reward_uid": "rwd_789",
"product_name": "Pizza Margherita Grande"
},
"created_at": "2024-06-18T14:00:00Z"
},
{
"id": "evt_003",
"type": "referral",
"title": "Indicação convertida",
"description": "Maria Santos se cadastrou usando seu link",
"points": 100,
"empresa": null,
"metadata": {
"referred_name": "Maria Santos",
"referral_id": "ref_012"
},
"created_at": "2024-06-15T10:00:00Z"
}
],
"pagination": {
"page": 1,
"limit": 20,
"total": 45,
"total_pages": 3,
"has_next": true,
"has_prev": false
}
}
purchase, reward, referral, interactioncurl -X GET "https://api.indiqai.com/api/v1/timeline?page=1&limit=20" \
-H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
{
"items": [
{
"id": "evt_001",
"type": "purchase",
"title": "Compra registrada",
"description": "Você ganhou 150 pontos",
"points": 150,
"empresa": {
"id": "emp_123",
"name": "Pizzaria Exemplo",
"logo_url": "https://..."
},
"metadata": {
"nfce_id": "nfce_456",
"valor_total": 75.00
},
"created_at": "2024-06-20T19:30:00Z"
},
{
"id": "evt_002",
"type": "reward",
"title": "Prêmio resgatado",
"description": "Pizza Margherita Grande",
"points": -200,
"empresa": {
"id": "emp_123",
"name": "Pizzaria Exemplo",
"logo_url": "https://..."
},
"metadata": {
"reward_uid": "rwd_789",
"product_name": "Pizza Margherita Grande"
},
"created_at": "2024-06-18T14:00:00Z"
},
{
"id": "evt_003",
"type": "referral",
"title": "Indicação convertida",
"description": "Maria Santos se cadastrou usando seu link",
"points": 100,
"empresa": null,
"metadata": {
"referred_name": "Maria Santos",
"referral_id": "ref_012"
},
"created_at": "2024-06-15T10:00:00Z"
}
],
"pagination": {
"page": 1,
"limit": 20,
"total": 45,
"total_pages": 3,
"has_next": true,
"has_prev": false
}
}
{
"type": "purchase",
"metadata": {
"nfce_id": "uuid",
"valor_total": 75.00,
"items_count": 3
}
}
{
"type": "reward",
"points": -200, // Negativo (gasto)
"metadata": {
"reward_uid": "uuid",
"product_name": "Nome do produto"
}
}
{
"type": "referral",
"points": 100,
"metadata": {
"referred_name": "Nome do indicado",
"referral_id": "uuid"
}
}
{
"type": "interaction",
"metadata": {
"interaction_type": "quest_completed",
"quest_name": "Primeira compra"
}
}
import { useInfiniteQuery } from '@tanstack/react-query';
import { apiClient } from '@/lib/api-client';
export function useTimeline() {
return useInfiniteQuery({
queryKey: ['timeline'],
queryFn: async ({ pageParam = 1 }) => {
const { data } = await apiClient.get('/timeline', {
params: { page: pageParam, limit: 20 }
});
return data;
},
getNextPageParam: (lastPage) =>
lastPage.pagination.has_next
? lastPage.pagination.page + 1
: undefined
});
}
Was this page helpful?
curl --request GET \
--url https://api.example.com/timeline{
"items": [
{
"id": "evt_001",
"type": "purchase",
"title": "Compra registrada",
"description": "Você ganhou 150 pontos",
"points": 150,
"empresa": {
"id": "emp_123",
"name": "Pizzaria Exemplo",
"logo_url": "https://..."
},
"metadata": {
"nfce_id": "nfce_456",
"valor_total": 75.00
},
"created_at": "2024-06-20T19:30:00Z"
},
{
"id": "evt_002",
"type": "reward",
"title": "Prêmio resgatado",
"description": "Pizza Margherita Grande",
"points": -200,
"empresa": {
"id": "emp_123",
"name": "Pizzaria Exemplo",
"logo_url": "https://..."
},
"metadata": {
"reward_uid": "rwd_789",
"product_name": "Pizza Margherita Grande"
},
"created_at": "2024-06-18T14:00:00Z"
},
{
"id": "evt_003",
"type": "referral",
"title": "Indicação convertida",
"description": "Maria Santos se cadastrou usando seu link",
"points": 100,
"empresa": null,
"metadata": {
"referred_name": "Maria Santos",
"referral_id": "ref_012"
},
"created_at": "2024-06-15T10:00:00Z"
}
],
"pagination": {
"page": 1,
"limit": 20,
"total": 45,
"total_pages": 3,
"has_next": true,
"has_prev": false
}
}