Skip to content

Commit

Permalink
Merge pull request #53 from grablair/feature-delete-transaction
Browse files Browse the repository at this point in the history
Implement delete_transaction API call
  • Loading branch information
hammem authored Jan 4, 2024
2 parents 9aba5b4 + 8ee6ed3 commit a773171
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions monarchmoney/monarchmoney.py
Original file line number Diff line number Diff line change
Expand Up @@ -624,6 +624,55 @@ async def create_transaction(
variables=variables,
)

async def delete_transaction(self, transaction_id: str) -> bool:
"""
Deletes the given transaction.
:param transaction_id: the ID of the transaction targeted for deletion.
"""
query = gql(
"""
mutation Common_DeleteTransactionMutation($input: DeleteTransactionMutationInput!) {
deleteTransaction(input: $input) {
deleted
errors {
...PayloadErrorFields
__typename
}
__typename
}
}
fragment PayloadErrorFields on PayloadError {
fieldErrors {
field
messages
__typename
}
message
code
__typename
}
"""
)

variables = {
"input": {
"transactionId": transaction_id,
},
}

response = await self.gql_call(
operation="Common_DeleteTransactionMutation",
graphql_query=query,
variables=variables,
)

if not response["deleteTransaction"]["deleted"]:
raise RequestFailedException(response["deleteTransaction"]["errors"])

return True

async def get_transaction_categories(self) -> Dict[str, Any]:
"""
Gets all the categories configured in the account.
Expand Down

0 comments on commit a773171

Please sign in to comment.