Make WithSort arg field names public (#10)
This commit is contained in:
@@ -42,12 +42,12 @@ func (grc *GetRecordsConfig) WithFilterFormula(filterFormula string) *GetRecords
|
|||||||
|
|
||||||
// WithSort add sorting to request.
|
// WithSort add sorting to request.
|
||||||
func (grc *GetRecordsConfig) WithSort(sortQueries ...struct {
|
func (grc *GetRecordsConfig) WithSort(sortQueries ...struct {
|
||||||
fieldName string
|
FieldName string
|
||||||
direction string
|
Direction string
|
||||||
}) *GetRecordsConfig {
|
}) *GetRecordsConfig {
|
||||||
for queryNum, sortQuery := range sortQueries {
|
for queryNum, sortQuery := range sortQueries {
|
||||||
grc.params.Set(fmt.Sprintf("sort[%v][field]", queryNum), sortQuery.fieldName)
|
grc.params.Set(fmt.Sprintf("sort[%v][field]", queryNum), sortQuery.FieldName)
|
||||||
grc.params.Set(fmt.Sprintf("sort[%v][direction]", queryNum), sortQuery.direction)
|
grc.params.Set(fmt.Sprintf("sort[%v][direction]", queryNum), sortQuery.Direction)
|
||||||
}
|
}
|
||||||
return grc
|
return grc
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,12 +13,12 @@ func TestGetRecordsConfig_Do(t *testing.T) {
|
|||||||
table := testTable(t)
|
table := testTable(t)
|
||||||
table.client.baseURL = mockResponse("get_records_with_filter.json").URL
|
table.client.baseURL = mockResponse("get_records_with_filter.json").URL
|
||||||
sortQuery1 := struct {
|
sortQuery1 := struct {
|
||||||
fieldName string
|
FieldName string
|
||||||
direction string
|
Direction string
|
||||||
}{"Field1", "desc"}
|
}{"Field1", "desc"}
|
||||||
sortQuery2 := struct {
|
sortQuery2 := struct {
|
||||||
fieldName string
|
FieldName string
|
||||||
direction string
|
Direction string
|
||||||
}{"Field2", "asc"}
|
}{"Field2", "asc"}
|
||||||
|
|
||||||
records, err := table.GetRecords().
|
records, err := table.GetRecords().
|
||||||
|
|||||||
Reference in New Issue
Block a user