forked from hyperledger-archives/aries-framework-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
models.go
91 lines (79 loc) · 3.61 KB
/
models.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
/*
Copyright SecureKey Technologies Inc. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/
package introduce
import "github.com/Universal-Health-Chain/aries-framework-go/pkg/didcomm/protocol/decorator"
// Proposal defines proposal request.
type Proposal struct {
Type string `json:"@type,omitempty"`
ID string `json:"@id,omitempty"`
To *To `json:"to,omitempty"`
NWise bool `json:"nwise,omitempty"`
Thread *decorator.Thread `json:"~thread,omitempty"`
Timing *decorator.Timing `json:"~timing,omitempty"`
Goal string `json:"goal,omitempty"`
GoalCode string `json:"goal-code,omitempty"`
}
// To introducee descriptor keeps information about the introduction
// e.g introducer wants to introduce Bot to introducee { "name": "Bob" }.
type To struct {
Name string `json:"name,omitempty"`
Description string `json:"description,omitempty"`
DescriptionL10N DescriptionL10N `json:"description~l10n,omitempty"`
Where string `json:"where,omitempty"`
ImgAttach ImgAttach `json:"img~attach,omitempty"`
Proposed bool `json:"proposed,omitempty"`
}
// DescriptionL10N may contain locale field and key->val pair for translation
// e.g { "locale": "en", "es": "Donde se toma el MRI; no en el centro"},
// where locale field tells that field Description form To struct has en translation.
type DescriptionL10N map[string]string
// Locale returns locale for the specified description (To.Description).
func (d DescriptionL10N) Locale() string {
if d == nil {
return ""
}
// TODO: clarify whether it should be default locale e.g "en" or empty string
return d["locale"]
}
// ImgAttach represent information about the image.
type ImgAttach struct {
Description string `json:"description,omitempty"`
MimeType string `json:"mime-type,omitempty"`
Filename string `json:"filename,omitempty"`
Content Content `json:"content,omitempty"`
}
// Content keeps image data.
type Content struct {
Link string `json:"link,omitempty"`
ByteCount int `json:"byte_count,omitempty"`
Sha256 string `json:"sha256,omitempty"`
}
// PleaseIntroduceTo includes all field from To structure
// also it has Discovered the field which should be provided by help-me-discover protocol.
type PleaseIntroduceTo struct {
// nolint: staticcheck
To `json:",squash"`
// Discovered Discovered `json:"discovered,omitempty"`
}
// Request is not part of any state machine, it can be sent at any time,
// and when it is received, the recipient can choose whether or not to honor it in their own way
// TODO: need to clarify about decorator ~please_ack and problem_report
// should Request contain those fields? What type it should be for each field?
type Request struct {
Type string `json:"@type,omitempty"`
ID string `json:"@id,omitempty"`
PleaseIntroduceTo *PleaseIntroduceTo `json:"please_introduce_to,omitempty"`
NWise bool `json:"nwise,omitempty"`
Timing *decorator.Timing `json:"~timing,omitempty"`
}
// Response message that introducee usually sends in response to an introduction proposal.
type Response struct {
Type string `json:"@type,omitempty"`
ID string `json:"@id,omitempty"`
Thread *decorator.Thread `json:"~thread,omitempty"`
Approve bool `json:"approve,omitempty"`
OOBMessage map[string]interface{} `json:"oob-message,omitempty"`
Attachments []*decorator.Attachment `json:"~attach,omitempty"`
}