recreation

package module
v0.0.9 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2022 License: MIT Imports: 8 Imported by: 0

README

recreation

Modern problems require modern solutions.

non brute force

users table
  • job query
  • active: bool
  • id
checks table
  • time
  • result
  • userid
  • notification sent (?)

was result good -->

notifications table
  • check id
  • done

brute force

users table
  • job query
  • active: bool
  • id

query

  • campground
  • list of sites on ground
  • dates

Documentation

Index

Constants

View Source
const (
	RecreationGovURI = "https://www.recreation.gov"

	UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36"
)

Variables

This section is empty.

Functions

func GetStartOfMonth

func GetStartOfMonth(input time.Time) time.Time

Types

type Availability

type Availability struct {
	Campsites map[string]Campsite `json:"campsites,omitempty"`
	Count     int                 `json:"count,omitempty"`
}

type CampGround added in v0.0.2

type CampGround struct {
	AccessibleCampsitesCount int `json:"accessible_campsites_count,omitempty"`
	Activities               []struct {
		ActivityDescription    string `json:"activity_description"`
		ActivityFeeDescription string `json:"activity_fee_description"`
		ActivityID             int    `json:"activity_id"`
		ActivityName           string `json:"activity_name"`
	} `json:"activities"`
	Addresses []struct {
		AddressType    string `json:"address_type"`
		City           string `json:"city"`
		CountryCode    string `json:"country_code"`
		PostalCode     string `json:"postal_code"`
		StateCode      string `json:"state_code"`
		StreetAddress1 string `json:"street_address1"`
		StreetAddress2 string `json:"street_address2"`
		StreetAddress3 string `json:"street_address3"`
	} `json:"addresses"`
	AggregateCellCoverage float64   `json:"aggregate_cell_coverage,omitempty"`
	AverageRating         float64   `json:"average_rating,omitempty"`
	CampsiteAccessible    int       `json:"campsite_accessible,omitempty"`
	CampsiteEquipmentName []string  `json:"campsite_equipment_name,omitempty"`
	CampsiteReserveType   []string  `json:"campsite_reserve_type"`
	CampsiteTypeOfUse     []string  `json:"campsite_type_of_use"`
	CampsitesCount        string    `json:"campsites_count"`
	City                  string    `json:"city"`
	CountryCode           string    `json:"country_code"`
	Description           string    `json:"description"`
	Directions            string    `json:"directions"`
	Distance              string    `json:"distance"`
	EntityID              string    `json:"entity_id"`
	EntityType            string    `json:"entity_type"`
	GoLiveDate            time.Time `json:"go_live_date"`
	HTMLDescription       string    `json:"html_description"`
	ID                    string    `json:"id"`
	Latitude              string    `json:"latitude"`
	Links                 []struct {
		Description string `json:"description"`
		LinkType    string `json:"link_type"`
		Title       string `json:"title"`
		URL         string `json:"url"`
	} `json:"links"`
	Longitude string `json:"longitude"`
	Name      string `json:"name"`
	Notices   []struct {
		Text string `json:"text"`
		Type string `json:"type"`
	} `json:"notices"`
	NumberOfRatings int    `json:"number_of_ratings,omitempty"`
	OrgID           string `json:"org_id"`
	OrgName         string `json:"org_name"`
	ParentID        string `json:"parent_id"`
	ParentName      string `json:"parent_name"`
	ParentType      string `json:"parent_type"`
	PreviewImageURL string `json:"preview_image_url"`
	PriceRange      struct {
		AmountMax int    `json:"amount_max"`
		AmountMin int    `json:"amount_min"`
		PerUnit   string `json:"per_unit"`
	} `json:"price_range,omitempty"`
	Rate []struct {
		EndDate time.Time `json:"end_date"`
		Prices  []struct {
			Amount    int    `json:"amount"`
			Attribute string `json:"attribute"`
		} `json:"prices"`
		RateMap map[string]struct {
			GroupFees        interface{} `json:"group_fees"`
			SingleAmountFees Fees        `json:"single_amount_fees"`
		} `json:"rate_map"`
		SeasonDescription string    `json:"season_description"`
		SeasonType        string    `json:"season_type"`
		StartDate         time.Time `json:"start_date"`
	} `json:"rate"`
	Reservable bool   `json:"reservable"`
	StateCode  string `json:"state_code"`
	TimeZone   string `json:"time_zone,omitempty"`
	Type       string `json:"type"`
}

type Campsite

type Campsite struct {
	// keeping this as a string even though it's a time object for less processing
	Availabilities map[string]string `json:"availabilities"`

	CampsiteID          string `json:"campsite_id"`
	CampsiteReserveType string `json:"campsite_reserve_type"`
	CampsiteType        string `json:"campsite_type"`
	CapacityRating      string `json:"capacity_rating"`
	Loop                string `json:"loop"`
	MaxNumPeople        int    `json:"max_num_people"`
	MinNumPeople        int    `json:"min_num_people"`
	Site                string `json:"site"` // not sure what this represents
	TypeOfUse           string `json:"type_of_use"`

	// TODO: find example of this. haven't seen what form it takes yet.
	CampsiteRules interface{} `json:"campsite_rules"`

	// not sure what quantities means
	// TODO: figure out if we need it
	Quantities struct{} `json:"quantities"`
}

type ErrCloudFlare added in v0.0.3

type ErrCloudFlare struct {
	Status   int
	Contents []byte
}

func (ErrCloudFlare) Error added in v0.0.3

func (e ErrCloudFlare) Error() string

type Fees added in v0.0.2

type Fees struct {
	Deposit   int `json:"deposit"`
	Holiday   int `json:"holiday"`
	PerNight  int `json:"per_night"`
	PerPerson int `json:"per_person"`
	Weekend   int `json:"weekend"`
}

type HTTPClient added in v0.0.2

type HTTPClient interface {
	Do(req *http.Request) (*http.Response, error)
}

type Obfuscator added in v0.0.2

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

Obfuscator is what will set all the headers required to avoid detection by cloudflare. It also rate limits you to ensure you don't go over the cloudflare limit. TODO: make the rate limiting dynamic, ie increase limiting if it's no good

func (*Obfuscator) Do added in v0.0.2

func (c *Obfuscator) Do(req *http.Request) (*http.Response, error)

TODO: do this better. Should use a real library to make user agent headers

type SearchResults added in v0.0.2

type SearchResults struct {
	Latitude              string       `json:"latitude"`
	Location              string       `json:"location"`
	Longitude             string       `json:"longitude"`
	Radius                string       `json:"radius"`
	Results               []CampGround `json:"results"`
	Size                  int          `json:"size"`
	SpellingAutocorrected bool         `json:"spelling_autocorrected"`
	Start                 string       `json:"start"`
	Total                 int          `json:"total"`
}

type Server added in v0.0.4

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

func InitServer added in v0.0.4

func InitServer(ctx context.Context, apiPause time.Duration) *Server

func (*Server) GetAvailability added in v0.0.4

func (s *Server) GetAvailability(ctx context.Context, log *zap.Logger, campgroundID string, targetTime time.Time) (Availability, error)

func (*Server) SearchGeo added in v0.0.4

func (s *Server) SearchGeo(ctx context.Context, log *zap.Logger, lat, lon float64) (SearchResults, error)

type State

type State string
var (
	StateAvailable               State = "Available"
	StateReserved                State = "Reserved"
	StateNotReservableManagement State = "Not Reservable Management"
)

Jump to

Keyboard shortcuts

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