|
| 1 | +from ..utils import rest |
| 2 | +from starkcore.utils.resource import Resource |
| 3 | +from starkcore.utils.checks import check_datetime, check_date |
| 4 | + |
| 5 | + |
| 6 | +class SplitProfile(Resource): |
| 7 | + """# SplitProfile object |
| 8 | + When you initialize a SplitProfile, the entity will not be automatically |
| 9 | + created in the Stark Bank API. The 'create' function sends the objects |
| 10 | + to the Stark Bank API and returns the list of created objects. |
| 11 | + ## Parameters (required): |
| 12 | + - interval [string]: frequency of transfer, default "week". Options: "day", "week", "month" |
| 13 | + - delay [string]: how long the amount will stay at the workspace in milliseconds |
| 14 | + ## Attributes (return-only): |
| 15 | + - id [string]: unique id returned when the splitProfile is created. ex: "5656565656565656" |
| 16 | + - delay []: 604800, |
| 17 | + - interval []: "month", |
| 18 | + - tags []: [], |
| 19 | + - status [string]: current splitProfile status. ex: "created" |
| 20 | + - created [datetime.datetime]: creation datetime for the splitProfile. ex: datetime.datetime(2020, 3, 10, 10, 30, 0, 0) |
| 21 | + - updated [datetime.datetime]: latest update datetime for the splitProfile. ex: datetime.datetime(2020, 3, 10, 10, 30, 0, 0) |
| 22 | + """ |
| 23 | + |
| 24 | + def __init__(self, delay, interval, tags=None, id=None, status=None, created=None, updated=None): |
| 25 | + Resource.__init__(self, id=id) |
| 26 | + |
| 27 | + self.interval = interval |
| 28 | + self.delay = delay |
| 29 | + self.tags = tags |
| 30 | + self.status = status |
| 31 | + self.created = check_datetime(created) |
| 32 | + self.updated = check_datetime(updated) |
| 33 | + |
| 34 | + |
| 35 | +_resource = {"class": SplitProfile, "name": "SplitProfile"} |
| 36 | + |
| 37 | + |
| 38 | +def update(splitProfile, user=None): |
| 39 | + """# Create SplitProfile |
| 40 | + Send a list of SplitProfile objects for creation in the Stark Bank API |
| 41 | + ## Parameters (required): |
| 42 | + - splitProfile [list of SplitProfile objects]: list of SplitProfile objects to be created in the API |
| 43 | + ## Parameters (optional): |
| 44 | + - user [Organization/Project object, default None]: Organization or Project object. Not necessary if starkbank.user was set before function call |
| 45 | + ## Return: |
| 46 | + - list of SplitProfile objects with updated attributes |
| 47 | + """ |
| 48 | + return rest.put_raw(resource=_resource, entities=splitProfile, user=user) |
| 49 | + |
| 50 | + |
| 51 | +def get(id, user=None): |
| 52 | + """# Retrieve a specific SplitProfile |
| 53 | + Receive a single SplitProfile object previously created in the Stark Bank API by its id |
| 54 | + ## Parameters (required): |
| 55 | + - id [string]: object unique id. ex: "5656565656565656" |
| 56 | + ## Parameters (optional): |
| 57 | + - user [Organization/Project object, default None]: Organization or Project object. Not necessary if starkbank.user was set before function call |
| 58 | + ## Return: |
| 59 | + - SplitProfile object with updated attributes |
| 60 | + """ |
| 61 | + return rest.get_id(resource=_resource, id=id, user=user) |
| 62 | + |
| 63 | + |
| 64 | +def query(limit=None, after=None, before=None, transaction_ids=None, status=None, tax_id=None, sort=None, tags=None, ids=None, user=None): |
| 65 | + """# Retrieve SplitProfile |
| 66 | + Receive a generator of SplitProfile objects previously created in the Stark Bank API |
| 67 | + ## Parameters (optional): |
| 68 | + - limit [integer, default None]: maximum number of objects to be retrieved. Unlimited if None. ex: 35 |
| 69 | + - after [datetime.date or string, default None]: date filter for objects created or updated only after specified date. ex: datetime.date(2020, 3, 10) |
| 70 | + - before [datetime.date or string, default None]: date filter for objects created or updated only before specified date. ex: datetime.date(2020, 3, 10) |
| 71 | + - user [Organization/Project object, default None]: Organization or Project object. Not necessary if starkbank.user was set before function call |
| 72 | + ## Return: |
| 73 | + - generator of SplitProfile objects with updated attributes |
| 74 | + """ |
| 75 | + return rest.get_stream( |
| 76 | + resource=_resource, |
| 77 | + limit=limit, |
| 78 | + after=check_date(after), |
| 79 | + before=check_date(before), |
| 80 | + user=user, |
| 81 | + ) |
| 82 | + |
| 83 | + |
| 84 | +def page(cursor=None, after=None, before=None, tags=None, ids=None, receiver_ids=None, status=None, limit=None, user=None): |
| 85 | + """# Retrieve paged Split Profiles |
| 86 | + Receive a list of up to 100 Split Profiles objects previously created in the Stark Bank API and the cursor to the next page. |
| 87 | + Use this function instead of query if you want to manually page your requests. |
| 88 | + ## Parameters (optional): |
| 89 | + - cursor [string, default None]: cursor returned on the previous page function call |
| 90 | + - limit [integer, default 100]: maximum number of objects to be retrieved. It must be an integer between 1 and 100. ex: 50 |
| 91 | + - after [datetime.date or string, default None] date filter for objects created only after specified date. ex: datetime.date(2020, 3, 10) |
| 92 | + - before [datetime.date or string, default None] date filter for objects created only before specified date. ex: datetime.date(2020, 3, 10) |
| 93 | + - tags [list of strings, default None]: tags to filter retrieved objects. ex: ["tony", "stark"] |
| 94 | + - ids [list of strings, default None]: list of ids to filter retrieved objects. ex: ["5656565656565656", "4545454545454545"] |
| 95 | + - receiver_ids [list of strings, default None]: list of receiver ids to filter retrieved objects. ex: ["5656565656565656", "4545454545454545"] |
| 96 | + - status [string, default None]: filter for status of retrieved objects. ex: "success" |
| 97 | + - user [Organization/Project object, default None]: Organization or Project object. Not necessary if starkbank.user was set before function call |
| 98 | + ## Return: |
| 99 | + - list of Split objects with updated attributes |
| 100 | + - cursor to retrieve the next page of Split objects |
| 101 | + """ |
| 102 | + return rest.get_page( |
| 103 | + resource=_resource, |
| 104 | + cursor=cursor, |
| 105 | + limit=limit, |
| 106 | + after=check_date(after), |
| 107 | + before=check_date(before), |
| 108 | + tags=tags, |
| 109 | + ids=ids, |
| 110 | + receiver_ids=receiver_ids, |
| 111 | + status=status, |
| 112 | + user=user, |
| 113 | + ) |
0 commit comments