models

package
v0.4.7 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2019 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CreateRequest

type CreateRequest struct {
	URL           string  `json:"url"`
	XPATH         string  `json:"xpath"`
	Name          string  `json:"name"`
	ExpectedPrice string  `json:"expectedPrice"`
	Options       Options `json:"options,omitempty"`
}

CreateRequest defines the contract to add an entry

func (*CreateRequest) Validate

func (r *CreateRequest) Validate() error

Validate validates

type CreateResponse

type CreateResponse struct {
	OK      bool           `json:"ok"`
	Message string         `json:"message"`
	Key     *datastore.Key `json:"key,omitempty"`
}

CreateResponse returns whether create is successful

type DataPoint

type DataPoint struct {
	Timestamp time.Time
	Price     string
}

DataPoint aka each data record

type Entity

type Entity struct {
	K         *datastore.Key `json:",omitempty" datastore:"__key__"`
	Options   Options        `json:",omitempty" datastore:",noindex"`
	URL       string         `json:",omitempty" datastore:",noindex"`
	XPATH     string         `json:",omitempty" datastore:",noindex"`
	Name      string         `json:",omitempty"`
	NextCheck time.Time      `json:",omitempty"`
	History   []DataPoint    `json:",omitempty" datastore:",noindex"`
}

Entity is the data structure for datastore entry

func (*Entity) Save

func (entity *Entity) Save(ctx context.Context, entTypName string, dsClient *datastore.Client, check bool) (err error)

Save saves the entry in the datastore

func (*Entity) String added in v0.3.0

func (entity *Entity) String() string

String returns a String representation History has been skipped to save text space but the last one will be there

type Options

type Options struct {
	User       string  `json:"user"`
	CheckFreq  int16   `json:"checkFreq"` // in minutes
	AlertType  string  `json:"alertType"`
	Threshold  float32 `json:"threshold"`
	MaxRecords int16   `json:"maxRecords"`
	UseChrome  bool    `json:"useChrome"`
}

Options is the options for an entry

type ReadOrDelRequest

type ReadOrDelRequest struct {
	Key *datastore.Key `json:"key"`
}

ReadOrDelRequest defines the contract to read/delete an entry

func (*ReadOrDelRequest) Validate

func (r *ReadOrDelRequest) Validate() error

Validate validates

type ReadOrDelResponse

type ReadOrDelResponse struct {
	OK      bool    `json:"ok"`
	Message string  `json:"message"`
	Entity  *Entity `json:"entity,omitempty"`
}

ReadOrDelResponse returns whether read or del is successful

type UpdateRequest

type UpdateRequest struct {
	URL       string         `json:"url"`
	XPATH     string         `json:"xpath"`
	Name      string         `json:"name"`
	Key       *datastore.Key `json:"key"`
	UseChrome *bool          `json:"useChrome,omitempty"`
	Options   *Options       `json:"options,omitempty"`
}

UpdateRequest defines the contract to update an entry

func (*UpdateRequest) Validate

func (r *UpdateRequest) Validate() error

Validate validates

Jump to

Keyboard shortcuts

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