-
Notifications
You must be signed in to change notification settings - Fork 5
Add expand to PixKey resource #92
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,6 +13,7 @@ class BrcodePreview(Resource): | |
| - id [string]: BR Code from a Pix payment. This is also de information directly encoded in a QR Code. ex: "00020126580014br.gov.bcb.pix0136a629532e-7693-4846-852d-1bbff817b5a8520400005303986540510.005802BR5908T'Challa6009Sao Paulo62090505123456304B14A" | ||
| - payer_id [string]: tax id (CPF/CNPJ) of the individual or business requesting the PixKey information. This id is used by the Central Bank to limit request rates. ex: "20.018.183/0001-80" | ||
| ## Parameters (optional): | ||
| - expand [list of strings]: list of strings to retrieve fraud statistics related to the pixKey and its owner. Options: "keyStatistics", "ownerStatistics" | ||
| - end_to_end_id [string]: central bank's unique transaction ID. ex: "E79457883202101262140HHX553UPqeq" | ||
| ## Attributes (return-only): | ||
| - account_number [string]: Payment receiver account number. ex: "1234567" | ||
|
|
@@ -35,12 +36,15 @@ class BrcodePreview(Resource): | |
| - scheduled [datetime.datetime]: date of payment execution. ex: datetime(2020, 3, 10) | ||
| - status [string]: Payment status. ex: "active", "paid", "canceled" or "unknown" | ||
| - tax_id [string]: Payment receiver tax ID. ex: "012.345.678-90" | ||
| - keyStatistics [list of PixKey.Statistics, default []]: statistics associated with the key itself. ex: [PixKey.Statistics(after="2023-11-06T18:57:08.325090+00:00", source="pix-key")] | ||
| - ownerStatistics [list of PixKey.OwnerStatistics, default []]: statistics associated with legal or juridical person that owns the key. ex: [PixKey.OwnerStatistics(after="2023-11-06T18:57:08.325090+00:00", source="pix-key")] | ||
| """ | ||
|
|
||
| def __init__(self, id, payer_id, account_number=None, account_type=None, amount=None, amount_type=None, bank_code=None, | ||
| branch_code=None, cash_amount=None, cashier_bank_code=None, cashier_type=None, discount_amount=None, | ||
| fine_amount=None, interest_amount=None, key_id=None, name=None, nominal_amount=None, end_to_end_id=None, | ||
| reconciliation_id=None, reduction_amount=None, scheduled=None, status=None, tax_id=None, description=None): | ||
| reconciliation_id=None, reduction_amount=None, scheduled=None, status=None, tax_id=None, description=None, | ||
| expand=None, key_statistics=None, owner_statistics=None): | ||
| Resource.__init__(self, id=id) | ||
|
|
||
| self.payer_id = payer_id | ||
|
|
@@ -66,6 +70,9 @@ def __init__(self, id, payer_id, account_number=None, account_type=None, amount= | |
| self.status = status | ||
| self.tax_id = tax_id | ||
| self.description = description | ||
| self.expand = expand | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. O expand deveria ir na query string, da uma olhada como que é feito pra cartão no SDK
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Funcionou desse jeito? |
||
| self.key_statistics = key_statistics | ||
| self.owner_statistics = owner_statistics | ||
|
|
||
|
|
||
| _resource = {"class": BrcodePreview, "name": "BrcodePreview"} | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -28,10 +28,13 @@ class PixKey(Resource): | |
| - bank_name [string]: name of the bank that holds the account linked to the PixKey. ex: "StarkBank" | ||
| - type [string]: type of the PixKey. Options: "cpf", "cnpj", "phone", "email" and "evp" | ||
| - created [datetime.datetime]: creation datetime for the PixKey. ex: datetime.datetime(2020, 3, 10, 10, 30, 0, 0) | ||
| - statistics [list of PixKey.Statistics, default []]: statistics associated with the key itself. ex: [PixKey.Statistics(after="2023-11-06T18:57:08.325090+00:00", source="pix-key")] | ||
| - ownerStatistics [list of PixKey.OwnerStatistics, default []]: statistics associated with legal or juridical person that owns the key. ex: [PixKey.OwnerStatistics(after="2023-11-06T18:57:08.325090+00:00", source="pix-key")] | ||
| """ | ||
|
|
||
| def __init__(self, account_created, account_number, account_type, branch_code, name, tax_id, id=None, tags=None, | ||
| owned=None, owner_type=None, status=None, bank_code=None, bank_name=None, type=None, created=None): | ||
| owned=None, owner_type=None, status=None, bank_code=None, bank_name=None, type=None, created=None, | ||
| statistics=None, owner_statistics=None): | ||
| Resource.__init__(self, id=id) | ||
|
|
||
| self.account_created = check_datetime(account_created) | ||
|
|
@@ -48,6 +51,8 @@ def __init__(self, account_created, account_number, account_type, branch_code, n | |
| self.bank_name = bank_name | ||
| self.type = type | ||
| self.created = check_datetime(created) | ||
| self.statistics = statistics | ||
| self.owner_statistics = owner_statistics | ||
|
|
||
|
|
||
| _resource = {"class": PixKey, "name": "PixKey"} | ||
|
|
@@ -66,7 +71,7 @@ def create(key, user=None): | |
| return rest.post_single(resource=_resource, entity=key, user=user) | ||
|
|
||
|
|
||
| def get(id, payer_id, end_to_end_id=None, user=None): | ||
| def get(id, payer_id, end_to_end_id=None, user=None, expand=None): | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fazer igual pro brcode payment |
||
| """# Retrieve a PixKey object | ||
| Retrieve the PixKey object linked to your Workspace in the Stark Infra API by its id. | ||
| ## Parameters (required): | ||
|
|
@@ -79,7 +84,7 @@ def get(id, payer_id, end_to_end_id=None, user=None): | |
| - PixKey object that corresponds to the given id. | ||
| """ | ||
|
|
||
| return rest.get_id(id=id, payer_id=payer_id, end_to_end_id=end_to_end_id, resource=_resource, user=user) | ||
| return rest.get_id(id=id, payer_id=payer_id, end_to_end_id=end_to_end_id, resource=_resource, user=user, expand=expand) | ||
|
|
||
|
|
||
| def query(limit=None, after=None, before=None, status=None, tags=None, ids=None, type=None, user=None): | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -65,6 +65,18 @@ def test_success(self): | |
| self.assertIsNotNone(pix_key.id) | ||
| self.assertEqual(pix_key.id, pix_key_id) | ||
| print(pix_key) | ||
|
|
||
| def test_success_with_expand(self): | ||
| pix_keys = starkinfra.pixkey.query() | ||
| pix_key_id = next(pix_keys).id | ||
| pix_key = starkinfra.pixkey.get( | ||
| id=pix_key_id, | ||
| payer_id=TaxIdGenerator.taxId(), | ||
| expand=["statistics", "ownerStatistics"], | ||
| ) | ||
| self.assertIn("statistics", str(pix_key)) | ||
| self.assertIn("owner_statistics", str(pix_key)) | ||
| print(pix_key) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Testar para o brcode tmb né |
||
|
|
||
| def test_success_ids(self): | ||
| pix_keys = starkinfra.pixkey.query(limit=5) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tirar o comentário