-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrecords.go
274 lines (248 loc) · 9.54 KB
/
records.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
// This file was auto-generated by Fern from our API Definition.
package api
import (
json "encoding/json"
fmt "fmt"
core "github.com/FlatFilers/flatfile-go/core"
time "time"
)
type DeleteRecordsRequest struct {
// A list of record IDs to delete. Maximum of 100 allowed.
Ids []RecordId `json:"-" url:"ids"`
}
type FindAndReplaceRecordRequest struct {
Filter *Filter `json:"-" url:"filter,omitempty"`
// Name of field by which to filter records
FilterField *FilterField `json:"-" url:"filterField,omitempty"`
SearchValue *SearchValue `json:"-" url:"searchValue,omitempty"`
SearchField *SearchField `json:"-" url:"searchField,omitempty"`
// The Record Ids param (ids) is a list of record ids that can be passed to several record endpoints allowing the user to identify specific records to INCLUDE in the query, or specific records to EXCLUDE, depending on whether or not filters are being applied. When passing a query param that filters the record dataset, such as 'searchValue', or a 'filter' of 'valid' | 'error' | 'all', the 'ids' param will EXCLUDE those records from the filtered results. For basic queries that do not filter the dataset, passing record ids in the 'ids' param will limit the dataset to INCLUDE just those specific records
Ids []*RecordId `json:"-" url:"ids,omitempty"`
// An FFQL query used to filter the result set
Q *string `json:"-" url:"q,omitempty"`
// A value to find for a given field in a sheet. For exact matches, wrap the value in double quotes ("Bob")
Find *CellValueUnion `json:"find,omitempty" url:"-"`
// The value to replace found values with
Replace *CellValueUnion `json:"replace,omitempty" url:"-"`
// A unique key used to identify a field in a sheet
FieldKey string `json:"fieldKey" url:"-"`
}
type GetRecordsRequest struct {
// Deprecated, use `commitId` instead.
VersionId *VersionId `json:"-" url:"versionId,omitempty"`
CommitId *CommitId `json:"-" url:"commitId,omitempty"`
// Deprecated, use `sinceCommitId` instead.
SinceVersionId *VersionId `json:"-" url:"sinceVersionId,omitempty"`
SinceCommitId *CommitId `json:"-" url:"sinceCommitId,omitempty"`
SortField *SortField `json:"-" url:"sortField,omitempty"`
SortDirection *SortDirection `json:"-" url:"sortDirection,omitempty"`
Filter *Filter `json:"-" url:"filter,omitempty"`
// Name of field by which to filter records
FilterField *FilterField `json:"-" url:"filterField,omitempty"`
SearchValue *SearchValue `json:"-" url:"searchValue,omitempty"`
SearchField *SearchField `json:"-" url:"searchField,omitempty"`
// The Record Ids param (ids) is a list of record ids that can be passed to several record endpoints allowing the user to identify specific records to INCLUDE in the query, or specific records to EXCLUDE, depending on whether or not filters are being applied. When passing a query param that filters the record dataset, such as 'searchValue', or a 'filter' of 'valid' | 'error' | 'all', the 'ids' param will EXCLUDE those records from the filtered results. For basic queries that do not filter the dataset, passing record ids in the 'ids' param will limit the dataset to INCLUDE just those specific records. Maximum of 100 allowed.
Ids []*RecordId `json:"-" url:"ids,omitempty"`
// Number of records to return in a page (default 10,000)
PageSize *int `json:"-" url:"pageSize,omitempty"`
// Based on pageSize, which page of records to return (Note - numbers start at 1)
PageNumber *int `json:"-" url:"pageNumber,omitempty"`
// **DEPRECATED** Use GET /sheets/:sheetId/counts
IncludeCounts *bool `json:"-" url:"includeCounts,omitempty"`
// The length of the record result set, returned as counts.total
IncludeLength *bool `json:"-" url:"includeLength,omitempty"`
// If true, linked records will be included in the results. Defaults to false.
IncludeLinks *bool `json:"-" url:"includeLinks,omitempty"`
// Include error messages, defaults to false.
IncludeMessages *bool `json:"-" url:"includeMessages,omitempty"`
// A list of field keys to include in the response. If not provided, all fields will be included.
Fields []*string `json:"-" url:"fields,omitempty"`
// if "for" is provided, the query parameters will be pulled from the event payload
For *EventId `json:"-" url:"for,omitempty"`
// An FFQL query used to filter the result set
Q *string `json:"-" url:"q,omitempty"`
}
type CellValueUnion struct {
String string
Integer int
Long int64
Double float64
Boolean bool
Date time.Time
DateTime time.Time
StringList []string
typ string
}
func NewCellValueUnionFromString(value string) *CellValueUnion {
return &CellValueUnion{typ: "String", String: value}
}
func NewCellValueUnionFromInteger(value int) *CellValueUnion {
return &CellValueUnion{typ: "Integer", Integer: value}
}
func NewCellValueUnionFromLong(value int64) *CellValueUnion {
return &CellValueUnion{typ: "Long", Long: value}
}
func NewCellValueUnionFromDouble(value float64) *CellValueUnion {
return &CellValueUnion{typ: "Double", Double: value}
}
func NewCellValueUnionFromBoolean(value bool) *CellValueUnion {
return &CellValueUnion{typ: "Boolean", Boolean: value}
}
func NewCellValueUnionFromDate(value time.Time) *CellValueUnion {
return &CellValueUnion{typ: "Date", Date: value}
}
func NewCellValueUnionFromDateTime(value time.Time) *CellValueUnion {
return &CellValueUnion{typ: "DateTime", DateTime: value}
}
func NewCellValueUnionFromStringList(value []string) *CellValueUnion {
return &CellValueUnion{typ: "StringList", StringList: value}
}
func (c *CellValueUnion) UnmarshalJSON(data []byte) error {
var valueString string
if err := json.Unmarshal(data, &valueString); err == nil {
c.typ = "String"
c.String = valueString
return nil
}
var valueInteger int
if err := json.Unmarshal(data, &valueInteger); err == nil {
c.typ = "Integer"
c.Integer = valueInteger
return nil
}
var valueLong int64
if err := json.Unmarshal(data, &valueLong); err == nil {
c.typ = "Long"
c.Long = valueLong
return nil
}
var valueDouble float64
if err := json.Unmarshal(data, &valueDouble); err == nil {
c.typ = "Double"
c.Double = valueDouble
return nil
}
var valueBoolean bool
if err := json.Unmarshal(data, &valueBoolean); err == nil {
c.typ = "Boolean"
c.Boolean = valueBoolean
return nil
}
var valueDate *core.Date
if err := json.Unmarshal(data, &valueDate); err == nil {
c.typ = "Date"
c.Date = valueDate.Time()
return nil
}
var valueDateTime *core.DateTime
if err := json.Unmarshal(data, &valueDateTime); err == nil {
c.typ = "DateTime"
c.DateTime = valueDateTime.Time()
return nil
}
var valueStringList []string
if err := json.Unmarshal(data, &valueStringList); err == nil {
c.typ = "StringList"
c.StringList = valueStringList
return nil
}
return fmt.Errorf("%s cannot be deserialized as a %T", data, c)
}
func (c CellValueUnion) MarshalJSON() ([]byte, error) {
if c.typ == "String" || c.String != "" {
return json.Marshal(c.String)
}
if c.typ == "Integer" || c.Integer != 0 {
return json.Marshal(c.Integer)
}
if c.typ == "Long" || c.Long != 0 {
return json.Marshal(c.Long)
}
if c.typ == "Double" || c.Double != 0 {
return json.Marshal(c.Double)
}
if c.typ == "Boolean" || c.Boolean != false {
return json.Marshal(c.Boolean)
}
if c.typ == "Date" || !c.Date.IsZero() {
return json.Marshal(core.NewDate(c.Date))
}
if c.typ == "DateTime" || !c.DateTime.IsZero() {
return json.Marshal(core.NewDateTime(c.DateTime))
}
if c.typ == "StringList" || c.StringList != nil {
return json.Marshal(c.StringList)
}
return nil, fmt.Errorf("type %T does not include a non-empty union type", c)
}
type CellValueUnionVisitor interface {
VisitString(string) error
VisitInteger(int) error
VisitLong(int64) error
VisitDouble(float64) error
VisitBoolean(bool) error
VisitDate(time.Time) error
VisitDateTime(time.Time) error
VisitStringList([]string) error
}
func (c *CellValueUnion) Accept(visitor CellValueUnionVisitor) error {
if c.typ == "String" || c.String != "" {
return visitor.VisitString(c.String)
}
if c.typ == "Integer" || c.Integer != 0 {
return visitor.VisitInteger(c.Integer)
}
if c.typ == "Long" || c.Long != 0 {
return visitor.VisitLong(c.Long)
}
if c.typ == "Double" || c.Double != 0 {
return visitor.VisitDouble(c.Double)
}
if c.typ == "Boolean" || c.Boolean != false {
return visitor.VisitBoolean(c.Boolean)
}
if c.typ == "Date" || !c.Date.IsZero() {
return visitor.VisitDate(c.Date)
}
if c.typ == "DateTime" || !c.DateTime.IsZero() {
return visitor.VisitDateTime(c.DateTime)
}
if c.typ == "StringList" || c.StringList != nil {
return visitor.VisitStringList(c.StringList)
}
return fmt.Errorf("type %T does not include a non-empty union type", c)
}
type GetRecordsResponse struct {
Data *GetRecordsResponseData `json:"data,omitempty" url:"data,omitempty"`
extraProperties map[string]interface{}
_rawJSON json.RawMessage
}
func (g *GetRecordsResponse) GetExtraProperties() map[string]interface{} {
return g.extraProperties
}
func (g *GetRecordsResponse) UnmarshalJSON(data []byte) error {
type unmarshaler GetRecordsResponse
var value unmarshaler
if err := json.Unmarshal(data, &value); err != nil {
return err
}
*g = GetRecordsResponse(value)
extraProperties, err := core.ExtractExtraProperties(data, *g)
if err != nil {
return err
}
g.extraProperties = extraProperties
g._rawJSON = json.RawMessage(data)
return nil
}
func (g *GetRecordsResponse) String() string {
if len(g._rawJSON) > 0 {
if value, err := core.StringifyJSON(g._rawJSON); err == nil {
return value
}
}
if value, err := core.StringifyJSON(g); err == nil {
return value
}
return fmt.Sprintf("%#v", g)
}