Feature/put post (#9)
This commit is contained in:
@@ -11,14 +11,14 @@ import (
|
||||
"strconv"
|
||||
)
|
||||
|
||||
// GetRecordsConfig helper type to use in
|
||||
// step by step get records
|
||||
// GetRecordsConfig helper type to use in.
|
||||
// step by step get records.
|
||||
type GetRecordsConfig struct {
|
||||
table *Table
|
||||
params url.Values
|
||||
}
|
||||
|
||||
// GetRecords prepare step to get records
|
||||
// GetRecords prepare step to get records.
|
||||
func (t *Table) GetRecords() *GetRecordsConfig {
|
||||
return &GetRecordsConfig{
|
||||
table: t,
|
||||
@@ -26,7 +26,7 @@ func (t *Table) GetRecords() *GetRecordsConfig {
|
||||
}
|
||||
}
|
||||
|
||||
// ReturnFields set returning field names
|
||||
// ReturnFields set returning field names.
|
||||
func (grc *GetRecordsConfig) ReturnFields(fieldNames ...string) *GetRecordsConfig {
|
||||
for _, fieldName := range fieldNames {
|
||||
grc.params.Add("fields[]", fieldName)
|
||||
@@ -34,13 +34,13 @@ func (grc *GetRecordsConfig) ReturnFields(fieldNames ...string) *GetRecordsConfi
|
||||
return grc
|
||||
}
|
||||
|
||||
// WithFilterFormula add filter to request
|
||||
// WithFilterFormula add filter to request.
|
||||
func (grc *GetRecordsConfig) WithFilterFormula(filterFormula string) *GetRecordsConfig {
|
||||
grc.params.Set("filterByFormula", filterFormula)
|
||||
return grc
|
||||
}
|
||||
|
||||
// WithSort add sorting to request
|
||||
// WithSort add sorting to request.
|
||||
func (grc *GetRecordsConfig) WithSort(sortQueries ...struct {
|
||||
fieldName string
|
||||
direction string
|
||||
@@ -52,13 +52,13 @@ func (grc *GetRecordsConfig) WithSort(sortQueries ...struct {
|
||||
return grc
|
||||
}
|
||||
|
||||
// FromView add view parameter to get records
|
||||
// FromView add view parameter to get records.
|
||||
func (grc *GetRecordsConfig) FromView(viewNameOrID string) *GetRecordsConfig {
|
||||
grc.params.Set("view", viewNameOrID)
|
||||
return grc
|
||||
}
|
||||
|
||||
// The maximum total number of records that will be returned in your requests.
|
||||
// MaxRecords The maximum total number of records that will be returned in your requests.
|
||||
// If this value is larger than pageSize (which is 100 by default),
|
||||
// you may have to load multiple pages to reach this total.
|
||||
// See the Pagination section below for more.
|
||||
@@ -67,7 +67,7 @@ func (grc *GetRecordsConfig) MaxRecords(maxRecords int) *GetRecordsConfig {
|
||||
return grc
|
||||
}
|
||||
|
||||
// The number of records returned in each request.
|
||||
// PageSize The number of records returned in each request.
|
||||
// Must be less than or equal to 100. Default is 100.
|
||||
// See the Pagination section below for more.
|
||||
func (grc *GetRecordsConfig) PageSize(pageSize int) *GetRecordsConfig {
|
||||
@@ -82,14 +82,14 @@ func (grc *GetRecordsConfig) PageSize(pageSize int) *GetRecordsConfig {
|
||||
// If there are more records, the response will contain an offset.
|
||||
// To fetch the next page of records, include offset in the next request's parameters.
|
||||
|
||||
// Pagination will stop when you've reached the end of your table.
|
||||
// WithOffset Pagination will stop when you've reached the end of your table.
|
||||
// If the maxRecords parameter is passed, pagination will stop once you've reached this maximum.
|
||||
func (grc *GetRecordsConfig) WithOffset(offset string) *GetRecordsConfig {
|
||||
grc.params.Set("offset", offset)
|
||||
return grc
|
||||
}
|
||||
|
||||
// InStringFormat add parameter to get records in string format
|
||||
// InStringFormat add parameter to get records in string format.
|
||||
// it require timezone
|
||||
// https://support.airtable.com/hc/en-us/articles/216141558-Supported-timezones-for-SET-TIMEZONE
|
||||
// and user locale data
|
||||
@@ -101,7 +101,7 @@ func (grc *GetRecordsConfig) InStringFormat(timeZone, userLocale string) *GetRec
|
||||
return grc
|
||||
}
|
||||
|
||||
// Do send the prepared get records request
|
||||
// Do send the prepared get records request.
|
||||
func (grc *GetRecordsConfig) Do() (*Records, error) {
|
||||
return grc.table.GetRecordsWithParams(grc.params)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user