This file contains a few small snippets demonstrating common functionality of the module.
You must first initialize the bms.NewClient
with a RegionCode
and RegionName
.
After installing the CLI:
-
RegionCode
andRegionName
:gobms-cli listRegions > regions.txt
You can search the output file for your region's name and code.
-
TheaterCode
:From the region info you received in step 1, run:
gobms-cli listTheaters --regionName=<your-region-name> --regionCode=<your-region-code>
import "github.com/ArionMiles/gobms/pkg/bms"
client, err := bms.NewClient("Mumbai", "MUMBAI")
if err != nil {
// Handle Error
}
NOTE: Go through the models.go to find more attribute information.
qb, err := client.GetQuickbook("MT")
if err != nil {
// Handle Error
}
for _, movie := range qb.MovieData.BookMyShow.ArrEvents {
fmt.Println(movie.Title)
for _, childEvent := range movie.ChildEvents {
fmt.Println(childEvent.Language, childEvent.Dimension)
}
}
cinemas, err := client.ListPreferredCinemas()
if err != nil {
// Handle Error
}
for _, venue := range cinemas.Popular {
fmt.Println(venue.VenueCode, " - ", venue.VenueName)
}
theaters, err := client.ListTheaters()
if err != nil {
// Handle error
}
for _, theater := range theaters {
fmt.Println(theater.Name)
}
movies, err := client.ListMovieTitles()
if err != nil {
// Handle Error
}
for _, movie := range movies {
fmt.Println(movie)
}
// Both date examples work
// date := time.Now()
date := time.Date(2019, time.December, 20, 0, 0, 0, 0, time.UTC)
movieURL, err := client.GetMovieURL("Star Wars: The Rise of Skywalker", "English", "IMAX 3D", date)
if err != nil {
// Handle Error
}
fmt.Println(movieURL)
eventCode, err := obj.GetEventCode("Gunda", "Hindi", "IMAX 3D")
if err != nil {
// Handle Error
}
fmt.Println(eventCode)
Showtimes are all the screenings of a movie in a particular theater (Venue) for a particular date.
Requires a EventCode
, VenueCode
and a date for the show
date := time.Now()
shows, err := obj.GetShowtimes("ET00042069", "ABCD", date)
if err != nil {
// Handle Error
}
for _, show := range shows {
fmt.Println(show.SessionID)
for _, category := range show.Categories {
fmt.Println(category.CurPrice, category.SeatsAvail, category.SeatsMax)
}
}
regions, err := bms.ListRegions()
if err != nil {
// Handle Error
}
for _, region := range *regions {
fmt.Println(region[0].Name, region[0].Code)
}