Skip to content

Commit 9600362

Browse files
transactions
1 parent a467f5f commit 9600362

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

custom_components/coverflex/api.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,10 @@ async def getBalance(self, token) -> Pocket:
7272
except aiohttp.ClientError as err:
7373
_LOGGER.error(err)
7474

75-
async def getMovements(self, token, pocketId, movementCount: int) -> List[Transaction]:
75+
async def getMovements(self, token, pocketId, movementCount: int):
7676
"""Issue CARD requests."""
7777
try:
78-
_LOGGER.debug("Getting the card movements...")
78+
_LOGGER.debug("Getting the card movements...", pocketId, movementCount)
7979
async with self.websession.get(
8080
API_MOVEMENTS_URL,
8181
params = {
@@ -87,6 +87,7 @@ async def getMovements(self, token, pocketId, movementCount: int) -> List[Transa
8787
) as res:
8888
if res.status == 200 and res.content_type == "application/json":
8989
json = await res.json()
90+
_LOGGER.debug("fetched...", json)
9091
return [
9192
Transaction(data) for data in json['movements']['list']
9293
]

custom_components/coverflex/sensor.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,16 @@ async def async_update(self) -> None:
140140

141141
qtd = int(config[CONF_TRANSACTIONS])
142142
if (qtd > 0):
143-
self._transactions = await api.getMovements(token, pocket.id, qtd)
143+
movements = await api.getMovements(token, pocket.id, qtd)
144+
list = []
145+
[list.append({
146+
"date": t.date,
147+
"description": t.description,
148+
"amount": t.amount,
149+
"currency": t.currency
150+
}) for t in movements]
151+
self._transactions = list
152+
144153

145154

146155
except aiohttp.ClientError as err:

0 commit comments

Comments
 (0)