Skip to content
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

[Fix / Boleto]: Fix missing split parameter for creating split "Boleto" #125

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions starkbank/boleto/__boleto.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from ..utils import rest
from starkcore.utils.api import from_api_json
from starkcore.utils.resource import Resource
from starkcore.utils.checks import check_date, check_datetime

from ..split.__split import _resource as _split_resource, Split

class Boleto(Resource):
"""# Boleto object
Expand Down Expand Up @@ -43,7 +44,7 @@ class Boleto(Resource):
def __init__(self, amount, name, tax_id, street_line_1, street_line_2, district, city, state_code, zip_code,
due=None, fine=None, interest=None, overdue_limit=None, tags=None, descriptions=None, discounts=None,
receiver_name=None, receiver_tax_id=None, id=None, fee=None, line=None, bar_code=None, status=None,
workspace_id=None, transaction_ids=None, created=None, our_number=None):
workspace_id=None, transaction_ids=None, created=None, our_number=None, splits=None):
Resource.__init__(self, id=id)

self.amount = amount
Expand Down Expand Up @@ -72,10 +73,22 @@ def __init__(self, amount, name, tax_id, street_line_1, street_line_2, district,
self.workspace_id = workspace_id
self.created = check_datetime(created)
self.our_number = our_number
self.splits = _parse_splits(splits)


_resource = {"class": Boleto, "name": "Boleto"}

def _parse_splits(splits):
if splits is None:
return None
parsed_splits = []
for split in splits:
if isinstance(split, Split):
parsed_splits.append(split)
continue
parsed_splits.append(from_api_json(_split_resource, split))
return parsed_splits


def create(boletos, user=None):
"""# Create Boletos
Expand Down