forked from hyperledger-archives/aries-framework-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
event.go
64 lines (52 loc) · 1.45 KB
/
event.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/*
Copyright SecureKey Technologies Inc. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/
package didexchange
// Event properties related api. This can be used to cast Generic event properties to DID Exchange specific props.
type Event interface {
// connection ID
ConnectionID() string
// invitation ID
InvitationID() string
}
// didExchangeEvent implements didexchange.Event interface.
type didExchangeEvent struct {
connectionID string
invitationID string
}
// ConnectionID returns DIDExchange connectionID.
func (ex *didExchangeEvent) ConnectionID() string {
return ex.connectionID
}
// InvitationID returns DIDExchange invitationID.
func (ex *didExchangeEvent) InvitationID() string {
return ex.invitationID
}
// All implements EventProperties interface.
func (ex *didExchangeEvent) All() map[string]interface{} {
return map[string]interface{}{
"connectionID": ex.ConnectionID(),
"invitationID": ex.InvitationID(),
}
}
// didExchangeEvent for sending events with processing error.
type didExchangeEventError struct {
didExchangeEvent
err error
}
// Error implements error interface.
func (ex *didExchangeEventError) Error() string {
if ex.err != nil {
return ex.err.Error()
}
return ""
}
// All implements EventProperties interface.
func (ex *didExchangeEventError) All() map[string]interface{} {
return map[string]interface{}{
"connectionID": ex.ConnectionID(),
"invitationID": ex.InvitationID(),
"error": ex.Error(),
}
}