Skip to content

Commit 56620ac

Browse files
committed
impr: add context to Do methods (#19)
1 parent e0fd5aa commit 56620ac

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

get-bases.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package airtable
22

33
import (
4+
"context"
45
"net/url"
56
)
67

@@ -35,3 +36,8 @@ func (gbc *GetBasesConfig) WithOffset(offset string) *GetBasesConfig {
3536
func (gbc *GetBasesConfig) Do() (*Bases, error) {
3637
return gbc.client.GetBasesWithParams(gbc.params)
3738
}
39+
40+
// DoContext send the prepared get records request with context.
41+
func (gbc *GetBasesConfig) DoContext(ctx context.Context) (*Bases, error) {
42+
return gbc.client.GetBasesWithParamsContext(ctx, gbc.params)
43+
}

get-records.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
package airtable
77

88
import (
9+
"context"
910
"fmt"
1011
"net/url"
1112
"strconv"
@@ -44,7 +45,8 @@ func (grc *GetRecordsConfig) WithFilterFormula(filterFormula string) *GetRecords
4445
func (grc *GetRecordsConfig) WithSort(sortQueries ...struct {
4546
FieldName string
4647
Direction string
47-
}) *GetRecordsConfig {
48+
},
49+
) *GetRecordsConfig {
4850
for queryNum, sortQuery := range sortQueries {
4951
grc.params.Set(fmt.Sprintf("sort[%v][field]", queryNum), sortQuery.FieldName)
5052
grc.params.Set(fmt.Sprintf("sort[%v][direction]", queryNum), sortQuery.Direction)
@@ -105,3 +107,8 @@ func (grc *GetRecordsConfig) InStringFormat(timeZone, userLocale string) *GetRec
105107
func (grc *GetRecordsConfig) Do() (*Records, error) {
106108
return grc.table.GetRecordsWithParams(grc.params)
107109
}
110+
111+
// DoContext send the prepared get records request with context.
112+
func (grc *GetRecordsConfig) DoContext(ctx context.Context) (*Records, error) {
113+
return grc.table.GetRecordsWithParamsContext(ctx, grc.params)
114+
}

0 commit comments

Comments
 (0)