Skip to content

Commit d75ed02

Browse files
stephenlucossiggy
authored andcommitted
Add transactions
1 parent 7c13281 commit d75ed02

1 file changed

Lines changed: 53 additions & 0 deletions

File tree

method/resources/Connection.py

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
from typing import TypedDict, Optional, List, Literal
2+
3+
from method.resources import Account
4+
from method.errors import ResourceError
5+
from method.resource import Resource
6+
from method.configuration import Configuration
7+
8+
9+
ConnectionSourcesLiterals = Literal[
10+
'plaid',
11+
'mch_5500'
12+
]
13+
14+
15+
ConnectionStatusesLiterals = Literal[
16+
'success',
17+
'reauth_required',
18+
'syncing',
19+
'failed'
20+
]
21+
22+
23+
class Connection(TypedDict):
24+
id: str
25+
entity_id: str
26+
accounts: List[str]
27+
source: ConnectionSourcesLiterals
28+
status: ConnectionStatusesLiterals
29+
error: Optional[ResourceError]
30+
created_at: str
31+
updated_at: str
32+
last_synced_at: str
33+
34+
35+
class ConnectionUpdateOpts(TypedDict):
36+
status: Literal['syncing']
37+
38+
39+
class ConnectionResource(Resource):
40+
def __init__(self, config: Configuration):
41+
super(ConnectionResource, self).__init__(config.add_path('connections'))
42+
43+
def get(self, _id: str) -> Connection:
44+
return super(ConnectionResource, self)._get_with_id(_id)
45+
46+
def list(self) -> List[Connection]:
47+
return super(ConnectionResource, self)._list(None)
48+
49+
def update(self, _id: str, opts: ConnectionUpdateOpts) -> Connection:
50+
return super(ConnectionResource, self)._update_with_id(_id, opts)
51+
52+
def get_public_account_tokens(self, _id: str) -> List[str]:
53+
return super(ConnectionResource, self)._get_with_sub_path('{_id}/public_account_tokens'.format(_id=_id))

0 commit comments

Comments
 (0)