mapping

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ByLastModified

type ByLastModified []model.InternalNotification

ByLastModified sorts InternalNotifications by last modified date.

func (ByLastModified) Len

func (s ByLastModified) Len() int

func (ByLastModified) Less

func (s ByLastModified) Less(i, j int) bool

func (ByLastModified) Swap

func (s ByLastModified) Swap(i, j int)

type DefaultMapper

type DefaultMapper struct {
	ApiHost string
}

DefaultMapper is the standard NotificationsMapper implementation

func (DefaultMapper) MapInternalNotificationToPublic

func (m DefaultMapper) MapInternalNotificationToPublic(notification model.InternalNotification) model.PublicNotification

MapInternalNotificationToPublic maps an InternalNotification to a PublicNotification

func (DefaultMapper) MapRequestToInternalNotification

func (m DefaultMapper) MapRequestToInternalNotification(uuid string, decoder *json.Decoder) (*model.InternalNotification, error)

MapRequestToInternalNotification maps json (from a decoder) to an InternalNotification

type NextLinkGenerator

type NextLinkGenerator interface {
	NextLink(since time.Time, offset int, notifications []model.InternalNotification) model.Link
	ProcessRequestLink(uri *url.URL) *url.URL
}

NextLinkGenerator returns the link to the next result set in a paginated response.

type NotificationsMapper

type NotificationsMapper interface {
	MapRequestToInternalNotification(uuid string, decoder *json.Decoder) (*model.InternalNotification, error)
	MapInternalNotificationToPublic(notification model.InternalNotification) model.PublicNotification
}

NotificationsMapper maps notifications from json to internal and internal to public.

type OffsetNextLink struct {
	ApiHost    string
	CacheDelay int
	MaxLimit   int
}

OffsetNextLink is the default implementation for NextLinkGenerator

func (o OffsetNextLink) NextLink(since time.Time, offset int, notifications []model.InternalNotification) model.Link

NextLink given the since date and offset from the original incoming request, and the notifications read from the db, return the 'next' link

func (o OffsetNextLink) ProcessRequestLink(uri *url.URL) *url.URL

Jump to

Keyboard shortcuts

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