Skip to content

Commit 88546af

Browse files
Merge pull request #9 from garethtdavies/feature/transaction_status
Adding support for transactionStatus
2 parents c1fb5c8 + e82caf1 commit 88546af

2 files changed

Lines changed: 26 additions & 0 deletions

File tree

CodaClient.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,25 @@ def get_pooled_payments(self, pk: str) -> dict:
417417
res = self._send_query(query, variables)
418418
return res["data"]
419419

420+
def get_transaction_status(self, payment_id: str) -> dict:
421+
"""Get the transaction status for the specified Payment Id.
422+
423+
Arguments:
424+
payment_id {str} -- A Payment Id corresponding to a UserCommand.
425+
426+
Returns:
427+
dict -- Returns the "data" field of the JSON Response as a Dict.
428+
"""
429+
query = '''
430+
query($paymentId:ID!){
431+
transactionStatus(payment:$paymentId)
432+
}
433+
'''
434+
variables = {
435+
"paymentId": payment_id
436+
}
437+
res = self._send_query(query, variables)
438+
return res["data"]
420439

421440
async def listen_sync_update(self, callback):
422441
"""Creates a subscription for Network Sync Updates

tests/test_client.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,13 @@ def test_get_wallet(self, mock_post, snapshot):
5959
client.get_wallet("pk")
6060
snapshot.assert_match(mock_post.call_args_list)
6161

62+
def test_get_transaction_status(self, mock_post, snapshot):
63+
mock_post.return_value = self._mock_response(json_data={"data": "foo"})
64+
65+
client = Client()
66+
client.get_transaction_status("payment_id")
67+
snapshot.assert_match(mock_post.call_args_list)
68+
6269
def test_get_current_snark_worker(self, mock_post, snapshot):
6370
mock_post.return_value = self._mock_response(json_data={"data": "foo"})
6471

0 commit comments

Comments
 (0)