Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 29 additions & 14 deletions card/card_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ import (
"net/http"
"testing"

"github.com/larksuite/oapi-sdk-go/v3/core"
"github.com/larksuite/oapi-sdk-go/v3/event"
larkcore "github.com/larksuite/oapi-sdk-go/v3/core"
larkevent "github.com/larksuite/oapi-sdk-go/v3/event"
)

func TestVerifyUrlOk(t *testing.T) {
Expand Down Expand Up @@ -71,10 +71,15 @@ func mockEventReq(token string) *larkevent.EventReq {
TenantKey: "d32004232",
Token: token,
Action: &struct {
Value map[string]interface{} `json:"value"`
Tag string `json:"tag"`
Option string `json:"option"`
Timezone string `json:"timezone"`
Value map[string]interface{} `json:"value"`
Tag string `json:"tag"`
Option string `json:"option"`
Timezone string `json:"timezone"`
Name string `json:"name"`
FormValue map[string]interface{} `json:"form_value"`
InputValue string `json:"input_value"`
Options []string `json:"options"`
Checked bool `json:"checked"`
}{
Value: value,
Tag: "button",
Expand Down Expand Up @@ -219,10 +224,15 @@ func mockCardAction() *CardAction {
OpenMessageID: "om_abcdefg1234567890",
TenantKey: "d32004232",
Action: &struct {
Value map[string]interface{} `json:"value"`
Tag string `json:"tag"`
Option string `json:"option"`
Timezone string `json:"timezone"`
Value map[string]interface{} `json:"value"`
Tag string `json:"tag"`
Option string `json:"option"`
Timezone string `json:"timezone"`
Name string `json:"name"`
FormValue map[string]interface{} `json:"form_value"`
InputValue string `json:"input_value"`
Options []string `json:"options"`
Checked bool `json:"checked"`
}{
Value: value,
Tag: "button",
Expand All @@ -245,10 +255,15 @@ func TestDoHandleResultCardOk(t *testing.T) {
OpenMessageID: "om_abcdefg1234567890",
TenantKey: "d32004232",
Action: &struct {
Value map[string]interface{} `json:"value"`
Tag string `json:"tag"`
Option string `json:"option"`
Timezone string `json:"timezone"`
Value map[string]interface{} `json:"value"`
Tag string `json:"tag"`
Option string `json:"option"`
Timezone string `json:"timezone"`
Name string `json:"name"`
FormValue map[string]interface{} `json:"form_value"`
InputValue string `json:"input_value"`
Options []string `json:"options"`
Checked bool `json:"checked"`
}{
Value: value,
Tag: "button",
Expand Down
19 changes: 12 additions & 7 deletions core/httpserverext/httpserverext_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ import (
"net/http"
"testing"

"github.com/larksuite/oapi-sdk-go/v3/card"
"github.com/larksuite/oapi-sdk-go/v3/core"
larkcard "github.com/larksuite/oapi-sdk-go/v3/card"
larkcore "github.com/larksuite/oapi-sdk-go/v3/core"
"github.com/larksuite/oapi-sdk-go/v3/event/dispatcher"
"github.com/larksuite/oapi-sdk-go/v3/service/im/v1"
larkim "github.com/larksuite/oapi-sdk-go/v3/service/im/v1"
)

func TestStartHttpServer(t *testing.T) {
Expand Down Expand Up @@ -66,10 +66,15 @@ func mockRequest() *http.Request {
TenantKey: "d32004232",
Token: token,
Action: &struct {
Value map[string]interface{} `json:"value"`
Tag string `json:"tag"`
Option string `json:"option"`
Timezone string `json:"timezone"`
Value map[string]interface{} `json:"value"`
Tag string `json:"tag"`
Option string `json:"option"`
Timezone string `json:"timezone"`
Name string `json:"name"`
FormValue map[string]interface{} `json:"form_value"`
InputValue string `json:"input_value"`
Options []string `json:"options"`
Checked bool `json:"checked"`
}{
Value: value,
Tag: "button",
Expand Down
9 changes: 9 additions & 0 deletions core/httptransport.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,15 @@ func doSend(ctx context.Context, rawRequest *http.Request, httpClient HttpClient
}

func Request(ctx context.Context, req *ApiReq, config *Config, options ...RequestOptionFunc) (*ApiResp, error) {
if config == nil {
return nil, &IllegalParamError{msg: "config is nil"}
}
NewHttpClient(config)
NewSerialization(config)
if config.Logger == nil {
NewLogger(config)
}

option := &RequestOption{}
for _, optionFunc := range options {
optionFunc(option)
Expand Down
3 changes: 3 additions & 0 deletions core/reqtranslator.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,9 @@ func (translator *ReqTranslator) payload(body interface{}, serializable Serializ
if body == nil {
return contentType, nil, nil
}
if serializable == nil {
serializable = &DefaultSerialization{}
}
bs, err := serializable.Serialize(body)
return contentType, bs, err
}
Expand Down
12 changes: 6 additions & 6 deletions service/ext/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ type AuthenAccessTokenReqBody struct {
}

type AuthenAccessTokenReqBodyBuilder struct {
grantType string `json:"grant_type,omitempty"`
code string `json:"code,omitempty"`
grantType string
code string
}

func NewAuthenAccessTokenReqBodyBuilder() *AuthenAccessTokenReqBodyBuilder {
Expand Down Expand Up @@ -124,8 +124,8 @@ type RefreshAuthenAccessTokenReqBody struct {
}

type RefreshAuthenAccessTokenReqBodyBuilder struct {
grantType string `json:"grant_type,omitempty"`
refreshToken string `json:"refresh_token,omitempty"`
grantType string
refreshToken string
}

func NewRefreshAuthenAccessTokenReqBodyBuilder() *RefreshAuthenAccessTokenReqBodyBuilder {
Expand Down Expand Up @@ -263,8 +263,8 @@ type CreateFileReqBody struct {
}

type CreateFileReqBodyBuilder struct {
title string `json:"title,omitempty"`
type_ string `json:"type,omitempty"`
title string
type_ string
}

func NewCreateFileReqBodyBuilder() *CreateFileReqBodyBuilder {
Expand Down
1 change: 0 additions & 1 deletion service/im/v1/ext_model.go
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,6 @@ func (t *MessageText) AtUser(userId, name string) *MessageText {
t.builder.WriteString(name)
t.builder.WriteString("</at>")
return t
return t
}

func (t *MessageText) AtAll() *MessageText {
Expand Down