places

package
v0.1.0 Latest Latest
Warning

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

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

Documentation

Overview

Package places defines types for interacting with the Google Places API.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AccessibilityOptions

type AccessibilityOptions struct {
	WheelchairAccessibleEntrance bool `json:"wheelchairAccessibleEntrance,omitempty"`
	WheelchairAccessibleParking  bool `json:"wheelchairAccessibleParking,omitempty"`
	WheelchairAccessibleRestroom bool `json:"wheelchairAccessibleRestroom,omitempty"`
	WheelchairAccessibleSeating  bool `json:"wheelchairAccessibleSeating,omitempty"`
}

type AddressComponent

type AddressComponent struct {
	LanguageCode string   `json:"languageCode,omitempty"`
	LongText     string   `json:"longText,omitempty"`
	ShortText    string   `json:"shortText,omitempty"`
	Types        []string `json:"types,omitempty"`
}

type AreaSummary

type AreaSummary struct {
	ContentBlocks []*ContentBlock `json:"contentBlocks,omitempty"`
}

type Attribution

type Attribution struct {
	Provider    string `json:"provider,omitempty"`
	ProviderURI string `json:"providerUri,omitempty"`
}

type AuthorAttribution

type AuthorAttribution struct {
	DisplayName string `json:"displayName,omitempty"`
	PhotoURI    string `json:"photoUri,omitempty"`
	URI         string `json:"uri,omitempty"`
}

type CachingService

type CachingService struct {
	// contains filtered or unexported fields
}

CachingService is a Service that permanently caches place lookups in a bolt database.

func NewCachingService

func NewCachingService(filename string, next Service) (*CachingService, error)

NewCachingService creates a new CachingService that "wraps" the given Service and caches lookups in the given filename.

func (*CachingService) Close

func (s *CachingService) Close() error

Close closes the cache database.

func (*CachingService) GetPlace

func (s *CachingService) GetPlace(ctx context.Context, id string) (*Place, error)

GetPlace looks up a Place by ID. If the place is in the cache, it is returned. Otherwise the wrapped Service is called to fetch it, and the result is stored in the cache before being returned.

type ConnectorAggregation

type ConnectorAggregation struct {
	AvailabilityLastUpdateTime string  `json:"availabilityLastUpdateTime,omitempty"`
	AvailableCount             int64   `json:"availableCount,omitempty"`
	Count                      int64   `json:"count,omitempty"`
	MaxChargeRateKW            float64 `json:"maxChargeRateKw,omitempty"`
	OutOfServiceCount          int64   `json:"outOfServiceCount,omitempty"`
	Type                       string  `json:"type,omitempty"`
}

type ContentBlock

type ContentBlock struct {
	Content    *LocalizedText `json:"content,omitempty"`
	References *Places        `json:"references,omitempty"`
	Topic      string         `json:"topic,omitempty"`
}

type Date

type Date struct {
	Day   int64 `json:"day,omitempty"`
	Month int64 `json:"month,omitempty"`
	Year  int64 `json:"year,omitempty"`
}

type EVChargeOptions

type EVChargeOptions struct {
	ConnectorAggregation []*ConnectorAggregation `json:"connectorAggregation,omitempty"`
	ConnectorCount       int64                   `json:"connectorCount,omitempty"`
}

type FuelOptions

type FuelOptions struct {
	FuelPrices []*FuelPrice `json:"fuelPrices,omitempty"`
}

type FuelPrice

type FuelPrice struct {
	Price      *Money `json:"price,omitempty"`
	Type       string `json:"type,omitempty"`
	UpdateTime string `json:"updateTime,omitempty"`
}

type GenerativeSummary

type GenerativeSummary struct {
	Description *LocalizedText `json:"description,omitempty"`
	Overview    *LocalizedText `json:"overview,omitempty"`
	References  *References    `json:"references,omitempty"`
}

type LatLng

type LatLng struct {
	Latitude  float64 `json:"latitude,omitempty"`
	Longitude float64 `json:"longitude,omitempty"`
}

type LocalizedText

type LocalizedText struct {
	LanguageCode string `json:"languageCode,omitempty"`
	Text         string `json:"text,omitempty"`
}

type Money

type Money struct {
	CurrencyCode string `json:"currencyCode,omitempty"`
	Nanos        int64  `json:"nanos,omitempty"`
	Units        string `json:"units,omitempty"`
}

type OpeningHours

type OpeningHours struct {
	OpenNow             bool         `json:"openNow,omitempty"`
	Periods             []*Period    `json:"periods,omitempty"`
	SecondaryHoursType  string       `json:"secondaryHoursType,omitempty"`
	SpecialDays         []SpecialDay `json:"specialDays,omitempty"`
	WeekdayDescriptions []string     `json:"weekdayDescriptions,omitempty"`
}

type ParkingOptions

type ParkingOptions struct {
	FreeParkingLot    bool `json:"freeParkingLot,omitempty"`
	FreeStreetParking bool `json:"freeStreetParking,omitempty"`
	PaidStreetParking bool `json:"paidStreetParking,omitempty"`
	ValetParking      bool `json:"valetParking,omitempty"`
}

type PaymentOptions

type PaymentOptions struct {
	AcceptsCashOnly    bool `json:"acceptsCashOnly,omitempty"`
	AcceptsCreditCards bool `json:"acceptsCreditCards,omitempty"`
	AcceptsDebitCards  bool `json:"acceptsDebitCards,omitempty"`
	AcceptsNfc         bool `json:"acceptsNfc,omitempty"`
}

type Period

type Period struct {
	Close *Point `json:"close,omitempty"`
	Open  *Point `json:"open,omitempty"`
}

type Photo

type Photo struct {
	AuthorAttributions []*AuthorAttribution `json:"authorAttributions,omitempty"`
	HeightPx           int64                `json:"heightPx,omitempty"`
	Name               string               `json:"name,omitempty"`
	WidthPx            int64                `json:"widthPx,omitempty"`
}

type Place

type Place struct {
	AccessibilityOptions         *AccessibilityOptions `json:"accessibilityOptions,omitempty"`
	AddressComponents            []*AddressComponent   `json:"addressComponents,omitempty"`
	AdrFormatAddress             string                `json:"adrFormatAddress,omitempty"`
	AllowsDogs                   bool                  `json:"allowsDogs,omitempty"`
	AreaSummary                  *AreaSummary          `json:"areaSummary,omitempty"`
	Attributions                 []*Attribution        `json:"attributions,omitempty"`
	BusinessStatus               string                `json:"businessStatus,omitempty"`
	CurbsidePickup               bool                  `json:"curbsidePickup,omitempty"`
	CurrentOpeningHours          *OpeningHours         `json:"currentOpeningHours,omitempty"`
	CurrentSecondaryOpeningHours []*OpeningHours       `json:"currentSecondaryOpeningHours,omitempty"`
	Delivery                     bool                  `json:"delivery,omitempty"`
	DineIn                       bool                  `json:"dineIn,omitempty"`
	DisplayName                  *LocalizedText        `json:"displayName,omitempty"`
	EditorialSummary             *LocalizedText        `json:"editorialSummary,omitempty"`
	EVChargeOptions              *EVChargeOptions      `json:"evChargeOptions,omitempty"`
	FormattedAddress             string                `json:"formattedAddress,omitempty"`
	FuelOptions                  *FuelOptions          `json:"fuelOptions,omitempty"`
	GenerativeSummary            *GenerativeSummary    `json:"generativeSummary,omitempty"`
	GoodForChildren              bool                  `json:"goodForChildren,omitempty"`
	GoodForGroups                bool                  `json:"goodForGroups,omitempty"`
	GoodForWatchingSports        bool                  `json:"goodForWatchingSports,omitempty"`
	GoogleMapsURI                string                `json:"googleMapsUri,omitempty"`
	IconBackgroundColor          string                `json:"iconBackgroundColor,omitempty"`
	IconMaskBaseURI              string                `json:"iconMaskBaseUri,omitempty"`
	ID                           string                `json:"id,omitempty"`
	InternationalPhoneNumber     string                `json:"internationalPhoneNumber,omitempty"`
	LiveMusic                    bool                  `json:"liveMusic,omitempty"`
	Location                     *LatLng               `json:"location,omitempty"`
	MenuForChildren              bool                  `json:"menuForChildren,omitempty"`
	Name                         string                `json:"name,omitempty"`
	NationalPhoneNumber          string                `json:"nationalPhoneNumber,omitempty"`
	OutdoorSeating               bool                  `json:"outdoorSeating,omitempty"`
	ParkingOptions               *ParkingOptions       `json:"parkingOptions,omitempty"`
	PaymentOptions               *PaymentOptions       `json:"paymentOptions,omitempty"`
	Photos                       []*Photo              `json:"photos,omitempty"`
	PlusCode                     *PlusCode             `json:"plusCode,omitempty"`
	PriceLevel                   string                `json:"priceLevel,omitempty"`
	PrimaryType                  string                `json:"primaryType,omitempty"`
	PrimaryTypeDisplayName       *LocalizedText        `json:"primaryTypeDisplayName,omitempty"`
	Rating                       float64               `json:"rating,omitempty"`
	RegularOpeningHours          *OpeningHours         `json:"regularOpeningHours,omitempty"`
	RegularSecondaryOpeningHours []*OpeningHours       `json:"regularSecondaryOpeningHours,omitempty"`
	Reservable                   bool                  `json:"reservable,omitempty"`
	Restroom                     bool                  `json:"restroom,omitempty"`
	Reviews                      []*Review             `json:"reviews,omitempty"`
	ServesBeer                   bool                  `json:"servesBeer,omitempty"`
	ServesBreakfast              bool                  `json:"servesBreakfast,omitempty"`
	ServesBrunch                 bool                  `json:"servesBrunch,omitempty"`
	ServesCocktails              bool                  `json:"servesCocktails,omitempty"`
	ServesCoffee                 bool                  `json:"servesCoffee,omitempty"`
	ServesDessert                bool                  `json:"servesDessert,omitempty"`
	ServesDinner                 bool                  `json:"servesDinner,omitempty"`
	ServesLunch                  bool                  `json:"servesLunch,omitempty"`
	ServesVegetarianFood         bool                  `json:"servesVegetarianFood,omitempty"`
	ServesWine                   bool                  `json:"servesWine,omitempty"`
	ShortFormattedAddress        string                `json:"shortFormattedAddress,omitempty"`
	SubDestinations              []*SubDestination     `json:"subDestinations,omitempty"`
	Takeout                      bool                  `json:"takeout,omitempty"`
	Types                        []string              `json:"types,omitempty"`
	UserRatingCount              int64                 `json:"userRatingCount,omitempty"`
	UtcOffsetMinutes             int64                 `json:"utcOffsetMinutes,omitempty"`
	Viewport                     *Viewport             `json:"viewport,omitempty"`
	WebsiteURI                   string                `json:"websiteUri,omitempty"`
}

Place is a Google Places API place. This data type was generated by github.com/bobg/gjtypes, supplemented by information at https://developers.google.com/maps/documentation/places/web-service/reference/rest/v1/places.

type Places

type Places struct {
	Places []string `json:"places,omitempty"`
}

type PlusCode

type PlusCode struct {
	CompoundCode string `json:"compoundCode,omitempty"`
	GlobalCode   string `json:"globalCode,omitempty"`
}

type Point

type Point struct {
	Date      *Date `json:"date,omitempty"`
	Day       int64 `json:"day,omitempty"`
	Hour      int64 `json:"hour,omitempty"`
	Minute    int64 `json:"minute,omitempty"`
	Truncated bool  `json:"truncated,omitempty"`
}

type RateLimitedService

type RateLimitedService struct {
	// contains filtered or unexported fields
}

RateLimitedService is a Service that limits the rate at which it calls another Service.

func NewRateLimitedService

func NewRateLimitedService(limit rate.Limit, next Service) *RateLimitedService

NewRateLimitedService creates a new RateLimitedService that "wraps" the given Service and limits the rate at which it calls it.

func (*RateLimitedService) GetPlace

func (s *RateLimitedService) GetPlace(ctx context.Context, id string) (*Place, error)

GetPlace calls the wrapped Service's GetPlace method, subject to rate limiting.

type RealService

type RealService struct {
	// contains filtered or unexported fields
}

RealService is an implementation of Service that talks to the Google Places API.

func NewRealService

func NewRealService(ctx context.Context, creds []byte, tokenFile string) (*RealService, error)

NewRealService creates a new RealService. It reads the Google API credentials from creds, and the OAuth token from tokenFile. If there is no valid token in tokenFile, it will open the user's browser to obtain one and write it to the file.

func (*RealService) GetPlace

func (s *RealService) GetPlace(ctx context.Context, id string) (*Place, error)

GetPlace returns a place by its ID.

type References

type References struct {
	Places  []string  `json:"places,omitempty"`
	Reviews []*Review `json:"reviews,omitempty"`
}

type Review

type Review struct {
	AuthorAttribution              *AuthorAttribution `json:"authorAttribution,omitempty"`
	Name                           string             `json:"name,omitempty"`
	OriginalText                   *LocalizedText     `json:"originalText,omitempty"`
	PublishTime                    string             `json:"publishTime,omitempty"`
	Rating                         int64              `json:"rating,omitempty"`
	RelativePublishTimeDescription string             `json:"relativePublishTimeDescription,omitempty"`
	Text                           *LocalizedText     `json:"text,omitempty"`
}

type Service

type Service interface {
	GetPlace(context.Context, string) (*Place, error)
}

Service is a service that can supply Google Place API objects given a place ID.

type SpecialDay

type SpecialDay struct {
	Date *Date `json:"date,omitempty"`
}

type SubDestination

type SubDestination struct {
	Name string `json:"name,omitempty"`
	ID   string `json:"id,omitempty"`
}

type Viewport

type Viewport struct {
	High *LatLng `json:"high,omitempty"`
	Low  *LatLng `json:"low,omitempty"`
}

Jump to

Keyboard shortcuts

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