forked from sonda2208/gpass
-
Notifications
You must be signed in to change notification settings - Fork 0
/
applink.go
99 lines (79 loc) · 2.05 KB
/
applink.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
92
93
94
95
96
97
98
99
package gpass
import "github.com/sonda2208/gpass/walletobjects"
type AppTarget struct {
TargetURI *URI
}
func (t AppTarget) toWO() *walletobjects.AppLinkDataAppLinkInfoAppTarget {
return &walletobjects.AppLinkDataAppLinkInfoAppTarget{
TargetUri: t.TargetURI.toWO(),
}
}
func woToAppTarget(t *walletobjects.AppLinkDataAppLinkInfoAppTarget) *AppTarget {
if t == nil {
return nil
}
return &AppTarget{
TargetURI: woToUri(t.TargetUri),
}
}
type AppLinkInfo struct {
AppLogoImage *Image
Title *LocalizedString
Description *LocalizedString
AppTarget *AppTarget
}
func (i AppLinkInfo) toWO() *walletobjects.AppLinkDataAppLinkInfo {
res := walletobjects.AppLinkDataAppLinkInfo{}
if i.AppLogoImage != nil {
res.AppLogoImage = i.AppLogoImage.toWO()
}
if i.AppTarget != nil {
res.AppTarget = i.AppTarget.toWO()
}
if i.Description != nil {
res.Description = i.Description.toWO()
}
if i.Title != nil {
res.Title = i.Title.toWO()
}
return &res
}
func woToAppLinkInfo(i *walletobjects.AppLinkDataAppLinkInfo) *AppLinkInfo {
if i == nil {
return nil
}
return &AppLinkInfo{
AppLogoImage: woToImage(i.AppLogoImage),
Title: woToLocalizedString(i.Title),
Description: woToLocalizedString(i.Description),
AppTarget: woToAppTarget(i.AppTarget),
}
}
type AppLinkData struct {
AndroidAppLinkInfo *AppLinkInfo
IOSAppLinkInfo *AppLinkInfo
WebAppLinkInfo *AppLinkInfo
}
func (d AppLinkData) toWo() *walletobjects.AppLinkData {
res := walletobjects.AppLinkData{}
if d.AndroidAppLinkInfo != nil {
res.AndroidAppLinkInfo = d.AndroidAppLinkInfo.toWO()
}
if d.IOSAppLinkInfo != nil {
res.IosAppLinkInfo = d.IOSAppLinkInfo.toWO()
}
if d.WebAppLinkInfo != nil {
res.WebAppLinkInfo = d.WebAppLinkInfo.toWO()
}
return &res
}
func woToAppLinkData(d *walletobjects.AppLinkData) *AppLinkData {
if d == nil {
return nil
}
return &AppLinkData{
AndroidAppLinkInfo: woToAppLinkInfo(d.AndroidAppLinkInfo),
IOSAppLinkInfo: woToAppLinkInfo(d.IosAppLinkInfo),
WebAppLinkInfo: woToAppLinkInfo(d.WebAppLinkInfo),
}
}