Skip to content

Commit bce4e07

Browse files
committed
Make credential_id in store_credentials optional so it
* is optional as in the actual api and * only gets passed when provided [skip ci]
1 parent 58bff38 commit bce4e07

File tree

3 files changed

+17
-25
lines changed

3 files changed

+17
-25
lines changed

aries_cloudcontroller/controllers/base.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ def handle_output(self, *output, source: str = None, **kwargs):
5555
async def admin_request(
5656
self, method, path, json_data=None, text=False, params=None, data=None
5757
) -> ClientResponse:
58-
params = json.dumps(params)
5958
params = {k: v for (k, v) in (params or {}).items() if v is not None}
6059
async with self.client_session.request(
6160
method, self.admin_url + path, json=json_data, params=params, data=data

aries_cloudcontroller/controllers/connections.py

Lines changed: 13 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,13 @@ def default_handler(self, payload):
2929
connection.update_state(state)
3030
logger.debug(f"{connection_id} state updated")
3131

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+
3239
### TODO refactor to extract out generic base - /connections
3340

3441
async def get_connections(
@@ -68,34 +75,18 @@ async def create_invitation(
6875
self,
6976
alias: str = None,
7077
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,
7480
):
7581
params = {}
7682
if alias:
7783
params["alias"] = alias
78-
if auto_accept in [True, False]:
84+
if auto_accept:
7985
params["auto_accept"] = auto_accept
80-
if public in [True, False]:
86+
if public:
8187
params["public"] = public
82-
if multi_use in [True, False]:
88+
if multi_use:
8389
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
9990

10091
invite_details = await self.admin_POST(
10192
"/connections/create-invitation", params=params
@@ -110,7 +101,7 @@ async def receive_invitation(
110101
params = {}
111102
if alias:
112103
params["alias"] = alias
113-
if auto_accept in [True, False]:
104+
if auto_accept:
114105
params["auto_accept"] = auto_accept
115106

116107
response = await self.admin_POST(

aries_cloudcontroller/controllers/issuer.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,10 @@ async def issue_credential(self, cred_ex_id, comment, attributes):
135135
)
136136

137137
# Store a received credential
138-
async def store_credential(self, cred_ex_id, credential_id):
139-
body = {"credential_id": credential_id}
138+
async def store_credential(self, cred_ex_id, credential_id: str = None):
139+
body = {}
140+
if credential_id:
141+
body['credential_id'] = credential_id
140142
return await self.admin_POST(
141143
f"{self.base_url}/records/{cred_ex_id}/store", json_data=body
142144
)

0 commit comments

Comments
 (0)