model

package
v0.0.0-...-d1236c8 Latest Latest
Warning

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

Go to latest
Published: May 7, 2016 License: BSD-3-Clause Imports: 9 Imported by: 7

Documentation

Index

Constants

View Source
const OfferCollectionName = "offers"
View Source
const OfferGroupPostCollectionName = "offer_group_post"
View Source
const RegionCollectionName = "regions"
View Source
const RegistrationAccessTokenCollectionName = "registration_access_tokens"
View Source
const RestaurantCollectionName = "restaurants"
View Source
const TagCollectionName = "tags"
View Source
const UserCollectionName = "users"

UserCollectionName is the collection name used in the DB for users

Variables

This section is empty.

Functions

This section is empty.

Types

type CommonOfferFields

type CommonOfferFields struct {
	ID          bson.ObjectId   `json:"_id,omitempty"        bson:"_id,omitempty"`
	Restaurant  OfferRestaurant `json:"restaurant"           bson:"restaurant"`
	Title       string          `json:"title"                bson:"title"`
	FromTime    time.Time       `json:"from_time"            bson:"from_time"`
	ToTime      time.Time       `json:"to_time"              bson:"to_time"`
	Description string          `json:"description"          bson:"description"`
	Price       float64         `json:"price"                bson:"price"`
	Tags        []string        `json:"tags"                 bson:"tags"`
}

type DateWithoutTime

type DateWithoutTime string

func DateFromTime

func DateFromTime(t time.Time, loc *time.Location) DateWithoutTime

func (DateWithoutTime) IsValid

func (d DateWithoutTime) IsValid() bool

func (DateWithoutTime) TimeBounds

func (d DateWithoutTime) TimeBounds(location *time.Location) (time.Time, time.Time, error)

type FacebookPageToken

type FacebookPageToken struct {
	PageID string `bson:"page_id"`
	Token  string `bson:"token"`
}

type Location

type Location struct {
	Type        string    `json:"type" bson:"type"`
	Coordinates []float64 `json:"coordinates" bson:"coordinates"`
}

Location is a (limited) representation of a GeoJSON object

func NewPoint

func NewPoint(loc geo.Location) Location

NewPoint creates a Location object that get's marshalled into a GeoJSON object which mongo recognizes

type Offer

type Offer struct {
	// The bson marshaller (unlike the json one) doesn't automatically inline
	// embedded fields, so the inline tag has to be specified.
	CommonOfferFields `bson:",inline"`
	ImageChecksum     string `bson:"image_checksum,omitempty"`
}

Offer provides the mapping to the offers as represented in the DB

func MapOfferPOSTToOffer

func MapOfferPOSTToOffer(offer *OfferPOST, imageDataToChecksumMapper func(string) (string, error)) (*Offer, error)

type OfferGroupPost

type OfferGroupPost struct {
	ID           bson.ObjectId   `json:"_id,omitempty"       bson:"_id,omitempty"`
	RestaurantID bson.ObjectId   `json:"restaurant_id"       bson:"restaurant_id"`
	Date         DateWithoutTime `json:"date"                bson:"date"`

	MessageTemplate     string `json:"message_template"      bson:"message_template"`
	FBPostID            string `json:"fb_post_id,omitempty"  bson:"fb_post_id"`
	PostedImageChecksum uint32 `json:"posted_image_checksum" bson:"posted_image_checksum"`
}

type OfferImagePaths

type OfferImagePaths struct {
	Large     string `json:"large"`
	Thumbnail string `json:"thumbnail"`
}

OfferImagePaths holds paths to the various sizes of the offer's image

type OfferJSON

type OfferJSON struct {
	CommonOfferFields
	Image *OfferImagePaths `json:"image,omitempty"`
}

OfferJSON is the view of an offer that gets sent to the users

func MapOfferToJSON

func MapOfferToJSON(offer *Offer, imageToPathMapper func(string) (*OfferImagePaths, error)) (*OfferJSON, error)

type OfferPOST

type OfferPOST struct {
	CommonOfferFields
	ImageData string `json:"image_data,omitempty"`
}

OfferJSON is the view of an offer that gets sent to the users

type OfferRestaurant

type OfferRestaurant struct {
	ID       bson.ObjectId `json:"id"       bson:"id"`
	Name     string        `json:"name"     bson:"name"`
	Region   string        `json:"region"   bson:"region"`
	Address  string        `json:"address"  bson:"address"`
	Location Location      `json:"location" bson:"location"`
	Phone    string        `json:"phone"    bson:"phone"`
}

OfferRestaurant holds the information about the restaurant that gets included in every offer

type OfferRestaurantWithDistance

type OfferRestaurantWithDistance struct {
	OfferRestaurant
	Distance float64 `json:"distance"`
}

OfferRestaurantWithDistance wraps an OfferRestaurant and adds a distance field. This struct can be used to respond to queries about nearby offers.

type OfferWithDistance

type OfferWithDistance struct {
	Offer
	Restaurant OfferRestaurantWithDistance `json:"restaurant"`
}

OfferWithDistance wraps an offer and adds a distance field to the included restaurant struct. This struct can be used to respond to queries about nearby offers.

type OfferWithDistanceJSON

type OfferWithDistanceJSON struct {
	OfferJSON
	Restaurant OfferRestaurantWithDistance `json:"restaurant"`
}

OfferWithDistance wraps an offer's JSON representation and adds a distance field to the included restaurant struct. This struct can be used to respond to queries about nearby offers.

func MapOfferWithDistanceToJSON

func MapOfferWithDistanceToJSON(offer *OfferWithDistance, imageToPathMapper func(string) (*OfferImagePaths, error)) (*OfferWithDistanceJSON, error)

type Region

type Region struct {
	ID       bson.ObjectId `json:"_id,omitempty" bson:"_id,omitempty"`
	Name     string        `json:"name"          bson:"name"`
	Location string        `json:"location"      bson:"location"`
	// ccTLD (Country code top-level domain). Used to make more precise geocoding requests
	CCTLD string `json:"cctld,omitempty" bson:"cctld,omitempty"`
}

A Region specifies a town or a district supported by the application and the data related to this region, such as the time zone.

type RegistrationAccessToken

type RegistrationAccessToken struct {
	ID        bson.ObjectId `json:"_id,omitempty" bson:"_id,omitempty"`
	CreatedAt time.Time     `json:"created_at"    bson:"created_at"`
	Token     Token         `json:"token"         bson:"token"`
}

func NewRegistrationAccessToken

func NewRegistrationAccessToken() (*RegistrationAccessToken, error)

type Restaurant

type Restaurant struct {
	ID             bson.ObjectId `json:"_id,omitempty"              bson:"_id,omitempty"`
	Name           string        `json:"name"                       bson:"name"`
	Region         string        `json:"region"                     bson:"region"`
	Address        string        `json:"address"                    bson:"address"`
	Location       Location      `json:"location"                   bson:"location"`
	Phone          string        `json:"phone,omitempty"            bson:"phone,omitempty"`
	Email          string        `json:"email,omitempty"            bson:"email,omitempty"`
	Website        string        `json:"website,omitempty"          bson:"website,omitempty"`
	FacebookPageID string        `json:"facebook_page_id,omitempty" bson:"facebook_page_id,omitempty"`

	DefaultGroupPostMessageTemplate string `json:"default_group_post_message_template" bson:"default_group_post_message_template"`
}

type Tag

type Tag struct {
	ID          bson.ObjectId `json:"_id,omitempty" bson:"_id,omitempty"`
	Name        string        `json:"name"          bson:"name"`
	DisplayName string        `json:"display_name"  bson:"display_name"`
}

type Token

type Token [16]byte

func NewToken

func NewToken() (Token, error)

func TokenFromString

func TokenFromString(s string) (Token, error)

func (Token) String

func (t Token) String() string

type User

type User struct {
	ID             bson.ObjectId   `bson:"_id,omitempty"`
	RestaurantIDs  []bson.ObjectId `bson:"restaurant_ids,omitempty"`
	FacebookUserID string          `bson:"facebook_user_id"`
	Session        UserSession     `bson:"session,omitempty"`
}

User provides the mapping to the users as represented in the DB

type UserSession

type UserSession struct {
	ID                 string              `bson:"id,omitempty"`
	FacebookUserToken  oauth2.Token        `bson:"facebook_user_token,omitempty"`
	FacebookPageTokens []FacebookPageToken `bson:"facebook_page_tokens,omitempty"`
}

UserSession holds data about the current user session. Some of this data (facebook auth tokens, for example) may persist throughout multiple client sessions, however.

Jump to

Keyboard shortcuts

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