diff --git a/CHANGELOG.md b/CHANGELOG.md index bebce0f..cb27d8d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,18 @@ Given a version number MAJOR.MINOR.PATCH, increment: ## [Unreleased] +### Added +- reason parameter and attribute to PixRequest resource +- before parameter to PixBalance get method +- chunk_count attribute to PixStatement resource +- tax_id filter to PixKey query and page methods +- Statistics sub-resource to PixUser resource +- reference_ids filter to PixChargeback query and page methods +- bacen_id and reference_ids filters to PixDispute query and page methods +- ids filter to PixDispute log query and page methods +- type parameter and attribute to StaticBrcode resource +- expired, data and jws attributes to BrcodePreview resource +- additional method options to PixRequest and type options to DynamicBrcode and PixInfraction ## [0.26.0] - 2026-06-15 ### Added diff --git a/starkinfra/brcodepreview/__brcodepreview.py b/starkinfra/brcodepreview/__brcodepreview.py index 8b414b9..5c51ef4 100644 --- a/starkinfra/brcodepreview/__brcodepreview.py +++ b/starkinfra/brcodepreview/__brcodepreview.py @@ -2,7 +2,7 @@ from starkcore.utils.resource import Resource from starkcore.utils.api import from_api_json from ..subscription.__subscription import Subscription -from starkcore.utils.checks import check_datetime_or_date +from starkcore.utils.checks import check_datetime, check_datetime_or_date from ..subscription.__subscription import _resource as _subscription_resource @@ -27,10 +27,13 @@ class BrcodePreview(Resource): - cash_amount [integer]: Amount to be withdrawn from the cashier in cents. ex: 1000 (= R$ 10.00) - cashier_bank_code [string]: Cashier's bank code. ex: "20018183" - cashier_type [string]: Cashier's type. Options: "merchant", "participant" and "other" + - data [list of dictionaries]: additional data of the dynamic QR code, in key/value pairs. ex: [{"key": "additional-info", "value": "order #12345"}] - discount_amount [integer]: Discount value calculated over nominal_amount. ex: 3000 - due [datetime.datetime]: BR Code due date. ex: datetime(2020, 3, 10) + - expired [datetime.datetime]: date and time after which the dynamic QR code is considered expired. ex: datetime(2022, 2, 1) - fine_amount [integer]: Fine value calculated over nominal_amount. ex: 20000 - interest_amount [integer]: Interest value calculated over nominal_amount. ex: 10000 + - jws [string]: JWS of the dynamic QR code. Returned only when "jws" is passed in the expand query parameter. ex: "eyJhbGciOiJFUzI1NiIsInR5cCI6IkpXVCJ9..." - key_id [string]: Receiver's PixKey id. ex: "+5511989898989" - name [string]: Payment receiver name. ex: "Tony Stark" - nominal_amount [integer]: Brcode emission amount, without fines, fees and discounts. ex: 1234 (= R$ 12.34) @@ -43,8 +46,8 @@ class BrcodePreview(Resource): """ 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, due=None, - fine_amount=None, interest_amount=None, key_id=None, name=None, nominal_amount=None, end_to_end_id=None, + branch_code=None, cash_amount=None, cashier_bank_code=None, cashier_type=None, data=None, discount_amount=None, due=None, + expired=None, fine_amount=None, interest_amount=None, jws=None, key_id=None, name=None, nominal_amount=None, end_to_end_id=None, reconciliation_id=None, reduction_amount=None, scheduled=None, subscription=None, status=None, tax_id=None, description=None): Resource.__init__(self, id=id) @@ -59,12 +62,17 @@ def __init__(self, id, payer_id, account_number=None, account_type=None, amount= self.cash_amount = cash_amount self.cashier_bank_code = cashier_bank_code self.cashier_type = cashier_type + self.data = data self.discount_amount = discount_amount if(due == ""): due = None self.due = check_datetime_or_date(due) + if(expired == ""): + expired = None + self.expired = check_datetime(expired) self.fine_amount = fine_amount self.interest_amount = interest_amount + self.jws = jws self.key_id = key_id self.name = name self.nominal_amount = nominal_amount diff --git a/starkinfra/dynamicbrcode/__dynamicbrcode.py b/starkinfra/dynamicbrcode/__dynamicbrcode.py index 1b2d96e..0a555df 100644 --- a/starkinfra/dynamicbrcode/__dynamicbrcode.py +++ b/starkinfra/dynamicbrcode/__dynamicbrcode.py @@ -23,7 +23,7 @@ class DynamicBrcode(Resource): - city [string]: receiver's city name. ex: "Rio de Janeiro" - external_id [string]: string that must be unique among all your DynamicBrcodes. Duplicated external ids will cause failures. ex: "my-internal-id-123456" ## Parameters (optional): - - type [string, default "instant"]: type of the DynamicBrcode. Options: "instant", "due" + - type [string, default "instant"]: type of the DynamicBrcode. Options: "instant", "due", "subscription", "subscriptionAndInstant", "dueAndOrSubscription" - tags [list of strings, default []]: list of strings for tagging. ex: ["travel", "food"] ## Attributes (return-only): - id [string]: id returned on creation, this is the BR code. ex: "00020126360014br.gov.bcb.pix0114+552840092118152040000530398654040.095802BR5915Jamie Lannister6009Sao Paulo620705038566304FC6C" diff --git a/starkinfra/pixbalance/__pixbalance.py b/starkinfra/pixbalance/__pixbalance.py index f2d424f..ab10887 100644 --- a/starkinfra/pixbalance/__pixbalance.py +++ b/starkinfra/pixbalance/__pixbalance.py @@ -1,6 +1,6 @@ from ..utils import rest from starkcore.utils.resource import Resource -from starkcore.utils.checks import check_datetime +from starkcore.utils.checks import check_datetime, check_date class PixBalance(Resource): @@ -27,12 +27,13 @@ def __init__(self, id=None, amount=None, currency=None, updated=None): _resource = {"class": PixBalance, "name": "PixBalance"} -def get(user=None): +def get(before=None, user=None): """# Retrieve the PixBalance object Receive the PixBalance object linked to your Workspace in the Stark Infra API ## Parameters (optional): + - before [datetime.date or string, default None]: date filter to retrieve the balance as of the end of the informed day. ex: datetime.date(2022, 1, 31) - user [Organization/Project object, default None]: Organization or Project object. Not necessary if starkinfra.user was set before function call. ## Return: - PixBalance object with updated attributes """ - return next(rest.get_stream(resource=_resource, user=user)) + return next(rest.get_stream(resource=_resource, before=check_date(before), user=user)) diff --git a/starkinfra/pixchargeback/__pixchargeback.py b/starkinfra/pixchargeback/__pixchargeback.py index 90a6765..99697cf 100644 --- a/starkinfra/pixchargeback/__pixchargeback.py +++ b/starkinfra/pixchargeback/__pixchargeback.py @@ -103,7 +103,7 @@ def get(id, user=None): return rest.get_id(id=id, resource=_resource, user=user) -def query(limit=None, after=None, before=None, status=None, ids=None, bacen_id=None, flow=None, tags=None, user=None): +def query(limit=None, after=None, before=None, status=None, ids=None, bacen_id=None, reference_ids=None, flow=None, tags=None, user=None): """# Retrieve PixChargebacks Receive a generator of PixChargeback objects previously created in the Stark Infra API ## Parameters (optional): @@ -113,6 +113,7 @@ def query(limit=None, after=None, before=None, status=None, ids=None, bacen_id=N - status [list of strings, default None]: filter for status of retrieved objects. ex: ["created", "failed", "delivered", "closed", "canceled"] - ids [list of strings, default None]: list of ids to filter retrieved objects. ex: ["5656565656565656", "4545454545454545"] - bacen_id [string, default None]: unique transaction id returned from Central Bank. ex: "ccf9bd9c-e99d-999e-bab9-b999ca999f99" + - reference_ids [list of strings, default None]: list of end_to_end_ids or return_ids of the reversed transactions to filter retrieved objects. Max = 30. ex: ["E20018183202201201450u34sDjD7334"] - flow [string, default None]: direction of the Pix Chargeback. Options: "in" for received chargebacks, "out" for chargebacks you requested - tags [list of strings, default None]: filter for tags of retrieved objects. ex: ["travel", "food"] - user [Organization/Project object, default None]: Organization or Project object. Not necessary if starkinfra.user was set before function call. @@ -128,13 +129,14 @@ def query(limit=None, after=None, before=None, status=None, ids=None, bacen_id=N status=status, ids=ids, bacen_id=bacen_id, + reference_ids=reference_ids, flow=flow, tags=tags, user=user, ) -def page(cursor=None, limit=None, after=None, before=None, status=None, ids=None, bacen_id=None, flow=None, tags=None, user=None): +def page(cursor=None, limit=None, after=None, before=None, status=None, ids=None, bacen_id=None, reference_ids=None, flow=None, tags=None, user=None): """# Retrieve PixChargebacks Receive a list of up to 100 PixChargeback objects previously created in the Stark Infra API and the cursor to the next page. Use this function instead of query if you want to manually page your requests. @@ -146,6 +148,7 @@ def page(cursor=None, limit=None, after=None, before=None, status=None, ids=None - status [list of strings, default None]: filter for status of retrieved objects. ex: ["created", "failed", "delivered", "closed", "canceled"] - ids [list of strings, default None]: list of ids to filter retrieved objects. ex: ["5656565656565656", "4545454545454545"] - bacen_id [string, default None]: unique transaction id returned from Central Bank. ex: "ccf9bd9c-e99d-999e-bab9-b999ca999f99" + - reference_ids [list of strings, default None]: list of end_to_end_ids or return_ids of the reversed transactions to filter retrieved objects. Max = 30. ex: ["E20018183202201201450u34sDjD7334"] - flow [string, default None]: direction of the Pix Chargeback. Options: "in" for received chargebacks, "out" for chargebacks you requested - tags [list of strings, default None]: filter for tags of retrieved objects. ex: ["travel", "food"] - user [Organization/Project object, default None]: Organization or Project object. Not necessary if starkinfra.user was set before function call. @@ -162,6 +165,7 @@ def page(cursor=None, limit=None, after=None, before=None, status=None, ids=None status=status, ids=ids, bacen_id=bacen_id, + reference_ids=reference_ids, flow=flow, tags=tags, user=user, diff --git a/starkinfra/pixdispute/__pixdispute.py b/starkinfra/pixdispute/__pixdispute.py index cf23df1..ad59f30 100644 --- a/starkinfra/pixdispute/__pixdispute.py +++ b/starkinfra/pixdispute/__pixdispute.py @@ -88,7 +88,7 @@ def get(id, user=None): return rest.get_id(resource=_resource, id=id, user=user) -def query(limit=None, after=None, before=None, status=None, ids=None, tags=None, user=None): +def query(limit=None, after=None, before=None, status=None, ids=None, bacen_id=None, reference_ids=None, tags=None, user=None): """# Retrieve PixDisputes Receive a generator of PixDispute objects previously created in the Stark Infra API ## Parameters (optional): @@ -97,6 +97,8 @@ def query(limit=None, after=None, before=None, status=None, ids=None, tags=None, - before [datetime.date or string, default None]: date filter for objects created before a specified date. ex: datetime.date(2020, 3, 10) - status [list of strings, default None]: filter for status of retrieved objects. ex: ["created", "processing", "success", "failed"] - ids [list of strings, default None]: list of ids to filter retrieved objects. ex: ["5656565656565656", "4545454545454545"] + - bacen_id [string, default None]: Central Bank's unique dispute id to filter retrieved objects. ex: "817fc523-9e9d-40ab-9e53-dacb71454a05" + - reference_ids [list of strings, default None]: list of end_to_end_ids of the reported transactions to filter retrieved objects. ex: ["E20018183202201201450u34sDjD7334"] - tags [list of strings, default None]: tags to filter retrieved objects. ex: ["tony", "stark"] - user [Organization/Project object, default None]: Organization or Project object. Not necessary if starkinfra.user was set before function call. ## Return: @@ -109,12 +111,14 @@ def query(limit=None, after=None, before=None, status=None, ids=None, tags=None, before=check_date(before), status=status, ids=ids, + bacen_id=bacen_id, + reference_ids=reference_ids, tags=tags, user=user, ) -def page(cursor=None, limit=None, after=None, before=None, status=None, ids=None, tags=None, user=None): +def page(cursor=None, limit=None, after=None, before=None, status=None, ids=None, bacen_id=None, reference_ids=None, tags=None, user=None): """# Retrieve paged PixDisputes Receive a list of up to 100 PixDispute objects previously created in the Stark Infra API and the cursor to the next page. Use this function instead of query if you want to manually page your requests. @@ -125,6 +129,8 @@ def page(cursor=None, limit=None, after=None, before=None, status=None, ids=None - before [datetime.date or string, default None]: date filter for objects created before a specified date. ex: datetime.date(2020, 3, 10) - status [list of strings, default None]: filter for status of retrieved objects. ex: ["created", "processing", "success", "failed"] - ids [list of strings, default None]: list of ids to filter retrieved objects. ex: ["5656565656565656", "4545454545454545"] + - bacen_id [string, default None]: Central Bank's unique dispute id to filter retrieved objects. ex: "817fc523-9e9d-40ab-9e53-dacb71454a05" + - reference_ids [list of strings, default None]: list of end_to_end_ids of the reported transactions to filter retrieved objects. ex: ["E20018183202201201450u34sDjD7334"] - tags [list of strings, default None]: tags to filter retrieved objects. ex: ["tony", "stark"] - user [Organization/Project object, default None]: Organization or Project object. Not necessary if starkinfra.user was set before function call. ## Return: @@ -139,6 +145,8 @@ def page(cursor=None, limit=None, after=None, before=None, status=None, ids=None before=check_date(before), status=status, ids=ids, + bacen_id=bacen_id, + reference_ids=reference_ids, tags=tags, user=user, ) diff --git a/starkinfra/pixdispute/log/__log.py b/starkinfra/pixdispute/log/__log.py index b68a705..dd8d09f 100644 --- a/starkinfra/pixdispute/log/__log.py +++ b/starkinfra/pixdispute/log/__log.py @@ -41,7 +41,7 @@ def get(id, user=None): return rest.get_id(resource=_resource, id=id, user=user) -def query(limit=None, after=None, before=None, types=None, dispute_ids=None, user=None): +def query(limit=None, after=None, before=None, types=None, ids=None, dispute_ids=None, user=None): """# Retrieve PixDispute.Logs Receive a generator of PixDispute.Log objects previously created in the Stark Infra API ## Parameters (optional): @@ -49,6 +49,7 @@ def query(limit=None, after=None, before=None, types=None, dispute_ids=None, use - after [datetime.date or string, default None]: date filter for objects created after a specified date. ex: datetime.date(2020, 3, 10) - before [datetime.date or string, default None]: date filter for objects created before a specified date. ex: datetime.date(2020, 3, 10) - types [list of strings, default None]: filter retrieved objects by types. Options: ["sent", "denied", "failed", "created", "success", "approved", "credited", "refunded", "processing"] + - ids [list of strings, default None]: list of PixDispute.Log ids to filter retrieved objects. ex: ["6767676767676767", "4545454545454545"] - dispute_ids [list of strings, default None]: list of PixDispute ids to filter retrieved objects. ex: ["5656565656565656", "4545454545454545"] - user [Organization/Project object, default None]: Organization or Project object. Not necessary if starkinfra.user was set before function call. ## Return: @@ -60,12 +61,13 @@ def query(limit=None, after=None, before=None, types=None, dispute_ids=None, use after=check_date(after), before=check_date(before), types=types, + ids=ids, dispute_ids=dispute_ids, user=user, ) -def page(cursor=None, limit=None, after=None, before=None, types=None, dispute_ids=None, user=None): +def page(cursor=None, limit=None, after=None, before=None, types=None, ids=None, dispute_ids=None, user=None): """# Retrieve paged PixDispute.Logs Receive a list of up to 100 PixDispute.Log objects previously created in the Stark Infra API and the cursor to the next page. Use this function instead of query if you want to manually page your requests. @@ -75,6 +77,7 @@ def page(cursor=None, limit=None, after=None, before=None, types=None, dispute_i - after [datetime.date or string, default None]: date filter for objects created after a specified date. ex: datetime.date(2020, 3, 10) - before [datetime.date or string, default None]: date filter for objects created before a specified date. ex: datetime.date(2020, 3, 10) - types [list of strings, default None]: filter retrieved objects by types. Options: ["sent", "denied", "failed", "created", "success", "approved", "credited", "refunded", "processing"] + - ids [list of strings, default None]: list of PixDispute.Log ids to filter retrieved objects. ex: ["6767676767676767", "4545454545454545"] - dispute_ids [list of strings, default None]: list of PixDispute IDs to filter retrieved objects. ex: ["5656565656565656", "4545454545454545"] - user [Organization/Project object, default None]: Organization or Project object. Not necessary if starkinfra.user was set before function call. ## Return: @@ -88,6 +91,7 @@ def page(cursor=None, limit=None, after=None, before=None, types=None, dispute_i after=check_date(after), before=check_date(before), types=types, + ids=ids, dispute_ids=dispute_ids, user=user, ) diff --git a/starkinfra/pixinfraction/__pixinfraction.py b/starkinfra/pixinfraction/__pixinfraction.py index d7b0883..db64741 100644 --- a/starkinfra/pixinfraction/__pixinfraction.py +++ b/starkinfra/pixinfraction/__pixinfraction.py @@ -12,7 +12,7 @@ class PixInfraction(Resource): to the Stark Infra API and returns the created object. ## Parameters (required): - reference_id [string]: end_to_end_id or return_id of the transaction being reported. ex: "E20018183202201201450u34sDGd19lz" - - type [string]: type of infraction report. Options: "reversal", "reversalChargeback" + - type [string]: type of infraction report. Options: "fraud", "reversal", "reversalChargeback" - method [string]: method of Pix Infraction. Options: "scam", "unauthorized", "coercion", "invasion", "other", "unknown" - operator_email [string]: contact email of the operator responsible for the PixInfraction. - operator_phone [string]: contact phone number of the operator responsible for the PixInfraction. diff --git a/starkinfra/pixkey/__pixkey.py b/starkinfra/pixkey/__pixkey.py index e29dd32..756ed68 100644 --- a/starkinfra/pixkey/__pixkey.py +++ b/starkinfra/pixkey/__pixkey.py @@ -88,7 +88,7 @@ def get(id, payer_id, end_to_end_id=None, user=None, expand=None): 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): +def query(limit=None, after=None, before=None, status=None, tags=None, ids=None, type=None, tax_id=None, user=None): """# Retrieve PixKeys Receive a generator of PixKey objects previously created in the Stark Infra API ## Parameters (optional): @@ -99,6 +99,7 @@ def query(limit=None, after=None, before=None, status=None, tags=None, ids=None, - tags [list of strings, default None]: tags to filter retrieved objects. ex: ["tony", "stark"] - ids [list of strings, default None]: list of ids to filter retrieved objects. ex: ["5656565656565656", "4545454545454545"] - type [string, default None]: filter for the type of retrieved PixKeys. Options: "cpf", "cnpj", "phone", "email" and "evp" + - tax_id [string, default None]: filter for the tax id (CPF/CNPJ) of the holder linked to the retrieved PixKeys. ex: "012.345.678-90" - user [Organization/Project object, default None]: Organization or Project object. Not necessary if starkinfra.user was set before function call. ## Return: - generator of PixKey objects with updated attributes @@ -112,12 +113,13 @@ def query(limit=None, after=None, before=None, status=None, tags=None, ids=None, tags=tags, ids=ids, type=type, + tax_id=tax_id, user=user, ) def page(cursor=None, limit=None, after=None, before=None, status=None, tags=None, ids=None, type=None, - user=None): + tax_id=None, user=None): """# Retrieve paged PixKeys Receive a generator of PixKey objects previously created in the Stark Infra API ## Parameters (optional): @@ -129,6 +131,7 @@ def page(cursor=None, limit=None, after=None, before=None, status=None, tags=Non - tags [list of strings, default None]: tags to filter retrieved objects. ex: ["tony", "stark"] - ids [list of strings, default None]: list of ids to filter retrieved objects. ex: ["5656565656565656", "4545454545454545"] - type [string, default None]: filter for the type of retrieved PixKeys. Options: "cpf", "cnpj", "phone", "email" and "evp" + - tax_id [string, default None]: filter for the tax id (CPF/CNPJ) of the holder linked to the retrieved PixKeys. ex: "012.345.678-90" - user [Organization/Project object, default None]: Organization or Project object. Not necessary if starkinfra.user was set before function call. ## Return: - cursor to retrieve the next page of PixKey objects @@ -144,6 +147,7 @@ def page(cursor=None, limit=None, after=None, before=None, status=None, tags=Non tags=tags, ids=ids, type=type, + tax_id=tax_id, user=user, ) diff --git a/starkinfra/pixrequest/__pixrequest.py b/starkinfra/pixrequest/__pixrequest.py index 3060be8..c94e500 100644 --- a/starkinfra/pixrequest/__pixrequest.py +++ b/starkinfra/pixrequest/__pixrequest.py @@ -38,7 +38,8 @@ class PixRequest(Resource): - reconciliation_id [string, default None]: Reconciliation ID linked to this payment. ex: "b77f5236-7ab9-4487-9f95-66ee6eaf1781" - initiator_tax_id [string, default None]: Payment initiator's tax id (CPF/CNPJ). ex: "01234567890" or "20.018.183/0001-80" - tags [list of strings, default []]: list of strings for reference when searching for PixRequests. ex: ["employees", "monthly"] - - method [string, default None]: execution method for thr creation of the Pix. ex: "manual", "payerQrcode", "dynamicQrcode" + - method [string, default None]: execution method for the creation of the Pix. Options: "manual", "dict", "initiator", "dynamicQrcode", "staticQrcode", "payerQrcode", "subscription", "contactless", "staticContactless" + - reason [string, default None]: reason why this Pix request was created. Options: "customerRequest", "subscriptionFlaw", "fraud" ## Attributes (return-only): - id [string]: unique id returned when the PixRequest is created. ex: "5656565656565656" - fee [integer]: fee charged when PixRequest is paid. ex: 200 (= R$ 2.00) @@ -53,7 +54,7 @@ def __init__(self, amount, external_id, sender_name, sender_tax_id, sender_branc sender_account_number, sender_account_type, receiver_name, receiver_tax_id, receiver_bank_code, receiver_account_number, receiver_branch_code, receiver_account_type, end_to_end_id, priority=None, cashier_type=None, cashier_bank_code=None, cash_amount=None, receiver_key_id=None, description=None, - reconciliation_id=None, initiator_tax_id=None, tags=None, method=None, id=None, fee=None, + reconciliation_id=None, initiator_tax_id=None, tags=None, method=None, reason=None, id=None, fee=None, status=None, flow=None, sender_bank_code=None, created=None, updated=None): Resource.__init__(self, id=id) @@ -81,6 +82,7 @@ def __init__(self, amount, external_id, sender_name, sender_tax_id, sender_branc self.initiator_tax_id = initiator_tax_id self.tags = tags self.method = method + self.reason = reason self.fee = fee self.status = status self.flow = flow diff --git a/starkinfra/pixstatement/__pixstatement.py b/starkinfra/pixstatement/__pixstatement.py index d5a6458..f065bee 100644 --- a/starkinfra/pixstatement/__pixstatement.py +++ b/starkinfra/pixstatement/__pixstatement.py @@ -20,11 +20,12 @@ class PixStatement(Resource): - id [string]: unique id returned when the PixStatement is created. ex: "5656565656565656" - status [string]: current PixStatement status. ex: "success" or "failed" - transaction_count [integer]: number of transactions that happened during the day that the PixStatement was requested. ex: 11 + - chunk_count [integer]: number of chunks the statement file is split into. ex: 2 - created [datetime.datetime]: creation datetime for the PixStatement. ex: datetime.datetime(2020, 3, 10, 10, 30, 0, 0) - updated [datetime.datetime]: latest update datetime for the PixStatement. ex: datetime.datetime(2020, 3, 10, 10, 30, 0, 0) """ - def __init__(self, after, before, type, id=None, status=None, transaction_count=None, created=None, updated=None): + def __init__(self, after, before, type, id=None, status=None, transaction_count=None, chunk_count=None, created=None, updated=None): Resource.__init__(self, id=id) self.after = check_date(after) @@ -32,6 +33,7 @@ def __init__(self, after, before, type, id=None, status=None, transaction_count= self.type = type self.status = status self.transaction_count = transaction_count + self.chunk_count = chunk_count self.created = check_datetime(created) self.updated = check_datetime(updated) diff --git a/starkinfra/pixuser/__init__.py b/starkinfra/pixuser/__init__.py index e360d72..3aa4843 100644 --- a/starkinfra/pixuser/__init__.py +++ b/starkinfra/pixuser/__init__.py @@ -1,2 +1,3 @@ +from .statistics.__statistics import Statistics from .__pixuser import get diff --git a/starkinfra/pixuser/__pixuser.py b/starkinfra/pixuser/__pixuser.py index 9d0a090..43b25e3 100644 --- a/starkinfra/pixuser/__pixuser.py +++ b/starkinfra/pixuser/__pixuser.py @@ -1,5 +1,8 @@ from ..utils import rest +from starkcore.utils.api import from_api_json from starkcore.utils.resource import Resource +from .statistics.__statistics import Statistics +from .statistics.__statistics import _sub_resource as _statistics_resource class PixUser(Resource): @@ -14,12 +17,26 @@ class PixUser(Resource): def __init__(self, id, statistics=None): Resource.__init__(self, id=id) - self.statistics = statistics + self.statistics = _parse_statistics(statistics) +PixUser.Statistics = Statistics + _resource = {"class": PixUser, "name": "PixUser"} +def _parse_statistics(statistics): + if statistics is None: + return None + parsed_statistics = [] + for statistic in statistics: + if isinstance(statistic, Statistics): + parsed_statistics.append(statistic) + continue + parsed_statistics.append(from_api_json(_statistics_resource, statistic)) + return parsed_statistics + + def get(id, key_id=None, user=None): """# Retrieve a PixUser object Receive a single PixUser object information by passing its taxId diff --git a/starkinfra/pixuser/statistics/__init__.py b/starkinfra/pixuser/statistics/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/starkinfra/pixuser/statistics/__statistics.py b/starkinfra/pixuser/statistics/__statistics.py new file mode 100644 index 0000000..5275f57 --- /dev/null +++ b/starkinfra/pixuser/statistics/__statistics.py @@ -0,0 +1,24 @@ +from starkcore.utils.subresource import SubResource +from starkcore.utils.checks import check_datetime + + +class Statistics(SubResource): + """# PixUser.Statistics object + The PixUser.Statistics object stores fraud statistics data of a Pix user. + ## Attributes (return-only): + - value [integer]: aggregated value of the statistic. ex: 3 + - type [string]: type of the statistic. ex: "infractions" + - source [string]: source of the statistic. ex: "keyManagement" + - after [datetime.datetime]: start datetime considered for the statistic aggregation. ex: datetime.datetime(2020, 4, 23, 23, 0, 0) + - updated [datetime.datetime]: latest update datetime for the statistic. ex: datetime.datetime(2020, 4, 23, 23, 0, 0) + """ + + def __init__(self, value=None, type=None, source=None, after=None, updated=None): + self.value = value + self.type = type + self.source = source + self.after = check_datetime(after) + self.updated = check_datetime(updated) + + +_sub_resource = {"class": Statistics, "name": "Statistics"} diff --git a/starkinfra/staticbrcode/__staticbrcode.py b/starkinfra/staticbrcode/__staticbrcode.py index 6a29ea9..5c4455c 100644 --- a/starkinfra/staticbrcode/__staticbrcode.py +++ b/starkinfra/staticbrcode/__staticbrcode.py @@ -19,6 +19,7 @@ class StaticBrcode(Resource): - reconciliation_id [string, default None]: id to be used for conciliation of the resulting Pix transaction. This id must have up to 25 alphanumeric characters ex: "ah27s53agj6493hjds6836v49" - description [string, default None]: optional description to override default description to be shown in the bank statement. ex: "Payment for service #1234" - tags [list of strings, default []]: list of strings for tagging. ex: ["travel", "food"] + - type [string, default "instant"]: type of the StaticBrcode. Options: "instant", "instantAndOrSubscription" ## Attributes (return-only): - id [string]: id returned on creation, this is the BR code. ex: "00020126360014br.gov.bcb.pix0114+552840092118152040000530398654040.095802BR5915Jamie Lannister6009Sao Paulo620705038566304FC6C" - uuid [string]: unique uuid returned when a StaticBrcode is created. ex: "97756273400d42ce9086404fe10ea0d6" @@ -28,7 +29,7 @@ class StaticBrcode(Resource): """ def __init__(self, name, key_id, city, amount=None, cashier_bank_code=None, reconciliation_id=None, tags=None, - id=None, description=None, uuid=None, url=None, updated=None, created=None): + id=None, description=None, type=None, uuid=None, url=None, updated=None, created=None): Resource.__init__(self, id=id) self.name = name @@ -39,6 +40,7 @@ def __init__(self, name, key_id, city, amount=None, cashier_bank_code=None, reco self.reconciliation_id = reconciliation_id self.description = description self.tags = tags + self.type = type self.uuid = uuid self.url = url self.updated = check_datetime(updated)