Skip to content

Commit

Permalink
Release v0.0.12
Browse files Browse the repository at this point in the history
  • Loading branch information
fern-api[bot] committed Apr 25, 2024
1 parent 8c4514b commit f7278c2
Show file tree
Hide file tree
Showing 3 changed files with 139 additions and 8 deletions.
2 changes: 1 addition & 1 deletion core/request_option.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func (r *RequestOptions) cloneHeader() http.Header {
headers := r.HTTPHeader.Clone()
headers.Set("X-Fern-Language", "Go")
headers.Set("X-Fern-SDK-Name", "github.com/FlatFilers/flatfile-go")
headers.Set("X-Fern-SDK-Version", "v0.0.11")
headers.Set("X-Fern-SDK-Version", "v0.0.12")
return headers
}

Expand Down
60 changes: 53 additions & 7 deletions sheets.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,15 @@ type ListSheetsRequest struct {
}

type Property struct {
Type string
String *StringProperty
Number *NumberProperty
Boolean *BooleanProperty
Date *DateProperty
Enum *EnumProperty
Reference *ReferenceProperty
Type string
String *StringProperty
Number *NumberProperty
Boolean *BooleanProperty
Date *DateProperty
Enum *EnumProperty
Reference *ReferenceProperty
StringList *StringListProperty
EnumList *EnumListProperty
}

func NewPropertyFromString(value *StringProperty) *Property {
Expand All @@ -118,6 +120,14 @@ func NewPropertyFromReference(value *ReferenceProperty) *Property {
return &Property{Type: "reference", Reference: value}
}

func NewPropertyFromStringList(value *StringListProperty) *Property {
return &Property{Type: "string-list", StringList: value}
}

func NewPropertyFromEnumList(value *EnumListProperty) *Property {
return &Property{Type: "enum-list", EnumList: value}
}

func (p *Property) UnmarshalJSON(data []byte) error {
var unmarshaler struct {
Type string `json:"type"`
Expand Down Expand Up @@ -163,6 +173,18 @@ func (p *Property) UnmarshalJSON(data []byte) error {
return err
}
p.Reference = value
case "string-list":
value := new(StringListProperty)
if err := json.Unmarshal(data, &value); err != nil {
return err
}
p.StringList = value
case "enum-list":
value := new(EnumListProperty)
if err := json.Unmarshal(data, &value); err != nil {
return err
}
p.EnumList = value
}
return nil
}
Expand Down Expand Up @@ -225,6 +247,24 @@ func (p Property) MarshalJSON() ([]byte, error) {
ReferenceProperty: p.Reference,
}
return json.Marshal(marshaler)
case "string-list":
var marshaler = struct {
Type string `json:"type"`
*StringListProperty
}{
Type: p.Type,
StringListProperty: p.StringList,
}
return json.Marshal(marshaler)
case "enum-list":
var marshaler = struct {
Type string `json:"type"`
*EnumListProperty
}{
Type: p.Type,
EnumListProperty: p.EnumList,
}
return json.Marshal(marshaler)
}
}

Expand All @@ -235,6 +275,8 @@ type PropertyVisitor interface {
VisitDate(*DateProperty) error
VisitEnum(*EnumProperty) error
VisitReference(*ReferenceProperty) error
VisitStringList(*StringListProperty) error
VisitEnumList(*EnumListProperty) error
}

func (p *Property) Accept(visitor PropertyVisitor) error {
Expand All @@ -253,6 +295,10 @@ func (p *Property) Accept(visitor PropertyVisitor) error {
return visitor.VisitEnum(p.Enum)
case "reference":
return visitor.VisitReference(p.Reference)
case "string-list":
return visitor.VisitStringList(p.StringList)
case "enum-list":
return visitor.VisitEnumList(p.EnumList)
}
}

Expand Down
85 changes: 85 additions & 0 deletions types.go
Original file line number Diff line number Diff line change
Expand Up @@ -5581,6 +5581,49 @@ func (d *DateProperty) String() string {
return fmt.Sprintf("%#v", d)
}

// Defines an array of values selected from an enumerated list of options. Matching tooling attempts to resolve incoming data assigment to a valid option. The maximum number of items that can be in this list is `100`.
type EnumListProperty struct {
Key string `json:"key" url:"key"`
// User friendly field name
Label *string `json:"label,omitempty" url:"label,omitempty"`
// A short description of the field. Markdown syntax is supported.
Description *string `json:"description,omitempty" url:"description,omitempty"`
Constraints []*Constraint `json:"constraints,omitempty" url:"constraints,omitempty"`
Readonly *bool `json:"readonly,omitempty" url:"readonly,omitempty"`
Appearance *FieldAppearance `json:"appearance,omitempty" url:"appearance,omitempty"`
// Useful for any contextual metadata regarding the schema. Store any valid json here.
Metadata interface{} `json:"metadata,omitempty" url:"metadata,omitempty"`
// A unique presentation for a field in the UI.
Treatments []string `json:"treatments,omitempty" url:"treatments,omitempty"`
AlternativeNames []string `json:"alternativeNames,omitempty" url:"alternativeNames,omitempty"`
Config *EnumPropertyConfig `json:"config,omitempty" url:"config,omitempty"`

_rawJSON json.RawMessage
}

func (e *EnumListProperty) UnmarshalJSON(data []byte) error {
type unmarshaler EnumListProperty
var value unmarshaler
if err := json.Unmarshal(data, &value); err != nil {
return err
}
*e = EnumListProperty(value)
e._rawJSON = json.RawMessage(data)
return nil
}

func (e *EnumListProperty) String() string {
if len(e._rawJSON) > 0 {
if value, err := core.StringifyJSON(e._rawJSON); err == nil {
return value
}
}
if value, err := core.StringifyJSON(e); err == nil {
return value
}
return fmt.Sprintf("%#v", e)
}

// Defines an enumerated list of options for the user to select from. Matching tooling attempts to resolve incoming data assigment to a valid option. The maximum number of options for this list is `100`. For larger lists, users should use the reference or future `lookup` types.
type EnumProperty struct {
Key string `json:"key" url:"key"`
Expand Down Expand Up @@ -6031,6 +6074,48 @@ func (s StringConfigOptions) Ptr() *StringConfigOptions {
return &s
}

// Defines a property that should be stored and read as an array of strings. Database engines should expect any number of items to be provided here. The maximum number of items that can be in this list is `100`.
type StringListProperty struct {
Key string `json:"key" url:"key"`
// User friendly field name
Label *string `json:"label,omitempty" url:"label,omitempty"`
// A short description of the field. Markdown syntax is supported.
Description *string `json:"description,omitempty" url:"description,omitempty"`
Constraints []*Constraint `json:"constraints,omitempty" url:"constraints,omitempty"`
Readonly *bool `json:"readonly,omitempty" url:"readonly,omitempty"`
Appearance *FieldAppearance `json:"appearance,omitempty" url:"appearance,omitempty"`
// Useful for any contextual metadata regarding the schema. Store any valid json here.
Metadata interface{} `json:"metadata,omitempty" url:"metadata,omitempty"`
// A unique presentation for a field in the UI.
Treatments []string `json:"treatments,omitempty" url:"treatments,omitempty"`
AlternativeNames []string `json:"alternativeNames,omitempty" url:"alternativeNames,omitempty"`

_rawJSON json.RawMessage
}

func (s *StringListProperty) UnmarshalJSON(data []byte) error {
type unmarshaler StringListProperty
var value unmarshaler
if err := json.Unmarshal(data, &value); err != nil {
return err
}
*s = StringListProperty(value)
s._rawJSON = json.RawMessage(data)
return nil
}

func (s *StringListProperty) String() string {
if len(s._rawJSON) > 0 {
if value, err := core.StringifyJSON(s._rawJSON); err == nil {
return value
}
}
if value, err := core.StringifyJSON(s); err == nil {
return value
}
return fmt.Sprintf("%#v", s)
}

// Defines a property that should be stored and read as a basic string. Database engines should expect any length of text to be provided here unless explicitly defined in the config.
type StringProperty struct {
Key string `json:"key" url:"key"`
Expand Down

0 comments on commit f7278c2

Please sign in to comment.