Documentation
¶
Index ¶
- Constants
- func CalculateIterations(reviewCount uint32) (iterations uint32)
- func CalculateOffset(iteration uint32) (offset uint32)
- func CheckProxyConnection(proxyHost string, timeout time.Duration) bool
- func FetchReviewCount(client *http.Client, locationID uint32, queryType string, languages []string) (reviewCount int, err error)
- func GetHTTPClientWithProxy(proxyHost string) (*http.Client, error)
- func GetQueryID(queryType string) (queryID string)
- func GetURLType(url string) string
- func ParseURL(url string, locationType string) (locationID uint32, locationName string, error error)
- func SortReviewsByDate(reviews []Review)
- func WriteReviewsToJSONFile(reviews []Review, location Location, fileHandle *os.File) error
- type Extensions
- type Feedback
- type Filter
- type Filters
- type Location
- type Photo
- type Photos
- type Request
- type Requests
- type Response
- type Responses
- type Review
- type ReviewAggregations
- type ReviewSummary
- type UserProfile
- 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" // AttractionQueryID is the pre-registered query ID for attraction reviews AttractionQueryID string = "b83d781ada1db6f2" // 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 CheckProxyConnection ¶
CheckProxyConnection attempts to establish a TCP connection to the proxy server to determine if it is operational.
func FetchReviewCount ¶
func FetchReviewCount(client *http.Client, locationID uint32, queryType string, languages []string) (reviewCount int, err error)
FetchReviewCount is a function that fetches the review count for the given location ID and query type
func GetHTTPClientWithProxy ¶
GetHTTPClientWithProxy returns an HTTP client that uses the proxy server
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
func ParseURL ¶
func ParseURL(url string, locationType string) (locationID uint32, locationName string, error error)
ParseURL is a function that parses the URL and returns the location ID and the location name
func SortReviewsByDate ¶
func SortReviewsByDate(reviews []Review)
SortReviewsByDate is a function that sorts the reviews by date This function modifies the original slice
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 Feedback ¶
Feedback is a struct that represents the feedback object in the response body from TripAdvisor endpoints
type Filter ¶
Filter is a struct that represents the filter object in the request body to TripAdvisor endpoints
type Location ¶
type Location struct { LocationID int `json:"locationId"` ParentGeoID int `json:"parentGeoId"` PlaceType string `json:"placeType"` ReviewSummary ReviewSummary AccommodationCategory string `json:"accommodationCategory"` ReviewAggregations ReviewAggregations `json:"reviewAggregations"` }
Location is a struct that represents the location object in the response body from TripAdvisor endpoints
type Photo ¶
type Photo struct { ID int `json:"id"` Statuses []string `json:"statuses"` PhotoSizes []struct { Width int `json:"width"` Height int `json:"height"` URL string `json:"url"` } `json:"photoSizes"` }
Photo is a struct that represents the photo object in the response body from 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 { Location ReviewListPage struct { TotalCount int `json:"totalCount"` Reviews []Review `json:"reviews"` } `json:"reviewListPage"` } `json:"locations"` } `json:"data,omitempty"` }
Response is a struct that represents the response body from TripAdvisor endpoints
type Review ¶
type Review struct { ID int `json:"id"` 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"` PhotoIds []int `json:"photoIds"` LocationID int `json:"locationId"` Labels []string `json:"labels"` Title string `json:"title"` Text string `json:"text"` URL string `json:"url"` Photos Photos `json:"photos"` UserProfile UserProfile `json:"userProfile"` Username string `json:"username"` }
Review is a struct that represents the review object in the response body from TripAdvisor endpoints
type ReviewAggregations ¶
type ReviewAggregations struct { RatingCounts []int `json:"ratingCounts"` LanguageCounts map[string]int `json:"languageCounts"` AlertStatusCount int `json:"alertStatusCount"` }
ReviewAggregations is a struct that represents the review aggregations object in the response body from TripAdvisor endpoints
type ReviewSummary ¶
ReviewSummary is a struct that represents the review summary object in the response body from TripAdvisor endpoints
type UserProfile ¶
type UserProfile struct { IsMe bool `json:"isMe"` IsVerified bool `json:"isVerified"` ContributionCounts struct { SumAllUgc int `json:"sumAllUgc"` SumAllLikes int `json:"sumAllLikes"` } `json:"contributionCounts"` IsFollowing bool `json:"isFollowing"` ID string `json:"id"` UserID string `json:"userId"` DisplayName string `json:"displayName"` Username string `json:"username"` Hometown struct { LocationID interface{} `json:"locationId"` Location interface{} `json:"location"` FallbackString interface{} `json:"fallbackString"` } `json:"hometown"` Route struct { URL string `json:"url"` } `json:"route"` Avatar struct { ID int `json:"id"` PhotoSizes []struct { Width int `json:"width"` Height int `json:"height"` URL string `json:"url"` } `json:"photoSizes"` } `json:"avatar"` }
UserProfile is a struct that represents the user profile object in 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