From 9a5c8e0578fa8f58e06c0df5ec23b4a92f2d13d0 Mon Sep 17 00:00:00 2001 From: Leonardo Kagohara Date: Tue, 18 Mar 2025 14:59:42 -0300 Subject: [PATCH] Fix dynamicBrCode and brCodePreview docstring --- CHANGELOG.md | 2 ++ starkbank/dynamicbrcode/__dynamicbrcode.py | 22 +++++++++++++++++++-- starkbank/dynamicbrcode/rule/__rule.py | 8 +++++++- starkbank/paymentpreview/__brcodepreview.py | 2 +- 4 files changed, 30 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f4f7f417..aa1d7c9c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,8 @@ Given a version number MAJOR.MINOR.PATCH, increment: ## [Unreleased] +### Fixed +- dynamicBrCode and brCodePreview docstring ## [2.28.0] - 2025-03-02 ### Added diff --git a/starkbank/dynamicbrcode/__dynamicbrcode.py b/starkbank/dynamicbrcode/__dynamicbrcode.py index 26acd53a..f593b638 100644 --- a/starkbank/dynamicbrcode/__dynamicbrcode.py +++ b/starkbank/dynamicbrcode/__dynamicbrcode.py @@ -8,9 +8,27 @@ class DynamicBrcode(Resource): """# DynamicBrcode object - Check out our API Documentation at https://starkbank.com/docs/api#dynamic-brcode + When you initialize a DynamicBrcode, the entity will not be automatically + sent to the Stark Bank API. The 'create' function sends the objects + to the Stark Bank API and returns the list of created objects. + DynamicBrcodes are conciliated BR Codes that can be used to receive Pix transactions in a convenient way. + When a DynamicBrcode is paid, a Deposit is created with the tags parameter containing the character “dynamic-brcode/” followed by the DynamicBrcode’s uuid "dynamic-brcode/{uuid}" for conciliation. + Additionally, all tags passed on the DynamicBrcode will be transferred to the respective Deposit resource. + ## Parameters (required): + - amount [integer]: DynamicBrcode value in cents. Minimum = 0 (any value will be accepted). ex: 1234 (= R$ 12.34) + ## Parameters (optional): + - expiration [integer or datetime.timedelta, default 3600 (1 hour)]: time interval in seconds between due date and expiration date. ex 123456789 + - tags [list of strings, default []]: list of strings for tagging, these will be passed to the respective Deposit resource when paid + - display_description [string, default None]: optional description to be shown in the payer bank interface. ex: "Payment for service #1234" + - rules [list of DynamicBrcode.Rules, default []]: list of DynamicBrcode.Rule objects for modifying invoice behavior. ex: [DynamicBrcode.Rule(key="allowedTaxIds", value=[ "012.345.678-90", "45.059.493/0001-73" ])] + ## 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 the DynamicBrcode is created. ex: "4e2eab725ddd495f9c98ffd97440702d" + - picture_url [string]: public QR Code (png image) URL. ex: "https://sandbox.api.starkbank.com/v2/dynamic-brcode/d3ebb1bd92024df1ab6e5a353ee799a4.png" + - updated [datetime.datetime]: latest update datetime for the DynamicBrcode. ex: datetime.datetime(2020, 3, 10, 10, 30, 0, 0) + - created [datetime.datetime]: creation datetime for the DynamicBrcode. ex: datetime.datetime(2020, 3, 10, 10, 30, 0, 0) """ - + def __init__(self, amount, expiration=None, tags=None, display_description=None, rules=None, id=None, uuid=None, picture_url=None, updated=None, created=None): Resource.__init__(self, id=id) diff --git a/starkbank/dynamicbrcode/rule/__rule.py b/starkbank/dynamicbrcode/rule/__rule.py index 89e3e361..af6cf370 100644 --- a/starkbank/dynamicbrcode/rule/__rule.py +++ b/starkbank/dynamicbrcode/rule/__rule.py @@ -2,7 +2,13 @@ class Rule(SubResource): - + """# DynamicBrcode.Rule object + The DynamicBrcode.Rule object modifies the behavior of DynamicBrcode objects when passed as an argument upon their creation. + ## Parameters (required): + - key [string]: Rule to be customized, describes what DynamicBrcode behavior will be altered. ex: "allowedTaxIds" + - value [list of string]: Value of the rule. ex: ["012.345.678-90", "45.059.493/0001-73"] + """ + def __init__(self, key, value): self.key = key self.value = value diff --git a/starkbank/paymentpreview/__brcodepreview.py b/starkbank/paymentpreview/__brcodepreview.py index 347c75aa..8e102ac7 100644 --- a/starkbank/paymentpreview/__brcodepreview.py +++ b/starkbank/paymentpreview/__brcodepreview.py @@ -6,7 +6,7 @@ class BrcodePreview(SubResource): """# BrcodePreview object A BrcodePreview is used to get information from a BR Code you received before confirming the payment. ## Attributes (return-only): - - status [string]: Payment status. ex: "active", "paid", "canceled" or "unknown" + - status [string]: Payment status. ex: "created", "paid", "canceled" or "expired" - name [string]: Payment receiver name. ex: "Tony Stark" - tax_id [string]: Payment receiver tax ID. ex: "012.345.678-90" - bank_code [string]: Payment receiver bank code. ex: "20018183"