-
Notifications
You must be signed in to change notification settings - Fork 0
/
telegram_chat_id.go
44 lines (33 loc) · 890 Bytes
/
telegram_chat_id.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
package entity
import (
"github.com/a-aslani/golang_agency_clean_architecture/internal/support/model/vo"
)
type TelegramChatID struct {
ID vo.TelegramChatIDID `bson:"_id" json:"id"`
ChatID string `bson:"chat_id" json:"chat_id"`
RoleID string `bson:"role_id" json:"role_id"`
}
type TelegramChatIDCreateRequest struct {
ID string `json:"-"`
ChatID string `json:"chat_id"`
RoleID string `json:"role_id"`
}
func (r TelegramChatIDCreateRequest) Validate() error {
// validate the create request here ...
return nil
}
func NewChatID(req TelegramChatIDCreateRequest) (*TelegramChatID, error) {
err := req.Validate()
if err != nil {
return nil, err
}
id, err := vo.NewTelegramChatIDID(req.ID)
if err != nil {
return nil, err
}
var obj TelegramChatID
obj.ID = id
obj.ChatID = req.ChatID
obj.RoleID = req.RoleID
return &obj, nil
}