-
Notifications
You must be signed in to change notification settings - Fork 0
/
convert.go
63 lines (56 loc) · 1.25 KB
/
convert.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
package app
import (
"github.com/DanielTitkov/teams-bot-example/internal/domain"
"github.com/DanielTitkov/teams-bot-example/pkg/mesga"
)
func mesgaToDomainUser(u mesga.User) domain.User {
return domain.User{
Meta: domain.UserMeta{
Teams: domain.UserMessagerData{
ID: u.Teams.ID,
Username: u.Teams.Username,
},
},
}
}
func mesgaToDomainDialog(d mesga.Dialog) domain.Dialog {
return domain.Dialog{
Meta: domain.DialogMeta{
Teams: d.Teams,
},
}
}
func mesgaToDomainMessage(m mesga.Message) domain.Message {
return domain.Message{
Text: m.Text,
PayloadType: m.Payload.Type,
PayloadValue: m.Payload.Value,
Attachment: m.Attachment,
Direction: m.Direction,
Proactive: m.Proactive,
}
}
func domainToMesgaUser(u domain.User) mesga.User {
return mesga.User{
Teams: mesga.UserMessagerData{
ID: u.Meta.Teams.ID,
},
}
}
func domainToMesgaDialog(d domain.Dialog) mesga.Dialog {
return mesga.Dialog{
Teams: d.Meta.Teams,
}
}
func domainToMesgaMessage(m domain.Message) mesga.Message {
return mesga.Message{
Text: m.Text,
Attachment: m.Attachment,
Direction: m.Direction,
Proactive: m.Proactive,
Payload: mesga.MessagePayload{
Type: m.PayloadType,
Value: m.PayloadValue,
},
}
}