Skip to content

Commit

Permalink
feat: add support for delete static pix qrcodes by ID
Browse files Browse the repository at this point in the history
  • Loading branch information
joepreludian committed Nov 1, 2024
1 parent 381c126 commit 7c5a68a
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/asaaspy/client/resources/pix.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ def create_qrcode(self, qrcode: StaticQRCodeSchema) -> StaticQRCodeViewSchema:
)
return StaticQRCodeViewSchema(**response)

def delete_qrcode(self, id): ... # noqa E704
def delete_qrcode(self, id) -> bool:
response = self.call("DELETE", f"v3/pix/qrCodes/static/{id}")
return response.get("deleted", False)

# Transacoes PIX
def pay_qrcode(self, id): ... # noqa E704
Expand Down
75 changes: 75 additions & 0 deletions tests/asaas_sandbox_vcr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2882,6 +2882,81 @@
"string": "{\"id\":\"PRELUDIA00000000525658ASA\",\"encodedImage\":\"iVBORw0KGgoAAAANSUhEUgAAAcIAAAHCAQAAAABUY/ToAAADEUlEQVR4Xu2VTW7rMBCDs9P9b9RjeZeGf3JSoPBDN28McOIoIw4/ZiGlfTz/WF+Pn8q/VsmrKnlVJa+q5FWVvKr/Rh4P1jpez3oeXCRB87qemFgtOZpEh1WD9eHgxiNkxl9yMIkh9m8mZy1ej7cufMmbkPDRKz1RNJS8FSkY3HkhsFfcx3eUnEw+swLZjsQolLGns+RcEmfOE7582Vny19cAMuUDx9invk//QLBuiavkWBK/X9yDsLwT5+3wFgamaC05mCTqDLoYIHWnKIffUHIyqaJL5EqGbOLx+FvQlBxLQtVQhqDyQhTEK5G4kmPJaLBzFchDt9MXgHPllZxLQgGiNglJwwDU1kvOJtXq0OWli3eAQrJ1KTgtOZfUgEcsA3uFcIcpBT8lR5N7AJYMckghSyt5LRiWHEzSDw8cdJJTqFRG728oOZkEpwFG/FBzpqHXNyS55FiSO9s4h3chzjyjbZKj5GiSQ6yeJ4Ov3W9PydGkMZp4CchTIClVv29YAJacS6LljE62W1EqaCtRS44lOcMEJHGlUNlWuKyUnE2aPXIL4nFI4CSXvAPJCR1qpGD0gHvTAkoOJqVrZKe95wWJlPSSs0lCcKk4F7Ww88/9vC0l55KYaogDD3j48ZVgDpNoKTmWlFn4y5FVEGgpiKFOd8mxJLwrTnrhYRA5GtjGUXIyyfPNhER6EAplSxnbksNJee2BQkQfQneELSXnkvQsNMLpMS+cazLxWXIwCbNP2jvM0dDErSWHlxxOQsyAD4nsEIoFXjclx5KoTM9aQgXyDQMgVsmxpI9evnz4zI3wqvDKaFtyMAkFAJXs5GSidCUmqeRkMhSNe2xc+70DX3IyKZB2P3LSFDZCyfFkSuOlnzIadAnUjjjGJeeS2Fn4MOC/rdgM3/50l5xLosvqQ5c5LBErsJScTb5kD/WJkXe+EMCklLwN+eNFK3PMABJX8gbk0z9iC+zltT2WksNJycc+bxm31z3HWKGUnEtCkgjuZX7gjR1uAe+DN3qXHE3+qUpeVcmrKnlVJa+q5FXdjPwG0zZatu9LEUUAAAAASUVORK5CYII=\",\"payload\":\"00020126580014br.gov.bcb.pix0136e3326671-e7d7-40bc-b54d-d8303f8140e85204000053039865802BR5914Preludian Tech6009Guarulhos62290525PRELUDIA00000000525658ASA630427C9\",\"allowsMultiplePayments\":true,\"expirationDate\":null,\"externalReference\":null}"
}
}
},
{
"request": {
"method": "DELETE",
"uri": "https://sandbox.asaas.com/api/v3/pix/qrCodes/static/PRELUDIA00000000525658ASA",
"body": "",
"headers": {
"host": [
"sandbox.asaas.com"
],
"accept": [
"*/*"
],
"accept-encoding": [
"gzip, deflate"
],
"connection": [
"keep-alive"
],
"content-type": [
"application/json"
],
"user-agent": [
"AsaasPy"
]
}
},
"response": {
"status": {
"code": 200,
"message": ""
},
"headers": {
"Content-Type": [
"application/json;charset=utf-8"
],
"Transfer-Encoding": [
"chunked"
],
"Connection": [
"keep-alive"
],
"Date": [
"Fri, 01 Nov 2024 02:37:50 GMT"
],
"Set-Cookie": [
"AWSALBTG=z9DSp7wPrBOMXvNEzpn8/KbtQzrJp6wjDiOP47yEDWnWh+BqAthvH2AOC3yU/Bx5zYBexJ/pcy5K9k+azp6mdVtxyJLtKKiZM0onSL9nuLnbuWwPgxAiF/7ASmkBKOIkR6AILMBSDDiqlYec0oYt52/YvgOQxX2PxYeCTMqghCyo; Expires=Fri, 08 Nov 2024 02:37:49 GMT; Path=/",
"AWSALBTGCORS=z9DSp7wPrBOMXvNEzpn8/KbtQzrJp6wjDiOP47yEDWnWh+BqAthvH2AOC3yU/Bx5zYBexJ/pcy5K9k+azp6mdVtxyJLtKKiZM0onSL9nuLnbuWwPgxAiF/7ASmkBKOIkR6AILMBSDDiqlYec0oYt52/YvgOQxX2PxYeCTMqghCyo; Expires=Fri, 08 Nov 2024 02:37:49 GMT; Path=/; SameSite=None; Secure",
"AWSALB=U6HIgMAvq1ahrQWfY3ovm+IVdcNxeaKFV2eOMJj1eDrYfNjYw9qorvTAzDpVtu3bowB2mUrKB9Jl69QZ9uAI5foHFpA+YIZ+8+ksii6K92kLa0UJ0vLYtQnLaQjT; Expires=Fri, 08 Nov 2024 02:37:49 GMT; Path=/",
"AWSALBCORS=U6HIgMAvq1ahrQWfY3ovm+IVdcNxeaKFV2eOMJj1eDrYfNjYw9qorvTAzDpVtu3bowB2mUrKB9Jl69QZ9uAI5foHFpA+YIZ+8+ksii6K92kLa0UJ0vLYtQnLaQjT; Expires=Fri, 08 Nov 2024 02:37:49 GMT; Path=/; SameSite=None; Secure",
"JSESSIONID=A4B3CF0C02510B31B1ADDA530D7E2AE6107DDCCE3F7C3131BB0D8540A8D5D6CD1DA77B6ED75A791B34788A4DC37A60BCCD726752FB5B933709E5AA4094567373.n1; Path=/; Secure; HttpOnly"
],
"Server": [
"nginx"
],
"X-Cache": [
"Miss from cloudfront"
],
"Via": [
"1.1 2a0fdfa56513675d5c5b25c2795727b0.cloudfront.net (CloudFront)"
],
"X-Amz-Cf-Pop": [
"FOR50-P1"
],
"Alt-Svc": [
"h3=\":443\"; ma=86400"
],
"X-Amz-Cf-Id": [
"n0-Wczd7N76ZQfLs8_TK2hrt9i4RW0MTYqzWUikXETrx4rglNRYXPQ=="
]
},
"body": {
"string": "{\"deleted\":true,\"id\":\"PRELUDIA00000000525658ASA\"}"
}
}
}
]
}
3 changes: 3 additions & 0 deletions tests/pix/test_pix_resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ def test_create_static_qrcode(self, asaas_svc):
return_data = asaas_svc.pix.create_qrcode(request)
assert isinstance(return_data, StaticQRCodeViewSchema)

def test_delete_static_qrcode(self, asaas_svc):
assert asaas_svc.pix.delete_qrcode("PRELUDIA00000000525658ASA")

def test_delete_key_by_id_should_trigger_error_400(self, asaas_svc):
with pytest.raises(AsaasClientError) as exc:
asaas_svc.pix.delete_key("39006e1e-7c57-4944-ab22-10d957a0d1c9")
Expand Down

0 comments on commit 7c5a68a

Please sign in to comment.