airtable

package
v0.0.82 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 2, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EncodePatchAsJSON

func EncodePatchAsJSON[T any](patchRequest PatchItemsRequest[T]) (bodyBuf *bytes.Buffer, err error)

EncodePatchAsJSON returns bytes of JSON encoded patch request

func EncodePostAsJSON added in v0.0.66

func EncodePostAsJSON[T AirtableFields](req CreateRecordsRequest[T]) (bodyBuf *bytes.Buffer, err error)

EncodePostAsJSON returns bytes of JSON encoded patch request

func GetOAuthEndpoint

func GetOAuthEndpoint() oauth2.Endpoint

GetOAuthEndpoint returns the OAuth endpoint for Airtable

func UpdateRecordsRequest

func UpdateRecordsRequest(baseID string, tableName string, patchBody *bytes.Buffer, ctx context.Context) (*http.Request, error)

UpdateRecordsRequest returns a request to update records of Airtable

Types

type AirtableFields

type AirtableFields interface {
}

AirtableFields a marker interface where any struct would work

type AirtableRecord

type AirtableRecord[T AirtableFields] struct {
	Id          string    `json:"id"`
	CreatedTime time.Time `json:"createdTime"`
	Fields      T         `json:"fields"`
}

AirtableRecord represents a record of Airtable

func CreateRecord added in v0.0.66

func CreateRecord[Tin AirtableFields, T AirtableFields](httpClient *http.Client, record *Tin, baseID string, tableName string, ctx context.Context) ([]*AirtableRecord[T], error)

func ListRecords

func ListRecords[T AirtableFields](httpClient *http.Client, baseID string, tableName string, viewName string, ctx context.Context, maxRecords int) ([]*AirtableRecord[T], error)

ListRecords returns a list of records from Airtable

func UpdateRecords

func UpdateRecords[T AirtableFields](httpClient *http.Client, request *http.Request) ([]*AirtableRecord[T], error)

UpdateRecords updates records of Airtable and returns the records updated

type AirtableRecords

type AirtableRecords[T AirtableFields] struct {
	Records []AirtableRecord[T] `json:"records"`
	Offset  string              `json:"offset"`
}

AirtableRecords represents a list of records of Airtable

type CreateRecordRequest added in v0.0.66

type CreateRecordRequest[T AirtableFields] struct {
	Fields T `json:"fields"`
}

CreateRecordRequest represents a request to create a record

type CreateRecordsRequest added in v0.0.66

type CreateRecordsRequest[T AirtableFields] struct {
	Records  []CreateRecordRequest[T] `json:"records"`
	Typecast bool                     `json:"typecast"`
}

CreateRecordsRequest represents a request to create a list of records

type ErrorDetail

type ErrorDetail struct {
	Message string `json:"message"`
	Type    string `json:"type"`
}

ErrorDetail represents an error detail from Airtable

type ErrorResponse

type ErrorResponse struct {
	Error ErrorDetail `json:"error"`
}

ErrorResponse represents an error response from Airtable

type PatchBooleanBody

type PatchBooleanBody func(map[string]bool) (*bytes.Buffer, error)

PatchBooleanBody returns bytes of a request body to patch a boolean field

type PatchItemRequest

type PatchItemRequest[T AirtableFields] struct {
	Id     string `json:"id"`
	Fields T      `json:"fields"`
}

PatchItemRequest represents a request to patch an item

type PatchItemsRequest

type PatchItemsRequest[T AirtableFields] struct {
	Records  []PatchItemRequest[T] `json:"records"`
	Typecast bool                  `json:"typecast"`
}

PatchItemsRequest represents a request to patch a list of items

type PatchStringArrayBody

type PatchStringArrayBody func(map[string][]string) (*bytes.Buffer, error)

PatchStringArrayBody returns bytes of a request body to patch a string array field

type PatchStringBody

type PatchStringBody func(map[string]string) (*bytes.Buffer, error)

PatchStringBody returns bytes of a request body to patch a string field

type PatchTimeBody

type PatchTimeBody func(map[string]time.Time) (*bytes.Buffer, error)

PatchTimeBody returns bytes of a request body to patch a time field

type SimpleErrorResponse

type SimpleErrorResponse struct {
	Error string `json:"error"`
}

SimpleErrorResponse represents a simple error response from Airtable

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL