Documentation ¶
Index ¶
- Constants
- func CalculateIterations(reviewCount uint32) (iterations uint32)
- func CalculateOffset(iteration uint32) (offset uint32)
- func CheckIP(client *http.Client) (ip string, err error)
- func FetchReviewCount(client *http.Client, locationID uint32, queryType string, lang string) (reviewCount int, err error)
- func GetQueryID(queryType string) (queryID string)
- func GetURLType(url string) string
- func ParseURL(url string, locationType string) (locationID uint32, locationName string, error error)
- type Extensions
- type Filter
- type Filters
- type Request
- type Requests
- type Response
- type Responses
- type Variables
Constants ¶
const ( // EndPointURL is the URL to the TripAdvisor GraphQL endpoint EndPointURL string = "https://www.tripadvisor.com/data/graphql/ids" // HotelQueryID is the pre-registered query ID for hotel reviews HotelQueryID string = "b83d781ada1db6f2" // AirlineQueryID is the pre-registered query ID for airline reviews AirlineQueryID string = "83003f8d5a7b1762" // ReviewLimit is the maximum number of reviews that can be fetched in a single request ReviewLimit uint32 = 20 )
Variables ¶
This section is empty.
Functions ¶
func CalculateIterations ¶
CalculateIterations is a function that calculates the number of iterations required to fetch all reviews
func CalculateOffset ¶
CalculateOffset is a function that calculates the offset for the given iteration
func CheckIP ¶
CheckIP takes in a http client and calls ipinfo.io/ip to check the current IP address
func FetchReviewCount ¶
func FetchReviewCount(client *http.Client, locationID uint32, queryType string, lang string) (reviewCount int, err error)
FetchReviewCount is a function that fetches the review count for the given location ID and query type
func GetQueryID ¶
GetQueryID is a function that returns the query ID for the given query type
func GetURLType ¶
GetURLType is a function that validates the URL and returns the type of URL
Types ¶
type Extensions ¶
type Extensions struct {
PreRegisteredQueryID string `json:"preRegisteredQueryId"`
}
Extensions is a struct that represents the extensions object in the request body to TripAdvisor endpoints.
type Filter ¶
Filter is a struct that represents the filter object in the request body to TripAdvisor endpoints
type Request ¶
type Request struct { Variables Variables `json:"variables"` Extensions Extensions `json:"extensions"` }
Request is a struct that represents the request body to query TripAdvisor endpoints
type Response ¶
type Response struct { Data struct { Locations []struct { ReviewListPage struct { TotalCount int `json:"totalCount"` Reviews []struct { CreatedDate string `json:"createdDate"` PublishedDate string `json:"publishedDate"` Rating int `json:"rating"` PublishPlatform string `json:"publishPlatform"` TripInfo struct { StayDate string `json:"stayDate"` TripType string `json:"tripType"` } `json:"tripInfo"` LocationID int `json:"locationId"` Labels []string `json:"labels"` Title string `json:"title"` Text string `json:"text"` } `json:"reviews"` } `json:"reviewListPage"` } `json:"locations"` } `json:"data,omitempty"` }
Response is a struct that represents the response body from TripAdvisor endpoints
type Variables ¶
type Variables struct { LocationID uint32 `json:"locationId"` Offset uint32 `json:"offset"` Prefs any `json:"prefs"` // null Filters Filters `json:"filters"` InitialPrefs struct { } `json:"initialPrefs"` // empty struct Limit uint32 `json:"limit"` FilterCacheKey any `json:"filterCacheKey"` // null PrefsCacheKey string `json:"prefsCacheKey"` // format "locationReviewPrefs_<localtionID>" NeedKeywords bool `json:"needKeywords"` // false KeywordVariant string `json:"keywordVariant"` }
Variables is a struct that represents the variables object in the request body to TripAdvisor endpoints