diff --git a/src/aleph/sdk/client/http.py b/src/aleph/sdk/client/http.py index f8eb674b..0ce33a7a 100644 --- a/src/aleph/sdk/client/http.py +++ b/src/aleph/sdk/client/http.py @@ -610,7 +610,7 @@ async def get_credit_history( page_size: int = 200, page: int = 1, ) -> CreditsHistoryResponse: - """Return List of credits balance for all addresses""" + """Return List of credits history for a specific addresses""" params = { "page": str(page), diff --git a/src/aleph/sdk/query/responses.py b/src/aleph/sdk/query/responses.py index 3872a3a2..b5958d47 100644 --- a/src/aleph/sdk/query/responses.py +++ b/src/aleph/sdk/query/responses.py @@ -87,7 +87,7 @@ class CreditsHistoryResponse(PaginationResponse): """Response from an aleph.im node API on the path /api/v0/credits""" address: str - credit_balances: List[CreditHistoryResponseItem] + credit_history: List[CreditHistoryResponseItem] pagination_item: str = "credit_history" diff --git a/tests/unit/test_credits.py b/tests/unit/test_credits.py index 6e4cbb90..fb2e6d95 100644 --- a/tests/unit/test_credits.py +++ b/tests/unit/test_credits.py @@ -16,51 +16,36 @@ async def test_get_credits_history(): # Mock data for credit history credit_history_data = { "address": address, - "credit_balances": [ + "credit_history": [ { - "amount": 1000, - "ratio": 1.0, - "tx_hash": "0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef", - "token": "ALEPH", - "chain": "ETH", - "provider": "gateway", - "origin": "purchase", - "origin_ref": "0xabcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890", - "payment_method": "token", - "credit_ref": "init_credit_1", - "credit_index": 1, - "expiration_date": "2025-12-31T23:59:59Z", - "message_timestamp": "2023-01-01T12:00:00Z", - }, - { - "amount": -100, + "amount": -22, "ratio": None, "tx_hash": None, "token": None, "chain": None, - "provider": "node1.aleph.im", - "origin": "vm_usage", - "origin_ref": "vm_instance_123456", - "payment_method": None, - "credit_ref": "vm_consumption_1", - "credit_index": 2, + "provider": "ALEPH", + "origin": None, + "origin_ref": "212f4825dd30e01f3801cdff1bdf8cd4d1c14ce2d31d695aee429d2ad0dfcba1", + "payment_method": "credit_expense", + "credit_ref": "cd77a7983af168941fd011427c6198b146ccd6f85077e0b593a4e7239d45fb11", + "credit_index": 0, "expiration_date": None, - "message_timestamp": "2023-01-15T14:30:00Z", + "message_timestamp": "2025-09-30T06:57:26.106000Z", }, { - "amount": 500, - "ratio": 0.8, - "tx_hash": "0x9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba", - "token": "ALEPH", - "chain": "ETH", - "provider": "gateway", - "origin": "purchase", - "origin_ref": "0xfedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210", - "payment_method": "token", - "credit_ref": "add_credit_1", - "credit_index": 3, - "expiration_date": "2026-06-30T23:59:59Z", - "message_timestamp": "2023-02-01T09:15:00Z", + "amount": -22, + "ratio": None, + "tx_hash": None, + "token": None, + "chain": None, + "provider": "ALEPH", + "origin": None, + "origin_ref": "36ceb85fb570fc87a6b906dc89df39129a971de96cbc56250553cfb8d49487e3", + "payment_method": "credit_expense", + "credit_ref": "5881c8f813ea186b25a9a20d9bea46e2082c4d61c2b9e7d53bf8a164dc892b73", + "credit_index": 0, + "expiration_date": None, + "message_timestamp": "2025-09-30T02:57:07.673000Z", }, ], "pagination_page": 1, @@ -87,4 +72,4 @@ async def test_get_credits_history(): spy.assert_called_once_with( expected_url, params={"page": "1", "pagination": "200"} ) - assert len(response.credit_balances) == 3 + assert len(response.credit_history) == 2