database

package
Version: v0.0.30 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2021 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DbService

type DbService struct {
	// contains filtered or unexported fields
}

DbService is an implementation of the database repository It is implementation agnostic i.e logic should be handled using the preferred database

func (DbService) CheckPreconditions

func (d DbService) CheckPreconditions()

CheckPreconditions ensures correct initialization

func (*DbService) DeleteAction

func (d *DbService) DeleteAction(
	ctx context.Context,
	uid string,
	flavour feedlib.Flavour,
	actionID string,
) error

DeleteAction permanently deletes an action and it's copies

func (*DbService) DeleteFeedItem

func (d *DbService) DeleteFeedItem(
	ctx context.Context,
	uid string,
	flavour feedlib.Flavour,
	itemID string,
) error

DeleteFeedItem permanently deletes a feed item and it's copies

func (*DbService) DeleteMessage

func (d *DbService) DeleteMessage(
	ctx context.Context,
	uid string,
	flavour feedlib.Flavour,
	itemID string,
	messageID string,
) error

DeleteMessage deletes a message

func (*DbService) DeleteNudge

func (d *DbService) DeleteNudge(
	ctx context.Context,
	uid string,
	flavour feedlib.Flavour,
	nudgeID string,
) error

DeleteNudge permanently deletes a nudge and it's copies

func (*DbService) GetAction

func (d *DbService) GetAction(
	ctx context.Context,
	uid string,
	flavour feedlib.Flavour,
	actionID string,
) (*feedlib.Action, error)

GetAction gets THE LATEST VERSION OF a single action

func (*DbService) GetActions

func (d *DbService) GetActions(
	ctx context.Context,
	uid string,
	flavour feedlib.Flavour,
) ([]feedlib.Action, error)

GetActions ...

func (*DbService) GetDefaultNudgeByTitle

func (d *DbService) GetDefaultNudgeByTitle(
	ctx context.Context,
	uid string,
	flavour feedlib.Flavour,
	title string,
) (*feedlib.Nudge, error)

GetDefaultNudgeByTitle ...

func (*DbService) GetFeed

func (d *DbService) GetFeed(
	ctx context.Context,
	uid *string,
	isAnonymous *bool,
	flavour feedlib.Flavour,
	playMP4 bool,
	persistent feedlib.BooleanFilter,
	status *feedlib.Status,
	visibility *feedlib.Visibility,
	expired *feedlib.BooleanFilter,
	filterParams *helpers.FilterParams,
) (*domain.Feed, error)

GetFeed ...

func (*DbService) GetFeedItem

func (d *DbService) GetFeedItem(
	ctx context.Context,
	uid string,
	flavour feedlib.Flavour,
	itemID string,
) (*feedlib.Item, error)

GetFeedItem ...

func (*DbService) GetItems

func (d *DbService) GetItems(
	ctx context.Context,
	uid string,
	flavour feedlib.Flavour,
	persistent feedlib.BooleanFilter,
	status *feedlib.Status,
	visibility *feedlib.Visibility,
	expired *feedlib.BooleanFilter,
	filterParams *helpers.FilterParams,
) ([]feedlib.Item, error)

GetItems ...

func (*DbService) GetMessage

func (d *DbService) GetMessage(
	ctx context.Context,
	uid string,
	flavour feedlib.Flavour,
	itemID string,
	messageID string,
) (*feedlib.Message, error)

GetMessage retrieves THE LATEST VERSION OF a message

func (*DbService) GetMessages

func (d *DbService) GetMessages(
	ctx context.Context,
	uid string,
	flavour feedlib.Flavour,
	itemID string,
) ([]feedlib.Message, error)

GetMessages retrieves a message

func (*DbService) GetNudge

func (d *DbService) GetNudge(
	ctx context.Context,
	uid string,
	flavour feedlib.Flavour,
	nudgeID string,
) (*feedlib.Nudge, error)

GetNudge gets THE LATEST VERSION OF a nudge from a feed

func (*DbService) GetNudges

func (d *DbService) GetNudges(
	ctx context.Context,
	uid string,
	flavour feedlib.Flavour,
	status *feedlib.Status,
	visibility *feedlib.Visibility,
	expired *feedlib.BooleanFilter,
) ([]feedlib.Nudge, error)

GetNudges ...

func (*DbService) Labels

func (d *DbService) Labels(
	ctx context.Context,
	uid string,
	flavour feedlib.Flavour,
) ([]string, error)

Labels ...

func (*DbService) PostMessage

func (d *DbService) PostMessage(
	ctx context.Context,
	uid string,
	flavour feedlib.Flavour,
	itemID string,
	message *feedlib.Message,
) (*feedlib.Message, error)

PostMessage posts a message or a reply to a message/thread

func (*DbService) RetrieveNotification

func (d *DbService) RetrieveNotification(
	ctx context.Context,
	firestoreClient *firestore.Client,
	registrationToken string,
	newerThan time.Time,
	limit int,
) ([]*dto.SavedNotification, error)

RetrieveNotification retrieves a notification

func (*DbService) SaveAction

func (d *DbService) SaveAction(
	ctx context.Context,
	uid string,
	flavour feedlib.Flavour,
	action *feedlib.Action,
) (*feedlib.Action, error)

SaveAction saves a new action

func (*DbService) SaveFeedItem

func (d *DbService) SaveFeedItem(
	ctx context.Context,
	uid string,
	flavour feedlib.Flavour,
	item *feedlib.Item,
) (*feedlib.Item, error)

SaveFeedItem ...

func (*DbService) SaveIncomingEvent

func (d *DbService) SaveIncomingEvent(
	ctx context.Context,
	event *feedlib.Event,
) error

SaveIncomingEvent ...

func (*DbService) SaveLabel

func (d *DbService) SaveLabel(
	ctx context.Context,
	uid string,
	flavour feedlib.Flavour,
	label string,
) error

SaveLabel ...

func (*DbService) SaveNPSResponse

func (d *DbService) SaveNPSResponse(
	ctx context.Context,
	response *dto.NPSResponse,
) error

SaveNPSResponse saves a NPS response

func (*DbService) SaveNotification

func (d *DbService) SaveNotification(
	ctx context.Context,
	firestoreClient *firestore.Client,
	notification dto.SavedNotification,
) error

SaveNotification saves a notification

func (*DbService) SaveNudge

func (d *DbService) SaveNudge(
	ctx context.Context,
	uid string,
	flavour feedlib.Flavour,
	nudge *feedlib.Nudge,
) (*feedlib.Nudge, error)

SaveNudge saves a new modified nudge

func (*DbService) SaveOutgoingEmails

func (d *DbService) SaveOutgoingEmails(ctx context.Context, payload *dto.OutgoingEmailsLog) error

SaveOutgoingEmails ...

func (*DbService) SaveOutgoingEvent

func (d *DbService) SaveOutgoingEvent(
	ctx context.Context,
	event *feedlib.Event,
) error

SaveOutgoingEvent ...

func (*DbService) SaveTwilioResponse

func (d *DbService) SaveTwilioResponse(
	ctx context.Context,
	data dto.Message,
) error

SaveTwilioResponse saves the callback data for future analysis

func (*DbService) SaveTwilioVideoCallbackStatus

func (d *DbService) SaveTwilioVideoCallbackStatus(
	ctx context.Context,
	data dto.CallbackData,
) error

SaveTwilioVideoCallbackStatus ..

func (*DbService) UnreadPersistentItems

func (d *DbService) UnreadPersistentItems(
	ctx context.Context,
	uid string,
	flavour feedlib.Flavour,
) (int, error)

UnreadPersistentItems ...

func (*DbService) UpdateFeedItem

func (d *DbService) UpdateFeedItem(
	ctx context.Context,
	uid string,
	flavour feedlib.Flavour,
	item *feedlib.Item,
) (*feedlib.Item, error)

UpdateFeedItem ...

func (*DbService) UpdateMailgunDeliveryStatus

func (d *DbService) UpdateMailgunDeliveryStatus(ctx context.Context, payload *dto.MailgunEvent) (*dto.OutgoingEmailsLog, error)

UpdateMailgunDeliveryStatus ...

func (*DbService) UpdateNudge

func (d *DbService) UpdateNudge(
	ctx context.Context,
	uid string,
	flavour feedlib.Flavour,
	nudge *feedlib.Nudge,
) (*feedlib.Nudge, error)

UpdateNudge updates an existing nudge

func (*DbService) UpdateUnreadPersistentItemsCount

func (d *DbService) UpdateUnreadPersistentItemsCount(
	ctx context.Context,
	uid string,
	flavour feedlib.Flavour,
) error

UpdateUnreadPersistentItemsCount ...

type Repository

type Repository interface {
	// getting a feed...create a default feed if it does not exist
	// return: feed, matching count, total count, optional error
	GetFeed(
		ctx context.Context,
		uid *string,
		isAnonymous *bool,
		flavour feedlib.Flavour,
		playMP4 bool,
		persistent feedlib.BooleanFilter,
		status *feedlib.Status,
		visibility *feedlib.Visibility,
		expired *feedlib.BooleanFilter,
		filterParams *helpers.FilterParams,
	) (*domain.Feed, error)

	// getting a the LATEST VERSION of a feed item from a feed
	GetFeedItem(
		ctx context.Context,
		uid string,
		flavour feedlib.Flavour,
		itemID string,
	) (*feedlib.Item, error)

	// saving a new feed item
	SaveFeedItem(
		ctx context.Context,
		uid string,
		flavour feedlib.Flavour,
		item *feedlib.Item,
	) (*feedlib.Item, error)

	// updating an existing feed item
	UpdateFeedItem(
		ctx context.Context,
		uid string,
		flavour feedlib.Flavour,
		item *feedlib.Item,
	) (*feedlib.Item, error)

	// DeleteFeedItem permanently deletes a feed item and it's copies
	DeleteFeedItem(
		ctx context.Context,
		uid string,
		flavour feedlib.Flavour,
		itemID string,
	) error

	// getting THE LATEST VERSION OF a nudge from a feed
	GetNudge(
		ctx context.Context,
		uid string,
		flavour feedlib.Flavour,
		nudgeID string,
	) (*feedlib.Nudge, error)

	// saving a new modified nudge
	SaveNudge(
		ctx context.Context,
		uid string,
		flavour feedlib.Flavour,
		nudge *feedlib.Nudge,
	) (*feedlib.Nudge, error)

	// updating an existing nudge
	UpdateNudge(
		ctx context.Context,
		uid string,
		flavour feedlib.Flavour,
		nudge *feedlib.Nudge,
	) (*feedlib.Nudge, error)

	// DeleteNudge permanently deletes a nudge and it's copies
	DeleteNudge(
		ctx context.Context,
		uid string,
		flavour feedlib.Flavour,
		nudgeID string,
	) error

	// getting THE LATEST VERSION OF a single action
	GetAction(
		ctx context.Context,
		uid string,
		flavour feedlib.Flavour,
		actionID string,
	) (*feedlib.Action, error)

	// saving a new action
	SaveAction(
		ctx context.Context,
		uid string,
		flavour feedlib.Flavour,
		action *feedlib.Action,
	) (*feedlib.Action, error)

	// DeleteAction permanently deletes an action and it's copies
	DeleteAction(
		ctx context.Context,
		uid string,
		flavour feedlib.Flavour,
		actionID string,
	) error

	// PostMessage posts a message or a reply to a message/thread
	PostMessage(
		ctx context.Context,
		uid string,
		flavour feedlib.Flavour,
		itemID string,
		message *feedlib.Message,
	) (*feedlib.Message, error)

	// GetMessage retrieves THE LATEST VERSION OF a message
	GetMessage(
		ctx context.Context,
		uid string,
		flavour feedlib.Flavour,
		itemID string,
		messageID string,
	) (*feedlib.Message, error)

	// DeleteMessage deletes a message
	DeleteMessage(
		ctx context.Context,
		uid string,
		flavour feedlib.Flavour,
		itemID string,
		messageID string,
	) error

	// GetMessages retrieves a message
	GetMessages(
		ctx context.Context,
		uid string,
		flavour feedlib.Flavour,
		itemID string,
	) ([]feedlib.Message, error)

	SaveIncomingEvent(
		ctx context.Context,
		event *feedlib.Event,
	) error

	SaveOutgoingEvent(
		ctx context.Context,
		event *feedlib.Event,
	) error

	GetNudges(
		ctx context.Context,
		uid string,
		flavour feedlib.Flavour,
		status *feedlib.Status,
		visibility *feedlib.Visibility,
		expired *feedlib.BooleanFilter,
	) ([]feedlib.Nudge, error)

	GetActions(
		ctx context.Context,
		uid string,
		flavour feedlib.Flavour,
	) ([]feedlib.Action, error)

	GetItems(
		ctx context.Context,
		uid string,
		flavour feedlib.Flavour,
		persistent feedlib.BooleanFilter,
		status *feedlib.Status,
		visibility *feedlib.Visibility,
		expired *feedlib.BooleanFilter,
		filterParams *helpers.FilterParams,
	) ([]feedlib.Item, error)

	Labels(
		ctx context.Context,
		uid string,
		flavour feedlib.Flavour,
	) ([]string, error)

	SaveLabel(
		ctx context.Context,
		uid string,
		flavour feedlib.Flavour,
		label string,
	) error

	UnreadPersistentItems(
		ctx context.Context,
		uid string,
		flavour feedlib.Flavour,
	) (int, error)

	UpdateUnreadPersistentItemsCount(
		ctx context.Context,
		uid string,
		flavour feedlib.Flavour,
	) error

	GetDefaultNudgeByTitle(
		ctx context.Context,
		uid string,
		flavour feedlib.Flavour,
		title string,
	) (*feedlib.Nudge, error)

	SaveTwilioResponse(
		ctx context.Context,
		data dto.Message,
	) error

	SaveNotification(
		ctx context.Context,
		firestoreClient *firestore.Client,
		notification dto.SavedNotification,
	) error

	RetrieveNotification(
		ctx context.Context,
		firestoreClient *firestore.Client,
		registrationToken string,
		newerThan time.Time,
		limit int,
	) ([]*dto.SavedNotification, error)

	SaveNPSResponse(
		ctx context.Context,
		response *dto.NPSResponse,
	) error

	SaveOutgoingEmails(
		ctx context.Context,
		payload *dto.OutgoingEmailsLog,
	) error
	UpdateMailgunDeliveryStatus(
		ctx context.Context,
		payload *dto.MailgunEvent,
	) (*dto.OutgoingEmailsLog, error)

	SaveTwilioVideoCallbackStatus(
		ctx context.Context,
		data dto.CallbackData,
	) error
}

Repository is the interface to be implemented by the database(s) The method signatures are should be database independent

func NewDbService

func NewDbService() Repository

NewDbService creates a new database service

Source Files

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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