forked from sonda2208/gpass
-
Notifications
You must be signed in to change notification settings - Fork 0
/
uri.go
67 lines (54 loc) · 1.27 KB
/
uri.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
package gpass
import "github.com/sonda2208/gpass/walletobjects"
type URI struct {
ID string
URI string
LocalizedDescription *LocalizedString
}
func (u *URI) toWO() *walletobjects.Uri {
res := walletobjects.Uri{
Id: u.ID,
Kind: "walletobjects#uri",
Uri: u.URI,
}
if u.LocalizedDescription != nil {
res.LocalizedDescription = u.LocalizedDescription.toWO()
}
return &res
}
func listURIToWO(uris []*URI) []*walletobjects.Uri {
res := make([]*walletobjects.Uri, len(uris))
for i, s := range uris {
res[i] = s.toWO()
}
return res
}
func woToUri(u *walletobjects.Uri) *URI {
if u == nil {
return nil
}
return &URI{
ID: u.Id,
URI: u.Uri,
LocalizedDescription: woToLocalizedString(u.LocalizedDescription),
}
}
type ImageUri struct {
LocalizedDescription *LocalizedString
URI string
}
func (iu *ImageUri) toWO() *walletobjects.ImageUri {
return &walletobjects.ImageUri{
Uri: iu.URI,
LocalizedDescription: iu.LocalizedDescription.toWO(),
}
}
func woToImageUri(u *walletobjects.ImageUri) *ImageUri {
if u == nil {
return nil
}
return &ImageUri{
URI: u.Uri,
LocalizedDescription: woToLocalizedString(u.LocalizedDescription),
}
}