MCPcopy Create free account
hub / github.com/BrasilAPI/BrasilAPI / getPixParticipants

Function getPixParticipants

services/pix/participants.js:19–39  ·  view source on GitHub ↗
(fromToday = true, daysBefore = 1)

Source from the content-addressed store, hash-verified

17}
18
19export const getPixParticipants = async (fromToday = true, daysBefore = 1) => {
20 const date = fromToday
21 ? buildDate()
22 : buildDate(getNow().subtract(daysBefore, 'day'));
23
24 const url = `${API_URL}${date}.csv`;
25 const csvPix = await axios.get(url, {
26 headers: {
27 Accept: 'text/csv',
28 'accept-encoding': '*',
29 },
30 responseType: 'arraybuffer',
31 });
32 const contentType = csvPix.headers['content-type'] || '';
33 const charsetMatch = contentType.match(/charset=([^;]+)/i);
34 const charset = (charsetMatch && charsetMatch[1].toLowerCase()) || 'latin1'; // fallback
35
36 const decoder = new TextDecoder(charset === 'utf-8' ? 'utf-8' : 'latin1');
37 const normalized = decoder.decode(csvPix.data);
38 return normalized;
39};
40
41/**
42 * Parse dos dados obtidos do Banco Central

Callers 1

obtainPixParticipantListFunction · 0.90

Calls 2

getNowFunction · 0.90
buildDateFunction · 0.85

Tested by

no test coverage detected