@@ -29,6 +29,13 @@ def default_handler(self, payload):
29
29
connection .update_state (state )
30
30
logger .debug (f"{ connection_id } state updated" )
31
31
32
+ # Combines receive and accept connection api calls
33
+ async def accept_connection (self , invitation ):
34
+ response = await self .receive_invitation (invitation )
35
+
36
+ accepted = await self .accept_invitation (response ["connection_id" ])
37
+ return accepted
38
+
32
39
### TODO refactor to extract out generic base - /connections
33
40
34
41
async def get_connections (
@@ -68,34 +75,18 @@ async def create_invitation(
68
75
self ,
69
76
alias : str = None ,
70
77
auto_accept : bool = None ,
71
- public : bool = None ,
72
- multi_use : bool = None ,
73
- invite_options : dict = None ,
78
+ public : str = None ,
79
+ multi_use : str = None ,
74
80
):
75
81
params = {}
76
82
if alias :
77
83
params ["alias" ] = alias
78
- if auto_accept in [ True , False ] :
84
+ if auto_accept :
79
85
params ["auto_accept" ] = auto_accept
80
- if public in [ True , False ] :
86
+ if public :
81
87
params ["public" ] = public
82
- if multi_use in [ True , False ] :
88
+ if multi_use :
83
89
params ["multi_use" ] = multi_use
84
- if invite_option :
85
- """A dictionary of the form:
86
- {
87
- "mediation_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
88
- "metadata": {},
89
- "recipient_keys": [
90
- "H3C2AVvLMv6gmMNam3uVAjZpfkcJCwDwnZn6z3wXmqPV"
91
- ],
92
- "routing_keys": [
93
- "H3C2AVvLMv6gmMNam3uVAjZpfkcJCwDwnZn6z3wXmqPV"
94
- ],
95
- "service_endpoint": "http://192.168.56.102:8020"
96
- }
97
- """
98
- params ['body' ] = invite_options
99
90
100
91
invite_details = await self .admin_POST (
101
92
"/connections/create-invitation" , params = params
@@ -110,7 +101,7 @@ async def receive_invitation(
110
101
params = {}
111
102
if alias :
112
103
params ["alias" ] = alias
113
- if auto_accept in [ True , False ] :
104
+ if auto_accept :
114
105
params ["auto_accept" ] = auto_accept
115
106
116
107
response = await self .admin_POST (
0 commit comments