Skip to content

Commit

Permalink
refactor: motify function name
Browse files Browse the repository at this point in the history
  • Loading branch information
hilaily committed Feb 9, 2021
1 parent c37f809 commit f44359a
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 4 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# larkcard

larkcard use for create a lark/feishu card message body.
larkcard 用来创建 lark/飞书卡片消息的内容

详细文档:https://laily.feishu.cn/docs/doccnwcXRSA5W3Unamx8Hwm3cSI#
8 changes: 5 additions & 3 deletions create.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package larkcard

func Create(config *Config, header *Header, modules ...IModule) *Card {
func New(config *Config, header *Header, modules ...IModule) *Card {
c := &Card{
Header: header,
Config: config,
Expand All @@ -9,7 +9,9 @@ func Create(config *Config, header *Header, modules ...IModule) *Card {
return c
}

func CreateI18n(config *Config, header *Header, modules map[string][]IModule) *Card {
// NewI18n
// Reference https://open.feishu.cn/document/ukTMukTMukTM/uEjNwUjLxYDM14SM2ATN
func NewI18n(config *Config, header *Header, modules map[string][]IModule) *Card {
c := &Card{
Header: header,
Config: config,
Expand All @@ -18,7 +20,7 @@ func CreateI18n(config *Config, header *Header, modules map[string][]IModule) *C
return c
}

func CreateByMD(config *Config, header *Header, mdContent string, href *OURL) *Card {
func NewByMD(config *Config, header *Header, mdContent string, href *OURL) *Card {
c := &Card{
Header: header,
Config: config,
Expand Down
13 changes: 12 additions & 1 deletion create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,19 @@ import (
"testing"
)

func TestCreateHeader(t *testing.T) {
h := NewHeader("my header").SetI18n(map[string]string{
"zh_cn": "中文文本",
"en_us": "English text",
"ja_jp": "日本語文案",
})

h = NewHeader("my header").SetColor(HeaderBlue)
fmt.Println(h)
}

func TestCreateCard(t *testing.T) {
c := Create(
c := New(
nil,
NewHeader("test header").SetColor(HeaderGreen),
NewModContent("[飞书](https://www.feishu.cn)整合即时沟通、日历、音视频会议、云文档、云盘、工作台等功能于一体,成就组织和个人,更高效、更愉悦。", true),
Expand Down

0 comments on commit f44359a

Please sign in to comment.