|
| 1 | +from .base import BaseController |
| 2 | +from aiohttp import ClientSession |
| 3 | +import logging |
| 4 | + |
| 5 | +logger = logging.getLogger("aries_controller.didexchange") |
| 6 | + |
| 7 | + |
| 8 | +class DidExchangeController(BaseController): |
| 9 | + def __init__(self, admin_url: str, client_session: ClientSession): |
| 10 | + super().__init__(admin_url, client_session) |
| 11 | + |
| 12 | + async def create_request_against_invite( |
| 13 | + self, |
| 14 | + their_pub_id: str, |
| 15 | + mediation_id: str = None, |
| 16 | + my_endpoint: str = None, |
| 17 | + my_label: str = None, |
| 18 | + ): |
| 19 | + params = {} |
| 20 | + if mediation_id: |
| 21 | + params["mediation_id"] = mediation_id |
| 22 | + if my_endpoint: |
| 23 | + params["my_endpoint"] = my_endpoint |
| 24 | + if my_label: |
| 25 | + params["my_label"] = my_label |
| 26 | + response = self.admin_POST(f"/didexchange/create-request", params=params) |
| 27 | + return response |
| 28 | + |
| 29 | + print(params) |
| 30 | + |
| 31 | + async def receive_request_against_invite( |
| 32 | + self, |
| 33 | + body: {} = None, |
| 34 | + alias: str = None, |
| 35 | + auto_accept: bool = None, |
| 36 | + mediation_id: str = None, |
| 37 | + my_endpoint: str = None, |
| 38 | + ): |
| 39 | + params = {} |
| 40 | + if alias: |
| 41 | + params["alias"] = alias |
| 42 | + if auto_accept: |
| 43 | + params["auto_accept"] = auto_accept |
| 44 | + if mediation_id: |
| 45 | + params["mediation_id"] = mediation_id |
| 46 | + if my_endpoint: |
| 47 | + params["my_endpoint"] = my_endpoint |
| 48 | + if body: |
| 49 | + response = self.admin_POST( |
| 50 | + f"/didexchange/receive-request", body=body, params=params |
| 51 | + ) |
| 52 | + else: |
| 53 | + response = self.admin_POST(f"/didexchange/receive-request", params=params) |
| 54 | + return response |
| 55 | + |
| 56 | + async def accept_invitation( |
| 57 | + self, connection_id: str, my_endpoint: str = None, my_label: str = None |
| 58 | + ): |
| 59 | + params = {} |
| 60 | + if my_endpoint: |
| 61 | + params["my_endpoint"] = my_endpoint |
| 62 | + if my_label: |
| 63 | + params["my_label"] = my_label |
| 64 | + response = self.admin_POST( |
| 65 | + f"/didexchange{connection_id}/accept-invitation", params=params |
| 66 | + ) |
| 67 | + return response |
| 68 | + |
| 69 | + async def accept_stored_invite( |
| 70 | + self, connection_id: str, mediation_id: str = None, my_endpoint: str = None |
| 71 | + ): |
| 72 | + params = {} |
| 73 | + if mediation_id: |
| 74 | + params["mediation_id"] = mediation_id |
| 75 | + if my_endpoint: |
| 76 | + params["my_endpoint"] = my_endpoint |
| 77 | + response = self.admin_POST( |
| 78 | + f"/didexchange/{connection_id}/accept-request", params=params |
| 79 | + ) |
0 commit comments