Documentation
¶
Index ¶
- Constants
- type CommonOfferFields
- type DateWithoutTime
- type FacebookPageToken
- type Location
- type Offer
- type OfferGroupPost
- type OfferImagePaths
- type OfferJSON
- type OfferPOST
- type OfferRestaurant
- type OfferRestaurantWithDistance
- type OfferWithDistance
- type OfferWithDistanceJSON
- type Region
- type RegistrationAccessToken
- type Restaurant
- type Tag
- type Token
- type User
- type UserSession
Constants ¶
const OfferCollectionName = "offers"
const OfferGroupPostCollectionName = "offer_group_post"
const RegionCollectionName = "regions"
const RegistrationAccessTokenCollectionName = "registration_access_tokens"
const RestaurantCollectionName = "restaurants"
const TagCollectionName = "tags"
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 ¶
type FacebookPageToken ¶
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
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
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 ¶
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 ¶
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 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.