model

package
v3.1.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2018 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LineBotEventTypeMessage  LineBotEventType = "message"
	LineBotEventTypeFollow   LineBotEventType = "follow"
	LineBotEventTypeUnfollow LineBotEventType = "unfollow"

	LineBotMessageTypeText LineBotMessageType = "text"
)
View Source
const (
	UstreamStatusID = "ustream_status"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type CreateTimestamper

type CreateTimestamper interface {
	SetCreatedAt(time.Time)
	GetCreatedAt() time.Time
}

CreateTimestamper provides set current timestamp to entity when save if not already set

type FeedCode

type FeedCode string

FeedCode represents identify code of feed

const (
	FeedCodeMomota   FeedCode = "momota-sd"
	FeedCodeAriyasu  FeedCode = "ariyasu-sd"
	FeedCodeTamai    FeedCode = "tamai-sd"
	FeedCodeSasaki   FeedCode = "sasaki-sd"
	FeedCodeTakagi   FeedCode = "takagi-sd"
	FeedCodeHappyclo FeedCode = "happyclo"
	FeedCodeAeNews   FeedCode = "aenews"
	FeedCodeYoutube  FeedCode = "youtube"
)

func (FeedCode) String

func (f FeedCode) String() string

String returns string representation of FeedCode

type FeedFetcher

type FeedFetcher interface {
	Fetch(code FeedCode, maxItemNum int, latestURL string) ([]FeedItem, error)
}

FeedFetcher interface

type FeedItem

type FeedItem struct {
	Title       string `validate:"required"`
	URL         string `validate:"required,url"`
	EntryTitle  string `validate:"required"`
	EntryURL    string `validate:"required,url"`
	ImageURLs   []string
	VideoURLs   []string
	PublishedAt time.Time `validate:"required"`
}

FeedItem represents an entry in the feed

func (FeedItem) UniqueURL

func (i FeedItem) UniqueURL() string

UniqueURL builds unique url

type ImageSearchResult

type ImageSearchResult struct {
	URL          string
	ThumbnailURL string
}

ImageSearchResult represents custom search image result

type ImageSearcher

type ImageSearcher interface {
	Search(string) (ImageSearchResult, error)
}

ImageSearcher represents google custom search image api

type LatestEntry

type LatestEntry struct {
	ID          string    `datastore:"-" goon:"id"`
	Code        FeedCode  `validate:"required"`
	URL         string    `validate:"required,url"`
	PublishedAt time.Time `validate:"required"`
	CreatedAt   time.Time `validate:"required"`
	UpdatedAt   time.Time `validate:"required"`
}

LatestEntry for confirm last updated entry url

func NewLatestEntry

func NewLatestEntry(urlStr string) (*LatestEntry, error)

NewLatestEntry builds *LatestEntry given url

func (*LatestEntry) BeforeSave

func (l *LatestEntry) BeforeSave()

BeforeSave hook

func (*LatestEntry) GetCreatedAt

func (l *LatestEntry) GetCreatedAt() time.Time

GetCreatedAt gets CreatedAt

func (*LatestEntry) SetCreatedAt

func (l *LatestEntry) SetCreatedAt(t time.Time)

SetCreatedAt sets given time to CreatedAt

func (*LatestEntry) SetUpdatedAt

func (l *LatestEntry) SetUpdatedAt(t time.Time)

SetUpdatedAt sets given time to UpdatedAt

type LatestEntryRepository

type LatestEntryRepository interface {
	Save(*LatestEntry) error
	FindOrNewByURL(string) (*LatestEntry, error)
	GetURL(string) string
}

LatestEntryRepository interface

type LineBot

type LineBot interface {
	ReplyText(string, string) error
	ReplyImage(string, string, string) error
}

LineBot represents line bot conversations

type LineBotEvent

type LineBotEvent struct {
	ReplyToken  string
	Type        LineBotEventType
	MessageType LineBotMessageType
	TextMessage LineBotTextMessage
}

LineBotEvent represents line bot event

type LineBotEventType

type LineBotEventType string

LineBotEventType represents line bot event type

type LineBotMessageType

type LineBotMessageType string

LineBotMessageType represents line bot message type

type LineBotTextMessage

type LineBotTextMessage struct {
	ID   string
	Text string
}

LineBotTextMessage represents line bot text message

type LineItem

type LineItem struct {
	ID          string    `datastore:"-" goon:"id" validate:"required"`
	Title       string    `validate:"required"`
	URL         string    `validate:"required,url"`
	PublishedAt time.Time `validate:"required"`
	ImageURLs   string    `datastore:",noindex"`
	VideoURLs   string    `datastore:",noindex"`
	CreatedAt   time.Time `validate:"required"`
}

LineItem represents line notification history

func NewLineItem

func NewLineItem(params FeedItem) *LineItem

NewLineItem returns LineItem given FeedItem

func (*LineItem) BeforeSave

func (e *LineItem) BeforeSave()

BeforeSave hook

func (*LineItem) GetCreatedAt

func (e *LineItem) GetCreatedAt() time.Time

GetCreatedAt gets CreatedAt

func (*LineItem) SetCreatedAt

func (e *LineItem) SetCreatedAt(t time.Time)

SetCreatedAt sets given time to CreatedAt

type LineItemRepository

type LineItemRepository interface {
	Exists(string) bool
	Find(string) (*LineItem, error)
	Save(*LineItem) error
	Tx(PersistenceHandler) LineItemRepository
}

LineItemRepository interface

type LineNotification

type LineNotification struct {
	ID         string `datastore:"-" goon:"id" validate:"required"`
	TokenCrypt string `datastore:",noindex" validate:"required"`
	Admin      bool
	CreatedAt  time.Time `validate:"required"`
}

LineNotification represents user tokens that published by LINE Notify the token is encrypted

func NewLineNotification

func NewLineNotification(tokenKey, token string) (*LineNotification, error)

NewLineNotification returns LineNotification given key and token

func (*LineNotification) BeforeSave

func (l *LineNotification) BeforeSave()

BeforeSave hook

func (*LineNotification) GetCreatedAt

func (l *LineNotification) GetCreatedAt() time.Time

GetCreatedAt gets CreatedAt

func (*LineNotification) SetCreatedAt

func (l *LineNotification) SetCreatedAt(t time.Time)

SetCreatedAt sets given time to CreatedAt

func (*LineNotification) Token

func (l *LineNotification) Token(tokenKey string) (string, error)

Token returns decrypted token

type LineNotificationRepository

type LineNotificationRepository interface {
	FindAll() ([]*LineNotification, error)
	Save(*LineNotification) error
	Delete(string) error
}

LineNotificationRepository interface

type LineNotify

type LineNotify interface {
	Notify(string, LineNotifyMessage) error
}

LineNotify interface

type LineNotifyMessage

type LineNotifyMessage struct {
	Text     string `validate:"required"`
	ImageURL string `validate:"omitempty,url"`
}

LineNotifyMessage represents text message and image

type LineNotifyRequest

type LineNotifyRequest struct {
	ID          string              `validate:"required"`
	AccessToken string              `validate:"required"`
	Messages    []LineNotifyMessage `validate:"min=1,dive"`
}

LineNotifyRequest represents request that notification message

type LineNotifyToken

type LineNotifyToken interface {
	GetAccessToken(string) (string, error)
}

LineNotifyToken interface

type PersistenceBeforeSaver

type PersistenceBeforeSaver interface {
	BeforeSave()
}

PersistenceBeforeSaver hook

type PersistenceHandler

type PersistenceHandler interface {
	Kind(interface{}) string
	Put(interface{}) error
	PutMulti(interface{}) error
	Get(interface{}) error
	GetMulti(interface{}) error
	Delete(interface{}) error
	DeleteMulti(interface{}) error
	NewQuery(string) PersistenceQuery
	GetAll(PersistenceQuery, interface{}) error
	FlushLocalCache()
}

PersistenceHandler represents persist operations

type PersistenceQuery

type PersistenceQuery interface {
	Filter(string, interface{}) PersistenceQuery
}

PersistenceQuery interface

type Reminder

type Reminder struct {
	ID      int64  `datastore:"-" goon:"id"`
	Text    string `validate:"required"`
	Type    ReminderType
	Enabled bool

	// Once
	RemindAt time.Time `datastore:",noindex"`

	// Weekly
	Weekday time.Weekday `datastore:",noindex"`
	Hour    int          `datastore:",noindex"`
	Minute  int          `datastore:",noindex"`
}

Reminder represents any remind information

func NewReminderOnce

func NewReminderOnce(text string, remindAt time.Time) *Reminder

NewReminderOnce builds one-time reminder

func NewReminderWeekly

func NewReminderWeekly(text string, weekday time.Weekday, hour int, minute int) *Reminder

NewReminderWeekly builds weekly reminder

func (*Reminder) Disable

func (r *Reminder) Disable()

Disable disabled remind

func (*Reminder) IsOneTime

func (r *Reminder) IsOneTime() bool

IsOneTime returns true if reminder type is one-time

func (*Reminder) Valid

func (r *Reminder) Valid(now time.Time) (bool, error)

Valid returns true if reminder on time

type ReminderRepository

type ReminderRepository interface {
	FindAll() ([]*Reminder, error)
	Save(*Reminder) error
}

ReminderRepository interface

type ReminderType

type ReminderType int

ReminderType type

const (
	ReminderOneTime ReminderType = iota
	ReminderWeekly
)

type TransactionOptions

type TransactionOptions struct {
	XG       bool
	Attempts int
}

TransactionOptions represents transaction options (TODO: want to eliminate datastore dependence but no ideas)

type Transactor

type Transactor interface {
	RunInTransaction(func(PersistenceHandler) error, *TransactionOptions) error
}

Transactor provides transaction across entities

type TweetItem

type TweetItem struct {
	ID          string    `datastore:"-" goon:"id" validate:"required"`
	Title       string    `validate:"required"`
	URL         string    `validate:"required,url"`
	PublishedAt time.Time `validate:"required"`
	ImageURLs   string    `datastore:",noindex"`
	VideoURLs   string    `datastore:",noindex"`
	CreatedAt   time.Time `validate:"required"`
}

TweetItem represents tweet history

func NewTweetItem

func NewTweetItem(params FeedItem) *TweetItem

NewTweetItem returns TweetItem given FeedItem

func (*TweetItem) BeforeSave

func (e *TweetItem) BeforeSave()

BeforeSave hook

func (*TweetItem) GetCreatedAt

func (e *TweetItem) GetCreatedAt() time.Time

GetCreatedAt gets CreatedAt

func (*TweetItem) SetCreatedAt

func (e *TweetItem) SetCreatedAt(t time.Time)

SetCreatedAt sets given time to CreatedAt

type TweetItemRepository

type TweetItemRepository interface {
	Exists(string) bool
	Find(string) (*TweetItem, error)
	Save(*TweetItem) error
	Tx(PersistenceHandler) TweetItemRepository
}

TweetItemRepository interface

type TweetRequest

type TweetRequest struct {
	InReplyToStatusID string
	Text              string
	ImageURLs         []string `validate:"dive,omitempty,url"`
	VideoURL          string   `validate:"omitempty,url"`
}

TweetRequest represents request that tweet message, img urls and video url data

type TweetResponse

type TweetResponse struct {
	IDStr string
}

TweetResponse represents response tweet data

type Tweeter

type Tweeter interface {
	Tweet(TweetRequest) (TweetResponse, error)
}

Tweeter interface

type UpdateTimestamper

type UpdateTimestamper interface {
	SetUpdatedAt(time.Time)
}

UpdateTimestamper provides set current timestamp to entity when save

type UstreamStatus

type UstreamStatus struct {
	ID     string `datastore:"-" goon:"id" validate:"required"`
	IsLive bool
}

UstreamStatus represents ustream status

func NewUstreamStatus

func NewUstreamStatus() *UstreamStatus

NewUstreamStatus returns UstreamStatus

type UstreamStatusChecker

type UstreamStatusChecker interface {
	IsLive() (bool, error)
}

UstreamStatusChecker interface

type UstreamStatusRepository

type UstreamStatusRepository interface {
	Find(string) (*UstreamStatus, error)
	Save(*UstreamStatus) error
}

UstreamStatusRepository interface

Jump to

Keyboard shortcuts

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