Documentation ¶
Index ¶
- type ActionMetadata
- type Client
- func (c *Client) CreateWebhook(baseId string, notificationUrl string, spec *WebhookSpecification) (*CreateWebhookResponse, error)
- func (c *Client) DeleteWebhook(baseId, webhookId string) error
- func (c *Client) NewWebhookHandler(macSecretBase64 string) (*WebhookHandler, error)
- func (c *Client) NewWebhookManager(ch chan InitialWebhookResponse) *WebhookManager
- func (c *Client) RefreshWebhook(baseId, webhookId string) (*RefreshWebhookResponse, error)
- func (c *Client) SetWebhookNotifications(baseId, webhookId string, enable bool) error
- type CreateWebhookResponse
- type Email
- type InitialWebhookResponse
- type InitialWebhookResponseHandler
- type LongText
- type Number
- type Option
- type Page
- type Phone
- type Record
- type RefreshWebhookResponse
- type Relation
- type ShortText
- type SingleSelect
- type Table
- type URL
- type User
- type WebhookHandler
- type WebhookManager
- type WebhookPayload
- type WebhookResponse
- type WebhookSpecification
- func (w *WebhookSpecification) AddChangeType(changeType string) *WebhookSpecification
- func (w *WebhookSpecification) AddDataType(dataType string) *WebhookSpecification
- func (w *WebhookSpecification) AddFromSource(source string) *WebhookSpecification
- func (w *WebhookSpecification) AddWatchDataInField(fieldId string) *WebhookSpecification
- func (w *WebhookSpecification) AddWatchSchemaOfField(fieldId string) *WebhookSpecification
- func (w *WebhookSpecification) SetRecordChangeScope(scope string) *WebhookSpecification
- type WebhookUser
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ActionMetadata ¶
type ActionMetadata struct { Source string `json:"source"` SourceMetadata struct { User WebhookUser `json:"user"` } `json:"sourceMetadata"` }
ActionMetadata represents metadata about the webhook action.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func (*Client) CreateWebhook ¶
func (c *Client) CreateWebhook(baseId string, notificationUrl string, spec *WebhookSpecification) (*CreateWebhookResponse, error)
CreateWebhook creates a new webhook in Airtable.
func (*Client) DeleteWebhook ¶
DeleteWebhook deletes an existing webhook in Airtable.
func (*Client) NewWebhookHandler ¶
func (c *Client) NewWebhookHandler(macSecretBase64 string) (*WebhookHandler, error)
NewWebhookHandler creates a new WebhookHandler as a method of the Client type.
func (*Client) NewWebhookManager ¶
func (c *Client) NewWebhookManager(ch chan InitialWebhookResponse) *WebhookManager
NewWebhookManager creates a new WebhookManager as a method of the Client type.
func (*Client) RefreshWebhook ¶
func (c *Client) RefreshWebhook(baseId, webhookId string) (*RefreshWebhookResponse, error)
RefreshWebhook extends the life of a webhook. The new expiration time will be 7 days after the refresh time.
type CreateWebhookResponse ¶
type CreateWebhookResponse struct { Id string `json:"id"` MacSecretBase64 string `json:"macSecretBase64"` ExpirationTime time.Time `json:"expirationTime"` }
CreateWebhookResponse defines the expected structure of the response from the Airtable API.
type InitialWebhookResponse ¶
type InitialWebhookResponse struct { Base struct { Id string `json:"id"` } `json:"base"` Webhook struct { Id string `json:"id"` } `json:"webhook"` Timestamp time.Time `json:"timestamp"` }
InitialWebhookResponse represents the structure of the initial payload received by the webhook.
type InitialWebhookResponseHandler ¶
type InitialWebhookResponseHandler struct { C chan InitialWebhookResponse // contains filtered or unexported fields }
InitialWebhookResponseHandler is a struct that holds a channel for InitialWebhookResponse payloads.
func NewInitialWebhookResponseHandler ¶
func NewInitialWebhookResponseHandler(macSecretBase64 string) (*InitialWebhookResponseHandler, error)
NewInitialWebhookResponseHandler creates a new InitialWebhookResponseHandler with a channel for InitialWebhookPayloads.
func (*InitialWebhookResponseHandler) ServeHTTP ¶
func (h *InitialWebhookResponseHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
type RefreshWebhookResponse ¶
RefreshWebhookResponse defines the expected structure of the response from refreshing a webhook.
type SingleSelect ¶
type SingleSelect string
type WebhookHandler ¶
type WebhookHandler struct { C chan WebhookPayload // contains filtered or unexported fields }
WebhookHandler encapsulates InitialWebhookResponseHandler and WebhookManager.
func (*WebhookHandler) Run ¶
func (h *WebhookHandler) Run() error
Run starts the process of listening for and fetching webhook payloads.
func (*WebhookHandler) ServeHTTP ¶
func (h *WebhookHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP implements the http.Handler interface.
type WebhookManager ¶
type WebhookManager struct { C chan WebhookPayload // contains filtered or unexported fields }
WebhookManager is responsible for handling the entire webhook process.
func (*WebhookManager) FetchWebhookPayloads ¶
func (h *WebhookManager) FetchWebhookPayloads(baseId, webhookId string) error
FetchWebhookPayloads fetches the detailed WebhookPayloads from Airtable.
func (*WebhookManager) Run ¶
func (h *WebhookManager) Run() error
Run starts listening on the InitialResponseChan for incoming initial webhook responses.
type WebhookPayload ¶
type WebhookPayload struct { Timestamp time.Time `json:"timestamp"` BaseTransactionNumber int `json:"baseTransactionNumber"` ActionMetadata ActionMetadata `json:"actionMetadata"` PayloadFormat string `json:"payloadFormat"` ChangedTablesById any `json:"changedTablesById,omitempty"` CreatedTablesById any `json:"createdTablesById,omitempty"` DestroyedTableIds []string `json:"destroyedTableIds,omitempty"` Error bool `json:"error,omitempty"` Code string `json:"code,omitempty"` }
WebhookPayload represents the common structure of a webhook payload.
type WebhookResponse ¶
type WebhookResponse struct { Payloads []WebhookPayload `json:"payloads"` Cursor int `json:"cursor"` MightHaveMore bool `json:"mightHaveMore"` }
WebhookResponse represents the response containing one or more payloads.
type WebhookSpecification ¶
type WebhookSpecification struct {
Options struct {
Filters filters `json:"filters"`
} `json:"options"`
}
WebhookSpecification defines the structure for the webhook creation request.
func NewWebhookSpecification ¶
func NewWebhookSpecification() *WebhookSpecification
func (*WebhookSpecification) AddChangeType ¶
func (w *WebhookSpecification) AddChangeType(changeType string) *WebhookSpecification
AddChangeType adds a changeType to the list.
func (*WebhookSpecification) AddDataType ¶
func (w *WebhookSpecification) AddDataType(dataType string) *WebhookSpecification
AddDataType adds a dataType to the list.
func (*WebhookSpecification) AddFromSource ¶
func (w *WebhookSpecification) AddFromSource(source string) *WebhookSpecification
AddFromSource adds a fromSource to the list.
func (*WebhookSpecification) AddWatchDataInField ¶
func (w *WebhookSpecification) AddWatchDataInField(fieldId string) *WebhookSpecification
AddWatchDataInField adds a field Id to watch data in.
func (*WebhookSpecification) AddWatchSchemaOfField ¶
func (w *WebhookSpecification) AddWatchSchemaOfField(fieldId string) *WebhookSpecification
AddWatchSchemaOfField adds a field Id to watch schema changes in.
func (*WebhookSpecification) SetRecordChangeScope ¶
func (w *WebhookSpecification) SetRecordChangeScope(scope string) *WebhookSpecification
SetRecordChangeScope sets the recordChangeScope.
type WebhookUser ¶
type WebhookUser struct { Id string `json:"id"` Email string `json:"email"` PermissionLevel string `json:"permissionLevel"` }
WebhookUser represents a user associated with a webhook action.