50 lines
1.6 KiB
Python
50 lines
1.6 KiB
Python
import requests
|
|
|
|
def consultoras (access_token, data_inicial, data_final):
|
|
# Defina o endpoint e os headers
|
|
url = "https://backend-dashboards.prd.franqueado.grupoboticario.digital/store-indicators"
|
|
headers = {
|
|
"authorization": f"Bearer {access_token}", # Substitua pelo token real
|
|
"dash-view-name": "store-view/general",
|
|
"x-api-key": "8V5pUI1u1y3dFASezqZYY6iZvkUXDHZO6Ol66ja5",
|
|
"revenue-type": "gmv-revenue",
|
|
"cp-code": "10269",
|
|
"Accept": "application/json, text/plain, */*",
|
|
# Outros cabeçalhos podem ser adicionados aqui
|
|
}
|
|
|
|
# Parâmetros da URL
|
|
params = {
|
|
"orderBy": "revenueCurrentPeriodValue",
|
|
"aggregation": "consultant",
|
|
"order": "DESC",
|
|
"years": "2025",
|
|
"pillars": "Todos",
|
|
"startCurrentDate": {data_inicial},
|
|
"endCurrentDate": {data_final},
|
|
"startPreviousDate": "2024-01-03",
|
|
"endPreviousDate": "2024-01-21",
|
|
"calendarType": "calendar",
|
|
"previousPeriodCycleType": "retail-year",
|
|
"previousPeriodCalendarType": "retail-year",
|
|
"hour": "00:00 - 23:00",
|
|
"separationType": "businessDays",
|
|
"download": "true",
|
|
"channels": "LOJ",
|
|
}
|
|
|
|
# Envie a requisição GET
|
|
response = requests.get(url, headers=headers, params=params)
|
|
|
|
# Verifique a resposta
|
|
if response.status_code == 200:
|
|
print("Requisição bem-sucedida!")
|
|
response_json = response.json()
|
|
file_url = response_json.get("data", "")
|
|
|
|
else:
|
|
print(f"Erro: {response.status_code}")
|
|
print(response.text)
|
|
return file_url
|
|
|