Skip to content
Open
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ Given a version number MAJOR.MINOR.PATCH, increment:


## [Unreleased]
### Added
- Statistic sub-resource

## [0.11.0] - 2024-03-19
### Added
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
starkcore==0.1.1
starkcore==0.3.2
18 changes: 17 additions & 1 deletion starkinfra/pixuser/__pixuser.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
from ..utils import rest
from starkcore.utils.resource import Resource
from starkcore.utils.api import from_api_json
from .statistic.__statistic import Statistic
from .statistic.__statistic import _sub_resource as _statistic_resource



class PixUser(Resource):
Expand All @@ -14,7 +18,19 @@ class PixUser(Resource):
def __init__(self, id, statistics=None):
Resource.__init__(self, id=id)

self.statistics = statistics
self.statistics = _parse_statistic(statistics)


def _parse_statistic(statistics):
if statistics is None:
return None
parsed_statistics = []
for statistic in statistics:
if isinstance(statistic, Statistic):
parsed_statistics.append(statistic)
continue
parsed_statistics.append(from_api_json(_statistic_resource, statistic))
return parsed_statistics


_resource = {"class": PixUser, "name": "PixUser"}
Expand Down
Empty file.
23 changes: 23 additions & 0 deletions starkinfra/pixuser/statistic/__statistic.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
from starkcore.utils.subresource import SubResource


class Statistic(SubResource):
"""# PixUser.Statistic object
The PixUser.Statistic object modifies the behavior of Invoice objects when passed as an argument upon their creation.
## Parameters (required):
- after [datetime.datetime]: start date filter for the first element count of this element. ex: datetime.datetime(2020, 3, 10, 10, 30, 0, 0)
- source [string]: source of the statistic. ex: "pix-key", "pix-request", "pix-fraud", "pix-infraction"...
- type [string]: type of the statistic source. ex: "registered", "settled", "scam", "mule", "amount", "open", "denied"
- updated [datetime.datetime]: latest update datetime for the Statistic object. ex: datetime.datetime(2020, 3, 10, 10, 30, 0, 0)
- value [integer]: Entity tyoe counter between after and updated. ex: 1234
"""

def __init__(self, after, source, type, updated, value):
self.after = after
self.source = source
self.type = type
self.updated = updated
self.value = value


_sub_resource = {"class": Statistic, "name": "Statistic"}