Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions providers/google/connector.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,10 @@ func (c *Connector) Subscribe(
ctx context.Context,
params common.SubscribeParams,
) (*common.SubscriptionResult, error) {
if c.Calendar != nil {
return c.Calendar.Subscribe(ctx, params)
}

if c.Mail != nil {
return c.Mail.Subscribe(ctx, params)
}
Expand All @@ -167,6 +171,10 @@ func (c *Connector) UpdateSubscription(
params common.SubscribeParams,
previousResult *common.SubscriptionResult,
) (*common.SubscriptionResult, error) {
if c.Calendar != nil {
return c.Calendar.UpdateSubscription(ctx, params, previousResult)
}

if c.Mail != nil {
return c.Mail.UpdateSubscription(ctx, params, previousResult)
}
Expand All @@ -178,6 +186,10 @@ func (c *Connector) DeleteSubscription(
ctx context.Context,
previousResult common.SubscriptionResult,
) error {
if c.Calendar != nil {
return c.Calendar.DeleteSubscription(ctx, previousResult)
}

if c.Mail != nil {
return c.Mail.DeleteSubscription(ctx, previousResult)
}
Expand All @@ -186,6 +198,10 @@ func (c *Connector) DeleteSubscription(
}

func (c *Connector) EmptySubscriptionParams() *common.SubscribeParams {
if c.Calendar != nil {
return c.Calendar.EmptySubscriptionParams()
}

if c.Mail != nil {
return c.Mail.EmptySubscriptionParams()
}
Expand All @@ -194,6 +210,10 @@ func (c *Connector) EmptySubscriptionParams() *common.SubscribeParams {
}

func (c *Connector) EmptySubscriptionResult() *common.SubscriptionResult {
if c.Calendar != nil {
return c.Calendar.EmptySubscriptionResult()
}

if c.Mail != nil {
return c.Mail.EmptySubscriptionResult()
}
Expand All @@ -206,6 +226,10 @@ func (c *Connector) VerifyWebhookMessage(
request *common.WebhookRequest,
params *common.VerificationParams,
) (bool, error) {
if c.Calendar != nil {
return c.Calendar.VerifyWebhookMessage(ctx, request, params)
}

if c.Mail != nil {
return c.Mail.VerifyWebhookMessage(ctx, request, params)
}
Expand All @@ -219,6 +243,10 @@ func (c *Connector) GetRecordsByIds(ctx context.Context, // nolint: revive
fields []string,
associations []string,
) ([]common.ReadResultRow, error) {
if c.Calendar != nil {
return c.Calendar.GetRecordsByIds(ctx, objectName, recordIds, fields, associations)
}

if c.Mail != nil {
return c.Mail.GetRecordsByIds(ctx, objectName, recordIds, fields, associations)
}
Expand All @@ -231,13 +259,25 @@ func (c *Connector) RunScheduledMaintenance(
params common.SubscribeParams,
previousResult *common.SubscriptionResult,
) (*common.SubscriptionResult, error) {
if c.Calendar != nil {
return c.Calendar.RunScheduledMaintenance(ctx, params, previousResult)
}

if c.Mail != nil {
return c.Mail.RunScheduledMaintenance(ctx, params, previousResult)
}

return nil, common.ErrNotImplemented
}

// Re-exports of Google Calendar subscribe types so external callers can use them
// without importing the internal calendar package.
type (
CalendarWatchRequest = calendar.WatchRequest
CalendarWatchResponse = calendar.WatchResponse
CalendarSubscriptionResult = calendar.CalendarSubscriptionResult
)

// Re-exports of Gmail history.list types so external callers can use them
// without importing the internal mail package.
type (
Expand Down
7 changes: 7 additions & 0 deletions providers/google/internal/calendar/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package calendar

import (
"bytes"
"errors"
"fmt"
"net/http"
"strings"
Expand All @@ -10,6 +11,12 @@ import (
"github.com/amp-labs/connectors/common/interpreter"
)

var (
errMissingParams = errors.New("missing required parameters")
errInvalidRequestType = errors.New("invalid request type")
errUnsupportedSubscribeObject = errors.New("unsupported subscribe object")
)

var errorFormats = interpreter.NewFormatSwitch( // nolint:gochecknoglobals
[]interpreter.FormatTemplate{
{
Expand Down
2 changes: 2 additions & 0 deletions providers/google/internal/calendar/operations.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ import (
const (
objectNameCalendarList = "calendarList"
objectNameEvents = "events"
objectNameSettings = "settings"
objectNameACL = "acl"

// Page size references:
// https://developers.google.com/workspace/calendar/api/v3/reference/calendarList/list
Expand Down
Loading
Loading