Skip to content

Commit

Permalink
Completed TODOs
Browse files Browse the repository at this point in the history
  • Loading branch information
mymmrac committed Oct 24, 2021
1 parent 8c06fc0 commit ddf4f26
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
17 changes: 15 additions & 2 deletions api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"fmt"
"io"
"mime/multipart"
"reflect"
"strings"

jsoniter "github.com/json-iterator/go"
Expand Down Expand Up @@ -153,8 +154,7 @@ func (d DefaultConstructor) MultipartRequest(
writer := multipart.NewWriter(data.Buffer)

for field, file := range filesParameters {
// TODO: Check if additional check for nil need here
if file == nil {
if isNil(file) {
continue
}

Expand Down Expand Up @@ -189,3 +189,16 @@ func (d DefaultConstructor) MultipartRequest(
data.ContentType = writer.FormDataContentType()
return data, nil
}

func isNil(i interface{}) bool {
if i == nil {
return true
}

switch reflect.TypeOf(i).Kind() {
case reflect.Chan, reflect.Func, reflect.Interface, reflect.Map, reflect.Ptr, reflect.Slice:
return reflect.ValueOf(i).IsNil()
}

return false
}
2 changes: 0 additions & 2 deletions types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ import (
"github.com/mymmrac/telego/api"
)

// TODO: Check t.Parallel() with -parallel

func TestReplyKeyboardMarkup_ReplyType(t *testing.T) {
assert.Equal(t, MarkupTypeReplyKeyboard, (&ReplyKeyboardMarkup{}).ReplyType())
}
Expand Down

0 comments on commit ddf4f26

Please sign in to comment.