-
Notifications
You must be signed in to change notification settings - Fork 5
/
stringattribute.go
49 lines (41 loc) · 1.39 KB
/
stringattribute.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
package attribute
import (
"github.com/getyoti/yoti-go-sdk/anchor"
"github.com/getyoti/yoti-go-sdk/yotiprotoattr"
)
// StringAttribute is a Yoti attribute which returns a string as its value
type StringAttribute struct {
*yotiprotoattr.Attribute
value string
anchors []*anchor.Anchor
}
// NewString creates a new String attribute
func NewString(a *yotiprotoattr.Attribute) *StringAttribute {
parsedAnchors := anchor.ParseAnchors(a.Anchors)
return &StringAttribute{
Attribute: &yotiprotoattr.Attribute{
Name: a.Name,
ContentType: a.ContentType,
},
value: string(a.Value),
anchors: parsedAnchors,
}
}
// Value returns the value of the StringAttribute as a string
func (a *StringAttribute) Value() string {
return a.value
}
// Anchors are the metadata associated with an attribute. They describe
// how an attribute has been provided to Yoti (SOURCE Anchor) and how
// it has been verified (VERIFIER Anchor).
func (a *StringAttribute) Anchors() []*anchor.Anchor {
return a.anchors
}
// Sources returns the anchors which identify how and when an attribute value was acquired.
func (a *StringAttribute) Sources() []*anchor.Anchor {
return anchor.GetSources(a.anchors)
}
// Verifiers returns the anchors which identify how and when an attribute value was verified by another provider.
func (a *StringAttribute) Verifiers() []*anchor.Anchor {
return anchor.GetVerifiers(a.anchors)
}