Skip to content

Commit

Permalink
update: StaticPickerOption
Browse files Browse the repository at this point in the history
  • Loading branch information
chyroc committed Apr 30, 2024
1 parent 02c62fe commit 2464e50
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 8 deletions.
2 changes: 2 additions & 0 deletions api_auth_tenant_access_token_get.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import (
"time"
)

// GetTenantAccessToken ...
//
// https://open.feishu.cn/document/ukTMukTMukTM/ukDNz4SO0MjL5QzM/auth-v3/auth/tenant_access_token_internal
// https://open.feishu.cn/document/ukTMukTMukTM/ukDNz4SO0MjL5QzM/auth-v3/auth/tenant_access_token
func (r *AuthService) GetTenantAccessToken(ctx context.Context) (*TokenExpire, *Response, error) {
Expand Down
53 changes: 45 additions & 8 deletions card/v2/component_interactive_static_picker.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,10 @@ package card
import "encoding/json"

// StaticPicker 创建下拉选择-单选组件
func StaticPicker(name string, options ...string) *ComponentStaticPicker {
opts := make([]*StaticPickerOption, 0)
for _, option := range options {
opts = append(opts, &StaticPickerOption{
Text: Text(option),
})
}
func StaticPicker(name string, options ...*StaticPickerOption) *ComponentStaticPicker {
return &ComponentStaticPicker{
Name: name,
Options: opts,
Options: options,
}
}

Expand Down Expand Up @@ -93,9 +87,19 @@ type ComponentStaticPicker struct {
Confirm *ObjectConfirm `json:"confirm,omitempty"`
}

//go:generate generate_set_attrs -type=StaticPickerOption
//go:generate generate_to_map -type=StaticPickerOption
type StaticPickerOption struct {
// 选项的名称。
Text *ObjectText `json:"text,omitempty"`

// 添加图标作为文本前缀图标。支持自定义或使用图标库中的图标。
Icon *ObjectIcon `json:"icon,omitempty"`

// 自定义选项回调值。当用户点击交互组件的选项后,会将 value 的值返回给接收回调数据的服务器。后续你可以通过服务器接收的 value 值进行业务处理。
//
// 该字段值仅支持 key-value 形式的 JSON 结构,且 key 为 String 类型。示例值:
Value map[string]any `json:"value,omitempty"`
}

// MarshalJSON ...
Expand Down Expand Up @@ -227,3 +231,36 @@ func (r *ComponentStaticPicker) toMap() map[string]interface{} {
}
return res
}

// SetText set StaticPickerOption.Text attribute
func (r *StaticPickerOption) SetText(val *ObjectText) *StaticPickerOption {
r.Text = val
return r
}

// SetIcon set StaticPickerOption.Icon attribute
func (r *StaticPickerOption) SetIcon(val *ObjectIcon) *StaticPickerOption {
r.Icon = val
return r
}

// SetValue set StaticPickerOption.Value attribute
func (r *StaticPickerOption) SetValue(val map[string]any) *StaticPickerOption {
r.Value = val
return r
}

// toMap conv StaticPickerOption to map
func (r *StaticPickerOption) toMap() map[string]interface{} {
res := make(map[string]interface{}, 3)
if r.Text != nil {
res["text"] = r.Text
}
if r.Icon != nil {
res["icon"] = r.Icon
}
if len(r.Value) != 0 {
res["value"] = r.Value
}
return res
}

0 comments on commit 2464e50

Please sign in to comment.