Skip to content

Commit 5243a12

Browse files
committed
fix: issuev2 models
Signed-off-by: Timo Glastra <timo@animo.id>
1 parent 287a909 commit 5243a12

File tree

1 file changed

+101
-30
lines changed

1 file changed

+101
-30
lines changed

aries_cloudcontroller/api/issue_credential_v2_0.py

Lines changed: 101 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -13,25 +13,37 @@
1313
json,
1414
)
1515

16-
from typing import Dict, List, Optional, Union # noqa: F401
16+
from typing import Dict, List, Optional, Union # noqa: F401
1717

18-
from aries_cloudcontroller.model.v20_cred_bound_offer_request import V20CredBoundOfferRequest
18+
from aries_cloudcontroller.model.v20_cred_bound_offer_request import (
19+
V20CredBoundOfferRequest,
20+
)
1921
from aries_cloudcontroller.model.v20_cred_ex_free import V20CredExFree
2022
from aries_cloudcontroller.model.v20_cred_ex_record import V20CredExRecord
2123
from aries_cloudcontroller.model.v20_cred_ex_record_detail import V20CredExRecordDetail
22-
from aries_cloudcontroller.model.v20_cred_ex_record_list_result import V20CredExRecordListResult
23-
from aries_cloudcontroller.model.v20_cred_issue_problem_report_request import V20CredIssueProblemReportRequest
24+
from aries_cloudcontroller.model.v20_cred_ex_record_list_result import (
25+
V20CredExRecordListResult,
26+
)
27+
from aries_cloudcontroller.model.v20_cred_issue_problem_report_request import (
28+
V20CredIssueProblemReportRequest,
29+
)
2430
from aries_cloudcontroller.model.v20_cred_issue_request import V20CredIssueRequest
25-
from aries_cloudcontroller.model.v20_cred_offer_conn_free_request import V20CredOfferConnFreeRequest
31+
from aries_cloudcontroller.model.v20_cred_offer_conn_free_request import (
32+
V20CredOfferConnFreeRequest,
33+
)
2634
from aries_cloudcontroller.model.v20_cred_offer_request import V20CredOfferRequest
2735
from aries_cloudcontroller.model.v20_cred_request_free import V20CredRequestFree
2836
from aries_cloudcontroller.model.v20_cred_request_request import V20CredRequestRequest
2937
from aries_cloudcontroller.model.v20_cred_store_request import V20CredStoreRequest
38+
from aries_cloudcontroller.model.v20_issue_cred_schema_core import (
39+
V20IssueCredSchemaCore,
40+
)
3041

3142

3243
class IssueCredentialV20Api(Consumer):
33-
34-
async def create_credential(self, *, body: Optional[dict] = None) -> V20CredExRecord:
44+
async def create_credential(
45+
self, *, body: Optional[V20IssueCredSchemaCore] = None
46+
) -> V20CredExRecord:
3547
"""Create credential from attribute values"""
3648
return await self.__create_credential(
3749
body=body,
@@ -49,7 +61,14 @@ async def get_record(self, *, cred_ex_id: str) -> V20CredExRecordDetail:
4961
cred_ex_id=cred_ex_id,
5062
)
5163

52-
async def get_records(self, *, connection_id: Optional[str] = None, role: Optional[str] = None, state: Optional[str] = None, thread_id: Optional[str] = None) -> V20CredExRecordListResult:
64+
async def get_records(
65+
self,
66+
*,
67+
connection_id: Optional[str] = None,
68+
role: Optional[str] = None,
69+
state: Optional[str] = None,
70+
thread_id: Optional[str] = None
71+
) -> V20CredExRecordListResult:
5372
"""Fetch all credential exchange records"""
5473
return await self.__get_records(
5574
connection_id=connection_id,
@@ -58,65 +77,88 @@ async def get_records(self, *, connection_id: Optional[str] = None, role: Option
5877
thread_id=thread_id,
5978
)
6079

61-
async def issue_credential(self, *, cred_ex_id: str, body: Optional[V20CredIssueRequest] = None) -> V20CredExRecordDetail:
80+
async def issue_credential(
81+
self, *, cred_ex_id: str, body: Optional[V20CredIssueRequest] = None
82+
) -> V20CredExRecordDetail:
6283
"""Send holder a credential"""
6384
return await self.__issue_credential(
6485
cred_ex_id=cred_ex_id,
6586
body=body,
6687
)
6788

68-
async def issue_credential20_create_offer_post(self, *, body: Optional[V20CredOfferConnFreeRequest] = None) -> V20CredExRecord:
89+
async def issue_credential20_create_offer_post(
90+
self, *, body: Optional[V20CredOfferConnFreeRequest] = None
91+
) -> V20CredExRecord:
6992
"""Create a credential offer, independent of any proposal or connection"""
7093
return await self.__issue_credential20_create_offer_post(
7194
body=body,
7295
)
7396

74-
async def issue_credential_automated(self, *, body: Optional[V20CredExFree] = None) -> V20CredExRecord:
97+
async def issue_credential_automated(
98+
self, *, body: Optional[V20CredExFree] = None
99+
) -> V20CredExRecord:
75100
"""Send holder a credential, automating entire flow"""
76101
return await self.__issue_credential_automated(
77102
body=body,
78103
)
79104

80-
async def report_problem(self, *, cred_ex_id: str, body: Optional[V20CredIssueProblemReportRequest] = None) -> Dict:
105+
async def report_problem(
106+
self,
107+
*,
108+
cred_ex_id: str,
109+
body: Optional[V20CredIssueProblemReportRequest] = None
110+
) -> Dict:
81111
"""Send a problem report for credential exchange"""
82112
return await self.__report_problem(
83113
cred_ex_id=cred_ex_id,
84114
body=body,
85115
)
86116

87-
async def send_offer(self, *, cred_ex_id: str, body: Optional[V20CredBoundOfferRequest] = None) -> V20CredExRecord:
117+
async def send_offer(
118+
self, *, cred_ex_id: str, body: Optional[V20CredBoundOfferRequest] = None
119+
) -> V20CredExRecord:
88120
"""Send holder a credential offer in reference to a proposal with preview"""
89121
return await self.__send_offer(
90122
cred_ex_id=cred_ex_id,
91123
body=body,
92124
)
93125

94-
async def send_offer_free(self, *, body: Optional[V20CredOfferRequest] = None) -> V20CredExRecord:
126+
async def send_offer_free(
127+
self, *, body: Optional[V20CredOfferRequest] = None
128+
) -> V20CredExRecord:
95129
"""Send holder a credential offer, independent of any proposal"""
96130
return await self.__send_offer_free(
97131
body=body,
98132
)
99133

100-
async def send_proposal(self, *, body: Optional[V20CredExFree] = None) -> V20CredExRecord:
134+
async def send_proposal(
135+
self, *, body: Optional[V20CredExFree] = None
136+
) -> V20CredExRecord:
101137
"""Send issuer a credential proposal"""
102138
return await self.__send_proposal(
103139
body=body,
104140
)
105141

106-
async def send_request(self, *, cred_ex_id: str, body: Optional[V20CredRequestRequest] = None) -> V20CredExRecord:
142+
async def send_request(
143+
self, *, cred_ex_id: str, body: Optional[V20CredRequestRequest] = None
144+
) -> V20CredExRecord:
107145
"""Send issuer a credential request"""
108146
return await self.__send_request(
109147
cred_ex_id=cred_ex_id,
110148
body=body,
111149
)
112150

113-
async def send_request_free(self, *, body: Optional[V20CredRequestFree] = None) -> V20CredExRecord:
151+
async def send_request_free(
152+
self, *, body: Optional[V20CredRequestFree] = None
153+
) -> V20CredExRecord:
114154
"""Send issuer a credential request not bound to an existing thread. Indy credentials cannot start at a request"""
115155
return await self.__send_request_free(
116156
body=body,
117157
)
118158

119-
async def store_credential(self, *, cred_ex_id: str, body: Optional[V20CredStoreRequest] = None) -> V20CredExRecordDetail:
159+
async def store_credential(
160+
self, *, cred_ex_id: str, body: Optional[V20CredStoreRequest] = None
161+
) -> V20CredExRecordDetail:
120162
"""Store a received credential"""
121163
return await self.__store_credential(
122164
cred_ex_id=cred_ex_id,
@@ -126,7 +168,9 @@ async def store_credential(self, *, cred_ex_id: str, body: Optional[V20CredStore
126168
@returns.json
127169
@json
128170
@post("/issue-credential-2.0/create")
129-
def __create_credential(self, *, body: Body = {}) -> V20CredExRecord:
171+
def __create_credential(
172+
self, *, body: Body(type=V20IssueCredSchemaCore) = {}
173+
) -> V20CredExRecord:
130174
"""Internal uplink method for create_credential"""
131175

132176
@returns.json
@@ -141,65 +185,92 @@ def __get_record(self, *, cred_ex_id: str) -> V20CredExRecordDetail:
141185

142186
@returns.json
143187
@get("/issue-credential-2.0/records")
144-
def __get_records(self, *, connection_id: Query = None, role: Query = None, state: Query = None, thread_id: Query = None) -> V20CredExRecordListResult:
188+
def __get_records(
189+
self,
190+
*,
191+
connection_id: Query = None,
192+
role: Query = None,
193+
state: Query = None,
194+
thread_id: Query = None
195+
) -> V20CredExRecordListResult:
145196
"""Internal uplink method for get_records"""
146197

147198
@returns.json
148199
@json
149200
@post("/issue-credential-2.0/records/{cred_ex_id}/issue")
150-
def __issue_credential(self, *, cred_ex_id: str, body: Body(type=V20CredIssueRequest) = {}) -> V20CredExRecordDetail:
201+
def __issue_credential(
202+
self, *, cred_ex_id: str, body: Body(type=V20CredIssueRequest) = {}
203+
) -> V20CredExRecordDetail:
151204
"""Internal uplink method for issue_credential"""
152205

153206
@returns.json
154207
@json
155208
@post("/issue-credential-2.0/create-offer")
156-
def __issue_credential20_create_offer_post(self, *, body: Body(type=V20CredOfferConnFreeRequest) = {}) -> V20CredExRecord:
209+
def __issue_credential20_create_offer_post(
210+
self, *, body: Body(type=V20CredOfferConnFreeRequest) = {}
211+
) -> V20CredExRecord:
157212
"""Internal uplink method for issue_credential20_create_offer_post"""
158213

159214
@returns.json
160215
@json
161216
@post("/issue-credential-2.0/send")
162-
def __issue_credential_automated(self, *, body: Body(type=V20CredExFree) = {}) -> V20CredExRecord:
217+
def __issue_credential_automated(
218+
self, *, body: Body(type=V20CredExFree) = {}
219+
) -> V20CredExRecord:
163220
"""Internal uplink method for issue_credential_automated"""
164221

165222
@returns.json
166223
@json
167224
@post("/issue-credential-2.0/records/{cred_ex_id}/problem-report")
168-
def __report_problem(self, *, cred_ex_id: str, body: Body(type=V20CredIssueProblemReportRequest) = {}) -> Dict:
225+
def __report_problem(
226+
self, *, cred_ex_id: str, body: Body(type=V20CredIssueProblemReportRequest) = {}
227+
) -> Dict:
169228
"""Internal uplink method for report_problem"""
170229

171230
@returns.json
172231
@json
173232
@post("/issue-credential-2.0/records/{cred_ex_id}/send-offer")
174-
def __send_offer(self, *, cred_ex_id: str, body: Body(type=V20CredBoundOfferRequest) = {}) -> V20CredExRecord:
233+
def __send_offer(
234+
self, *, cred_ex_id: str, body: Body(type=V20CredBoundOfferRequest) = {}
235+
) -> V20CredExRecord:
175236
"""Internal uplink method for send_offer"""
176237

177238
@returns.json
178239
@json
179240
@post("/issue-credential-2.0/send-offer")
180-
def __send_offer_free(self, *, body: Body(type=V20CredOfferRequest) = {}) -> V20CredExRecord:
241+
def __send_offer_free(
242+
self, *, body: Body(type=V20CredOfferRequest) = {}
243+
) -> V20CredExRecord:
181244
"""Internal uplink method for send_offer_free"""
182245

183246
@returns.json
184247
@json
185248
@post("/issue-credential-2.0/send-proposal")
186-
def __send_proposal(self, *, body: Body(type=V20CredExFree) = {}) -> V20CredExRecord:
249+
def __send_proposal(
250+
self, *, body: Body(type=V20CredExFree) = {}
251+
) -> V20CredExRecord:
187252
"""Internal uplink method for send_proposal"""
188253

189254
@returns.json
190255
@json
191256
@post("/issue-credential-2.0/records/{cred_ex_id}/send-request")
192-
def __send_request(self, *, cred_ex_id: str, body: Body(type=V20CredRequestRequest) = {}) -> V20CredExRecord:
257+
def __send_request(
258+
self, *, cred_ex_id: str, body: Body(type=V20CredRequestRequest) = {}
259+
) -> V20CredExRecord:
193260
"""Internal uplink method for send_request"""
194261

195262
@returns.json
196263
@json
197264
@post("/issue-credential-2.0/send-request")
198-
def __send_request_free(self, *, body: Body(type=V20CredRequestFree) = {}) -> V20CredExRecord:
265+
def __send_request_free(
266+
self, *, body: Body(type=V20CredRequestFree) = {}
267+
) -> V20CredExRecord:
199268
"""Internal uplink method for send_request_free"""
200269

201270
@returns.json
202271
@json
203272
@post("/issue-credential-2.0/records/{cred_ex_id}/store")
204-
def __store_credential(self, *, cred_ex_id: str, body: Body(type=V20CredStoreRequest) = {}) -> V20CredExRecordDetail:
273+
def __store_credential(
274+
self, *, cred_ex_id: str, body: Body(type=V20CredStoreRequest) = {}
275+
) -> V20CredExRecordDetail:
205276
"""Internal uplink method for store_credential"""

0 commit comments

Comments
 (0)