Skip to content

Commit

Permalink
Merge pull request #59 from kintone-labs/v0.6.0
Browse files Browse the repository at this point in the history
SSR-3727 v0.6.0 Release
  • Loading branch information
nmanhit committed Aug 24, 2023
2 parents 11fd1b0 + 2853b28 commit 9a7814c
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 40 deletions.
85 changes: 45 additions & 40 deletions app.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (

const (
NAME = "go-kintone"
VERSION = "0.4.2"
VERSION = "0.6.0"
DEFAULT_TIMEOUT = time.Second * 600 // Default value for App.Timeout
)

Expand Down Expand Up @@ -982,49 +982,51 @@ func (app *App) DeleteComment(recordId uint64, commentId uint64) error {

// FieldInfo is the meta data structure of a field.
type FieldInfo struct {
Label string `json:"label"` // Label string
Code string `json:"code"` // Unique field code
Type string `json:"type"` // Field type. One of FT_* constant.
NoLabel bool `json:"noLabel"` // true to hide the label
Required bool `json:"required"` // true if this field must be filled
Unique bool `json:"unique"` // true if field values must be unique
MaxValue interface{} `json:"maxValue"` // nil or numeric string
MinValue interface{} `json:"minValue"` // nil or numeric string
MaxLength interface{} `json:"maxLength"` // nil or numeric string
MinLength interface{} `json:"minLength"` // nil or numeric string
Default interface{} `json:"defaultValue"` // anything
DefaultTime interface{} `json:"defaultExpression"` // nil or "NOW"
Options []string `json:"options"` // list of selectable values
Expression string `json:"expression"` // to calculate values
Separator bool `json:"digit"` // true to use thousand separator
Medium string `json:"protocol"` // "WEB", "CALL", or "MAIL"
Format string `json:"format"` // "NUMBER", "NUMBER_DIGIT", "DATETIME", "DATE", "TIME", "HOUR_MINUTE", "DAY_HOUR_MINUTE"
Fields []FieldInfo `json:"fields"` // Field list of this subtable
Index int `json:"index"`
Label string `json:"label"` // Label string
Code string `json:"code"` // Unique field code
Type string `json:"type"` // Field type. One of FT_* constant.
NoLabel bool `json:"noLabel"` // true to hide the label
Required bool `json:"required"` // true if this field must be filled
Unique bool `json:"unique"` // true if field values must be unique
MaxValue interface{} `json:"maxValue"` // nil or numeric string
MinValue interface{} `json:"minValue"` // nil or numeric string
MaxLength interface{} `json:"maxLength"` // nil or numeric string
MinLength interface{} `json:"minLength"` // nil or numeric string
Default interface{} `json:"defaultValue"` // anything
DefaultTime interface{} `json:"defaultExpression"` // nil or "NOW"
Options []string `json:"options"` // list of selectable values
Expression string `json:"expression"` // to calculate values
Separator bool `json:"digit"` // true to use thousand separator
Medium string `json:"protocol"` // "WEB", "CALL", or "MAIL"
Format string `json:"format"` // "NUMBER", "NUMBER_DIGIT", "DATETIME", "DATE", "TIME", "HOUR_MINUTE", "DAY_HOUR_MINUTE"
Fields []FieldInfo `json:"fields"` // Field list of this subtable
Index int `json:"index"`
Lookup *map[string]interface{} `json:"lookup,omitempty"` // lookup
}

// Work around code to handle "true"/"false" strings as booleans...
func (fi *FieldInfo) UnmarshalJSON(data []byte) error {
var t struct {
Label string `json:"label"`
Code string `json:"code"`
Type string `json:"type"`
NoLabel string `json:"noLabel"`
Required string `json:"required"`
Unique string `json:"unique"`
MaxValue interface{} `json:"maxValue"`
MinValue interface{} `json:"minValue"`
MaxLength interface{} `json:"maxLength"`
MinLength interface{} `json:"minLength"`
Default interface{} `json:"defaultValue"`
DefaultTime interface{} `json:"defaultExpression"`
Options []string `json:"options"`
Expression string `json:"expression"`
Separator string `json:"digit"`
Medium string `json:"protocol"`
Format string `json:"format"`
Fields []FieldInfo `json:"fields"`
Index int `json:"index"`
Label string `json:"label"`
Code string `json:"code"`
Type string `json:"type"`
NoLabel string `json:"noLabel"`
Required string `json:"required"`
Unique string `json:"unique"`
MaxValue interface{} `json:"maxValue"`
MinValue interface{} `json:"minValue"`
MaxLength interface{} `json:"maxLength"`
MinLength interface{} `json:"minLength"`
Default interface{} `json:"defaultValue"`
DefaultTime interface{} `json:"defaultExpression"`
Options []string `json:"options"`
Expression string `json:"expression"`
Separator string `json:"digit"`
Medium string `json:"protocol"`
Format string `json:"format"`
Fields []FieldInfo `json:"fields"`
Index int `json:"index"`
Lookup *map[string]interface{} `json:"lookup,omitempty"`
}
err := json.Unmarshal(data, &t)
if err != nil {
Expand All @@ -1038,7 +1040,7 @@ func (fi *FieldInfo) UnmarshalJSON(data []byte) error {
t.MaxValue, t.MinValue, t.MaxLength, t.MinLength,
t.Default, t.DefaultTime, t.Options, t.Expression,
(t.Separator == "true"),
t.Medium, t.Format, t.Fields, t.Index,
t.Medium, t.Format, t.Fields, t.Index, t.Lookup,
}
return nil
}
Expand Down Expand Up @@ -1098,6 +1100,9 @@ func decodeFieldInfo(t AppFormFields, ret map[string]*FieldInfo) {
sb = append(sb, *ret[z])
}
fi.Fields = sb
case "lookup":
result, _ := (w).(map[string]interface{})
fi.Lookup = &result
default:
break
}
Expand Down
20 changes: 20 additions & 0 deletions app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -496,3 +496,23 @@ func TestGetProcess(t *testing.T) {
t.Error("TestGetProcess failed: ", err)
}
}

func TestLookupFieldInFieldInfo(t *testing.T) {
app := newApp()
countLookup := 0
fi, err := app.Fields()
if err != nil {
t.Error("Fields failed", err)
}
for _, f := range fi {
if f.Lookup != nil {countLookup++}
}

if countLookup > 0 {
fmt.Printf("\nApp have %v Lookup field\n", countLookup);
}

if countLookup == 0 {
fmt.Printf("\nApp have no Lookup field\n");
}
}

0 comments on commit 9a7814c

Please sign in to comment.