|
| 1 | +from typing import TypedDict, List, Literal, Dict, Any, Optional |
| 2 | + |
| 3 | +from method.resource import Resource |
| 4 | +from method.configuration import Configuration |
| 5 | +from method.errors import ResourceError |
| 6 | + |
| 7 | + |
| 8 | +ReversalStatusesLiterals = Literal[ |
| 9 | + 'pending_approval', |
| 10 | + 'pending', |
| 11 | + 'processing', |
| 12 | + 'sent', |
| 13 | + 'failed' |
| 14 | +] |
| 15 | + |
| 16 | + |
| 17 | +ReversalDirectionsLiterals = Literal[ |
| 18 | + 'debit', |
| 19 | + 'credit' |
| 20 | +] |
| 21 | + |
| 22 | + |
| 23 | +class Reversal(TypedDict): |
| 24 | + id: str |
| 25 | + pmt_id: str |
| 26 | + target_account: str |
| 27 | + trace_id: Optional[str] |
| 28 | + direction: ReversalDirectionsLiterals |
| 29 | + description: str |
| 30 | + amount: int |
| 31 | + status: ReversalStatusesLiterals |
| 32 | + error: Optional[ResourceError] |
| 33 | + created_at: str |
| 34 | + updated_at: str |
| 35 | + |
| 36 | + |
| 37 | +class ReversalUpdateOpts(TypedDict): |
| 38 | + status: ReversalStatusesLiterals |
| 39 | + description: Optional[str] |
| 40 | + |
| 41 | + |
| 42 | +class ReversalResource(Resource): |
| 43 | + def __init__(self, config: Configuration): |
| 44 | + super(ReversalResource, self).__init__(config.add_path('reversals')) |
| 45 | + |
| 46 | + def get(self, _id: str) -> Reversal: |
| 47 | + return super(ReversalResource, self)._get_with_id(_id) |
| 48 | + |
| 49 | + def update(self, _id: str, opts: ReversalUpdateOpts) -> Reversal: |
| 50 | + return super(ReversalResource, self)._update_with_id(_id, opts) |
| 51 | + |
| 52 | + def list(self) -> List[Reversal]: |
| 53 | + return super(ReversalResource, self)._list(None) |
0 commit comments