/
types.go
43 lines (37 loc) · 950 Bytes
/
types.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
package community
import (
"fmt"
"time"
)
// Defines module constants
const (
RouterKey = ModuleName
QuerierRoute = ModuleName
StoreKey = ModuleName
)
// Community represents the state of a community on TruStory
type Community struct {
ID string `json:"id"`
Name string `json:"name"`
Description string `json:"description,omitempty"`
CreatedTime time.Time `json:"created_time,omitempty"`
}
// Communities is a slice of communites
type Communities []Community
// NewCommunity creates a new Community
func NewCommunity(id, name, description string, createdTime time.Time) Community {
return Community{
ID: id,
Name: name,
Description: description,
CreatedTime: createdTime,
}
}
func (c Community) String() string {
return fmt.Sprintf(`Community:
ID: %s
Name: %s
Description: %s
CreatedTime: %s`,
c.ID, c.Name, c.Description, c.CreatedTime.String())
}