Skip to content

Commit da51b90

Browse files
committed
Rename issue credential functions
Signed-off-by: Laurence de Jong <info@ldej.nl>
1 parent e3027ce commit da51b90

File tree

4 files changed

+55
-69
lines changed

4 files changed

+55
-69
lines changed

README.md

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -129,23 +129,23 @@ Examples can be found in the [examples](./examples) folder.
129129

130130
`{id}` = credential exchange identifier
131131

132-
| Function Name | Method | Endpoint | Implemented |
133-
| --------------------------------- | ------ | ------------------------------------------- | ------------------ |
134-
| QueryCredentialExchange | GET | /issue-credential/records | :heavy_check_mark: |
135-
| GetCredentialExchange | GET | /issue-credential/records/{id} | :heavy_check_mark: |
136-
| CreateCredentialExchange | POST | /issue-credential/create | :heavy_check_mark: |
137-
| SendCredentialExchange | POST | /issue-credential/send | :heavy_check_mark: |
138-
| SendCredentialExchangeProposal | POST | /issue-credential/send-proposal | :heavy_check_mark: |
139-
| SendCredentialExchangeOffer | POST | /issue-credential/send-offer | :heavy_check_mark: |
140-
| SendCredentialExchangeOfferByID | POST | /issue-credential/{id}/send-offer | :heavy_check_mark: |
141-
| SendCredentialExchangeRequestByID | POST | /issue-credential/{id}/send-request | :heavy_check_mark: |
142-
| SendCredentialByID | POST | /issue-credential/{id}/issue | :heavy_check_mark: |
143-
| StoreReceivedCredential | POST | /issue-credential/{id}/store | :heavy_check_mark: |
144-
| RemoveCredentialExchange | POST | /issue-credential/{id}/remove | :heavy_check_mark: |
145-
| ReportCredentialExchangeProblem | POST | /issue-credential/{id}/problem-report | :heavy_check_mark: |
146-
| RevokeIssuedCredential | POST | /issue-credential/revoke | :heavy_check_mark: |
147-
| - | POST | /issue-credential/publish-revocations | :exclamation: |
148-
| - | POST | /issue-credential/clear-pending-revocations | :exclamation: |
132+
| Function Name | Method | Endpoint | Implemented |
133+
| ------------------------------- | ------ | ------------------------------------------- | ------------------ |
134+
| QueryCredentialExchange | GET | /issue-credential/records | :heavy_check_mark: |
135+
| GetCredentialExchange | GET | /issue-credential/records/{id} | :heavy_check_mark: |
136+
| CreateCredentialExchange | POST | /issue-credential/create | :heavy_check_mark: |
137+
| SendCredential | POST | /issue-credential/send | :heavy_check_mark: |
138+
| SendCredentialProposal | POST | /issue-credential/send-proposal | :heavy_check_mark: |
139+
| SendCredentialOffer | POST | /issue-credential/send-offer | :heavy_check_mark: |
140+
| SendCredentialOfferByID | POST | /issue-credential/{id}/send-offer | :heavy_check_mark: |
141+
| SendCredentialRequestByID | POST | /issue-credential/{id}/send-request | :heavy_check_mark: |
142+
| IssueCredentialByID | POST | /issue-credential/{id}/issue | :heavy_check_mark: |
143+
| StoreReceivedCredential | POST | /issue-credential/{id}/store | :heavy_check_mark: |
144+
| RemoveCredentialExchange | POST | /issue-credential/{id}/remove | :heavy_check_mark: |
145+
| ReportCredentialExchangeProblem | POST | /issue-credential/{id}/problem-report | :heavy_check_mark: |
146+
| RevokeIssuedCredential | POST | /issue-credential/revoke | :heavy_check_mark: |
147+
| - | POST | /issue-credential/publish-revocations | :exclamation: |
148+
| - | POST | /issue-credential/clear-pending-revocations | :exclamation: |
149149

150150
### Credentials
151151

credential.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import (
77

88
// TODO Credential differs between Swagger documentation and retrieved credential
99
type Credential struct {
10-
CredentialID string `json:"referent"` // ??
1110
CredentialDefinitionID string `json:"cred_def_id"`
1211
CredentialRevokeID string `json:"cred_rev_id"`
1312
SchemaID string `json:"schema_id"`
@@ -20,8 +19,10 @@ type Credential struct {
2019
Witness struct {
2120
Omega string `json:"omega"`
2221
} `json:"witness"`
23-
Values map[string]CredentialAttribute `json:"values"`
24-
Attributes map[string]interface{}
22+
Values map[string]CredentialAttribute `json:"values"`
23+
24+
CredentialID string `json:"referent"` // ??
25+
Attributes map[string]interface{} `json:"attrs"`
2526
}
2627

2728
type CredentialAttribute struct {

credential_exchange.go

Lines changed: 30 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ type CredentialProposal struct {
6969
SchemaIssuerDID string `json:"schema_issuer_did"`
7070
SchemaVersion string `json:"schema_version"`
7171
Comment string `json:"comment"`
72-
Credential CredentialPreview `json:"credential_proposal"`
72+
CredentialPreview CredentialPreview `json:"credential_proposal"`
7373
}
7474

7575
type CredentialRequest struct {
@@ -123,21 +123,12 @@ type Attribute struct {
123123
Value string `json:"value"`
124124
}
125125

126-
func (c *Client) SendCredentialExchangeOffer(offer CredentialOfferRequest) (CredentialExchange, error) {
127-
var credentialExchangeRecord CredentialExchange
128-
err := c.post(fmt.Sprintf("%s/issue-credential/send-offer", c.ACApyURL), nil, offer, &credentialExchangeRecord)
129-
if err != nil {
130-
return CredentialExchange{}, err
131-
}
132-
return credentialExchangeRecord, nil
133-
}
134-
135126
type CredentialProposalRequest struct {
136127
CredentialDefinitionID string `json:"cred_def_id"`
137128
ConnectionID string `json:"connection_id"`
138129
IssuerDID string `json:"issuer_did"`
139130
Comment string `json:"comment"`
140-
CredentialProposal CredentialPreview `json:"credential_proposal"`
131+
CredentialPreview CredentialPreview `json:"credential_proposal"`
141132
SchemaName string `json:"schema_name"`
142133
SchemaVersion string `json:"schema_version"`
143134
SchemaID string `json:"schema_id"`
@@ -146,28 +137,22 @@ type CredentialProposalRequest struct {
146137
AutoRemove bool `json:"auto_remove"`
147138
}
148139

149-
type CredentialProposalResponse struct {
150-
CredentialExchangeID string `json:"credential_exchange_id"`
151-
ConnectionID string `json:"connection_id"`
152-
ThreadID string `json:"thread_id"`
153-
State string `json:"state"`
154-
Initiator string `json:"initiator"`
155-
Role string `json:"role"`
156-
CredentialProposalMap CredentialProposal `json:"credential_proposal_dict"`
157-
CreatedAt string `json:"created_at"`
158-
UpdatedAt string `json:"updated_at"`
159-
Trace bool `json:"trace"`
160-
AutoIssue bool `json:"auto_issue"`
161-
AutoRemove bool `json:"auto_remove"`
140+
func (c *Client) SendCredentialProposal(proposal CredentialProposalRequest) (CredentialExchange, error) {
141+
var credentialExchange CredentialExchange
142+
err := c.post(fmt.Sprintf("%s/issue-credential/send-proposal", c.ACApyURL), nil, proposal, &credentialExchange)
143+
if err != nil {
144+
return CredentialExchange{}, err
145+
}
146+
return credentialExchange, nil
162147
}
163148

164-
func (c *Client) SendCredentialExchangeProposal(proposal CredentialProposalRequest) (CredentialProposalResponse, error) {
165-
var credentialProposalResponse CredentialProposalResponse
166-
err := c.post(fmt.Sprintf("%s/issue-credential/send-proposal", c.ACApyURL), nil, proposal, &credentialProposalResponse)
149+
func (c *Client) SendCredentialOffer(offer CredentialOfferRequest) (CredentialExchange, error) {
150+
var credentialExchangeRecord CredentialExchange
151+
err := c.post(fmt.Sprintf("%s/issue-credential/send-offer", c.ACApyURL), nil, offer, &credentialExchangeRecord)
167152
if err != nil {
168-
return CredentialProposalResponse{}, err
153+
return CredentialExchange{}, err
169154
}
170-
return credentialProposalResponse, nil
155+
return credentialExchangeRecord, nil
171156
}
172157

173158
type QueryCredentialExchangeParams struct {
@@ -204,17 +189,16 @@ func (c *Client) GetCredentialExchange(credentialExchangeID string) (CredentialE
204189
}
205190

206191
type CredentialCreateRequest struct {
207-
CredentialDefinitionID string `json:"cred_def_id"`
208-
// ConnectionID string `json:"connection_id"`
209-
IssuerDID string `json:"issuer_did"`
210-
Comment string `json:"comment"`
211-
CredentialProposal CredentialPreview `json:"credential_proposal"`
212-
SchemaName string `json:"schema_name"`
213-
SchemaVersion string `json:"schema_version"`
214-
SchemaID string `json:"schema_id"`
215-
SchemaIssuerDID string `json:"schema_issuer_did"`
216-
Trace bool `json:"trace"`
217-
AutoRemove bool `json:"auto_remove"`
192+
CredentialDefinitionID string `json:"cred_def_id"`
193+
IssuerDID string `json:"issuer_did"`
194+
Comment string `json:"comment"`
195+
CredentialPreview CredentialPreview `json:"credential_proposal"`
196+
SchemaName string `json:"schema_name"`
197+
SchemaVersion string `json:"schema_version"`
198+
SchemaID string `json:"schema_id"`
199+
SchemaIssuerDID string `json:"schema_issuer_did"`
200+
Trace bool `json:"trace"`
201+
AutoRemove bool `json:"auto_remove"`
218202
}
219203

220204
func (c *Client) CreateCredentialExchange(request CredentialCreateRequest) (CredentialExchange, error) {
@@ -228,7 +212,7 @@ func (c *Client) CreateCredentialExchange(request CredentialCreateRequest) (Cred
228212

229213
type CredentialSendRequest CredentialProposalRequest
230214

231-
func (c *Client) SendCredentialExchange(request CredentialSendRequest) (CredentialExchange, error) {
215+
func (c *Client) SendCredential(request CredentialSendRequest) (CredentialExchange, error) {
232216
var credentialExchange CredentialExchange
233217
err := c.post(fmt.Sprintf("%s/issue-credential/send", c.ACApyURL), nil, request, &credentialExchange)
234218
if err != nil {
@@ -237,7 +221,7 @@ func (c *Client) SendCredentialExchange(request CredentialSendRequest) (Credenti
237221
return credentialExchange, nil
238222
}
239223

240-
func (c *Client) SendCredentialExchangeOfferByID(credentialExchangeID string) (CredentialExchange, error) {
224+
func (c *Client) SendCredentialOfferByID(credentialExchangeID string) (CredentialExchange, error) {
241225
var credentialExchange CredentialExchange
242226
err := c.post(fmt.Sprintf("%s/issue-credential/records/%s/send-offer", c.ACApyURL, credentialExchangeID), nil, nil, &credentialExchange)
243227
if err != nil {
@@ -246,7 +230,7 @@ func (c *Client) SendCredentialExchangeOfferByID(credentialExchangeID string) (C
246230
return credentialExchange, nil
247231
}
248232

249-
func (c *Client) SendCredentialExchangeRequestByID(credentialExchangeID string) (CredentialExchange, error) {
233+
func (c *Client) SendCredentialRequestByID(credentialExchangeID string) (CredentialExchange, error) {
250234
var credentialExchange CredentialExchange
251235
err := c.post(fmt.Sprintf("%s/issue-credential/records/%s/send-request", c.ACApyURL, credentialExchangeID), nil, nil, &credentialExchange)
252236
if err != nil {
@@ -255,7 +239,7 @@ func (c *Client) SendCredentialExchangeRequestByID(credentialExchangeID string)
255239
return credentialExchange, nil
256240
}
257241

258-
func (c *Client) SendCredentialToHolder(credentialExchangeID string, comment string) (CredentialExchange, error) {
242+
func (c *Client) IssueCredentialByID(credentialExchangeID string, comment string) (CredentialExchange, error) {
259243
var credentialExchange CredentialExchange
260244
var body = struct {
261245
Comment string `json:"comment"`
@@ -269,7 +253,8 @@ func (c *Client) SendCredentialToHolder(credentialExchangeID string, comment str
269253
return credentialExchange, nil
270254
}
271255

272-
func (c *Client) StoreReceivedCredential(credentialExchangeID string, credentialID string) (CredentialExchange, error) {
256+
// credentialID is optional: https://github.com/hyperledger/aries-cloudagent-python/issues/594#issuecomment-656113125
257+
func (c *Client) StoreCredentialByID(credentialExchangeID string, credentialID string) (CredentialExchange, error) {
273258
var credentialExchange CredentialExchange
274259
var body = struct {
275260
CredentialID string `json:"credential_id"`

examples/issue_credential/main.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -140,13 +140,13 @@ func (app *App) ReadCommands() {
140140
AutoRemove: false,
141141
AutoIssue: false,
142142
}
143-
exchangeOffer, _ := app.client.SendCredentialExchangeOffer(offer)
143+
exchangeOffer, _ := app.client.SendCredentialOffer(offer)
144144
fmt.Printf("Credential Exchange ID: %s\n", exchangeOffer.CredentialExchangeID)
145145
case "6":
146146
fmt.Printf("Credential Exchange ID: ")
147147
scanner.Scan()
148148
credentialExchangeID := scanner.Text()
149-
_, _ = app.client.SendCredentialExchangeRequestByID(credentialExchangeID)
149+
_, _ = app.client.SendCredentialRequestByID(credentialExchangeID)
150150
case "7":
151151
fmt.Printf("Credential Exchange ID: ")
152152
scanner.Scan()
@@ -156,7 +156,7 @@ func (app *App) ReadCommands() {
156156
scanner.Scan()
157157
comment := scanner.Text()
158158

159-
_, _ = app.client.SendCredentialToHolder(credentialExchangeID, comment)
159+
_, _ = app.client.IssueCredentialByID(credentialExchangeID, comment)
160160
case "8":
161161
fmt.Printf("Credential Exchange ID: ")
162162
scanner.Scan()
@@ -166,7 +166,7 @@ func (app *App) ReadCommands() {
166166
scanner.Scan()
167167
credentialID := scanner.Text()
168168

169-
_, _ = app.client.StoreReceivedCredential(credentialExchangeID, credentialID)
169+
_, _ = app.client.StoreCredentialByID(credentialExchangeID, credentialID)
170170
case "9":
171171
credentials, _ := app.client.GetCredentials(10, 0, "")
172172
for _, cred := range credentials {

0 commit comments

Comments
 (0)