-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathroot_backend.py
More file actions
132 lines (108 loc) · 4.82 KB
/
Copy pathroot_backend.py
File metadata and controls
132 lines (108 loc) · 4.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
from collections.abc import Callable, Coroutine
from typing import Any, TypeVar
from fastapi import Request
from returns.maybe import Maybe
from returns.result import ResultE
from stapi_pydantic import (
OpportunitySearchRecord,
OpportunitySearchStatus,
Order,
OrderStatus,
)
GetOrders = Callable[
[str | None, int, Request],
Coroutine[Any, Any, ResultE[tuple[list[Order[OrderStatus]], Maybe[str], Maybe[int]]]],
]
"""
Type alias for an async function that returns a list of existing Orders.
Args:
next (str | None): A pagination token.
limit (int): The maximum number of orders to return in a page.
request (Request): FastAPI's Request object.
Returns:
A tuple containing a list of orders and a pagination token.
- Should return returns.result.Success[tuple[list[Order], returns.maybe.Some[str]]]
if including a pagination token
- Should return returns.result.Success[tuple[list[Order], returns.maybe.Nothing]]
if not including a pagination token
- Returning returns.result.Failure[Exception] will result in a 500.
"""
GetOrder = Callable[[str, Request], Coroutine[Any, Any, ResultE[Maybe[Order[OrderStatus]]]]]
"""
Type alias for an async function that gets details for the order with `order_id`.
Args:
order_id (str): The order ID.
request (Request): FastAPI's Request object.
Returns:
- Should return returns.result.Success[returns.maybe.Some[Order]] if order is found.
- Should return returns.result.Success[returns.maybe.Nothing] if the order is not found or if access is denied.
- Returning returns.result.Failure[Exception] will result in a 500.
"""
T = TypeVar("T", bound=OrderStatus)
GetOrderStatuses = Callable[
[str, str | None, int, Request],
Coroutine[Any, Any, ResultE[Maybe[tuple[list[T], Maybe[str]]]]],
]
"""
Type alias for an async function that gets statuses for the order with `order_id`.
Args:
order_id (str): The order ID.
next (str | None): A pagination token.
limit (int): The maximum number of statuses to return in a page.
request (Request): FastAPI's Request object.
Returns:
A tuple containing a list of order statuses and a pagination token.
- Should return returns.result.Success[returns.maybe.Some[tuple[list[OrderStatus], returns.maybe.Some[str]]]
if order is found and including a pagination token.
- Should return returns.result.Success[returns.maybe.Some[tuple[list[OrderStatus], returns.maybe.Nothing]]]
if order is found and not including a pagination token.
- Should return returns.result.Success[returns.maybe.Nothing] if the order is not found or if access is denied.
- Returning returns.result.Failure[Exception] will result in a 500.
"""
GetOpportunitySearchRecords = Callable[
[str | None, int, Request],
Coroutine[Any, Any, ResultE[tuple[list[OpportunitySearchRecord], Maybe[str]]]],
]
"""
Type alias for an async function that gets OpportunitySearchRecords for all products.
Args:
request (Request): FastAPI's Request object.
next (str | None): A pagination token.
limit (int): The maximum number of search records to return in a page.
Returns:
- Should return returns.result.Success[tuple[list[OpportunitySearchRecord], returns.maybe.Some[str]]]
if including a pagination token
- Should return returns.result.Success[tuple[list[OpportunitySearchRecord], returns.maybe.Nothing]]
if not including a pagination token
- Returning returns.result.Failure[Exception] will result in a 500.
"""
GetOpportunitySearchRecord = Callable[[str, Request], Coroutine[Any, Any, ResultE[Maybe[OpportunitySearchRecord]]]]
"""
Type alias for an async function that gets the OpportunitySearchRecord with
`search_record_id`.
Args:
search_record_id (str): The ID of the OpportunitySearchRecord.
request (Request): FastAPI's Request object.
Returns:
- Should return returns.result.Success[returns.maybe.Some[OpportunitySearchRecord]] if the search record is found.
- Should return returns.result.Success[returns.maybe.Nothing] if the search record is not found or
if access is denied.
- Returning returns.result.Failure[Exception] will result in a 500.
"""
GetOpportunitySearchRecordStatuses = Callable[
[str, Request], Coroutine[Any, Any, ResultE[Maybe[list[OpportunitySearchStatus]]]]
]
"""
Type alias for an async function that gets the statuses of a OpportunitySearchRecord with
`search_record_id`.
Args:
search_record_id (str): The ID of the OpportunitySearchRecord.
request (Request): FastAPI's Request object.
Returns:
- Should return
returns.result.Success[returns.maybe.Some[list[OpportunitySearchStatus]]] if
the search record is found.
- Should return returns.result.Success[returns.maybe.Nothing] if the search record is not found or
if access is denied.
- Returning returns.result.Failure[Exception] will result in a 500.
"""