-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
30741c6
commit 231fd0d
Showing
26 changed files
with
854 additions
and
25 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package main | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"log" | ||
"time" | ||
|
||
onebusaway "github.com/stainless-sdks/open-transit-go" | ||
"github.com/stainless-sdks/open-transit-go/option" | ||
) | ||
|
||
func main() { | ||
// Create a new instance of the OneBusAway SDK with the settings | ||
client := onebusaway.NewClient( | ||
option.WithAPIKey("TEST"), | ||
option.WithBaseURL("https://api.pugetsound.onebusaway.org/"), | ||
) | ||
|
||
ctx := context.Background() | ||
|
||
// Define the query parameters | ||
stopID := "1_75403" | ||
tripID := "1_604670535" | ||
serviceDate := time.Unix(1810918000, 0) // Convert Unix timestamp to time.Time | ||
|
||
// Retrieve arrival and departure information | ||
response, err := client.ArrivalAndDeparture.Get(ctx, stopID, onebusaway.ArrivalAndDepartureGetParams{ | ||
TripID: onebusaway.F(tripID), | ||
ServiceDate: onebusaway.F(serviceDate.Unix()), | ||
}) | ||
if err != nil { | ||
log.Fatalf("Error retrieving arrival and departure: %v", err) | ||
} | ||
|
||
fmt.Printf("%+v\n", response) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package main | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"log" | ||
"time" | ||
|
||
onebusaway "github.com/stainless-sdks/open-transit-go" | ||
"github.com/stainless-sdks/open-transit-go/option" | ||
) | ||
|
||
func main() { | ||
// Create a new instance of the OneBusAway SDK with the settings | ||
client := onebusaway.NewClient( | ||
option.WithAPIKey("TEST"), | ||
option.WithBaseURL("https://api.pugetsound.onebusaway.org/"), | ||
) | ||
|
||
ctx := context.Background() | ||
|
||
// Define the query parameters | ||
stopID := "1_75403" // Replace with actual stop ID | ||
|
||
minutesBefore := int64(5) // include vehicles having arrived or departed in the previous n minutes (default=5) | ||
minutesAfter := int64(35) // include vehicles arriving or departing in the next n minutes (default=35) | ||
|
||
// Retrieve arrival and departure information | ||
response, err := client.ArrivalAndDeparture.List(ctx, stopID, onebusaway.ArrivalAndDepartureListParams{ | ||
MinutesAfter: onebusaway.F(minutesAfter), | ||
MinutesBefore: onebusaway.F(minutesBefore), | ||
}) | ||
if err != nil { | ||
log.Fatalf("Error retrieving arrival and departure: %v", err) | ||
} | ||
|
||
for _, ad := range response.Data.Entry.ArrivalsAndDepartures { | ||
fmt.Printf("Route: %s\n", ad.RouteShortName) | ||
fmt.Printf("Trip Headsign: %s\n", ad.TripHeadsign) | ||
fmt.Printf("Predicted Arrival Time: %s\n", time.Unix(ad.PredictedArrivalTime/1000, 0)) | ||
fmt.Printf("Scheduled Arrival Time: %s\n", time.Unix(ad.ScheduledArrivalTime/1000, 0)) | ||
fmt.Printf("Vehicle ID: %s\n", ad.VehicleID) | ||
fmt.Println() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package main | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"log" | ||
|
||
onebusaway "github.com/stainless-sdks/open-transit-go" | ||
"github.com/stainless-sdks/open-transit-go/option" | ||
) | ||
|
||
func main() { | ||
|
||
// Initialize the OneBusAway client with the API key | ||
client := onebusaway.NewClient( | ||
option.WithAPIKey("TEST"), | ||
option.WithBaseURL("https://api.pugetsound.onebusaway.org/"), | ||
) | ||
|
||
ctx := context.Background() | ||
|
||
blockID := "1_7331695" // Replace with actual block ID | ||
|
||
block, err := client.Block.Get(ctx, blockID) | ||
|
||
if err != nil { | ||
log.Fatalf("Error fetching block: %v", err) | ||
} | ||
|
||
fmt.Print(block.Data.JSON.RawJSON()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package main | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"log" | ||
|
||
onebusaway "github.com/stainless-sdks/open-transit-go" | ||
"github.com/stainless-sdks/open-transit-go/option" | ||
) | ||
|
||
func main() { | ||
|
||
// Create a new instance of the OneBusAway SDK with the settings | ||
client := onebusaway.NewClient( | ||
option.WithAPIKey("TEST"), | ||
option.WithBaseURL("https://api.pugetsound.onebusaway.org/"), | ||
) | ||
|
||
ctx := context.Background() | ||
|
||
config, err := client.Config.Get(ctx) | ||
|
||
if err != nil { | ||
log.Fatalf("Error getting config: %v", err) | ||
} | ||
|
||
fmt.Println(config) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package main | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"log" | ||
|
||
onebusaway "github.com/stainless-sdks/open-transit-go" | ||
"github.com/stainless-sdks/open-transit-go/option" | ||
) | ||
|
||
func main() { | ||
|
||
// Create a new instance of the OneBusAway SDK with the settings | ||
client := onebusaway.NewClient( | ||
option.WithAPIKey("TEST"), | ||
option.WithBaseURL("https://api.pugetsound.onebusaway.org/"), | ||
) | ||
|
||
ctx := context.Background() | ||
|
||
currentTime, err := client.CurrentTime.Get(ctx) | ||
|
||
if err != nil { | ||
log.Fatalf("Error fetching current time: %v", err) | ||
} | ||
|
||
fmt.Println(currentTime.Data.JSON.RawJSON()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package main | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"log" | ||
|
||
onebusaway "github.com/stainless-sdks/open-transit-go" | ||
"github.com/stainless-sdks/open-transit-go/option" | ||
) | ||
|
||
func main() { | ||
|
||
// Create a new instance of the OneBusAway SDK with the settings | ||
client := onebusaway.NewClient( | ||
option.WithAPIKey("TEST"), | ||
option.WithBaseURL("https://api.pugetsound.onebusaway.org/"), | ||
) | ||
|
||
ctx := context.Background() | ||
|
||
stopID := "1_100000" | ||
|
||
reportProblemWithStop, err := client.ReportProblemWithStop.Get(ctx, stopID, onebusaway.ReportProblemWithStopGetParams{ | ||
UserComment: onebusaway.F("This is a test report"), | ||
UserLat: onebusaway.F(47.6062), | ||
UserLon: onebusaway.F(-122.3321), | ||
}) | ||
|
||
if err != nil { | ||
log.Fatalf("Error reporting problem with stop: %v", err) | ||
} | ||
|
||
fmt.Println(reportProblemWithStop) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package main | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"log" | ||
"time" | ||
|
||
onebusaway "github.com/stainless-sdks/open-transit-go" | ||
"github.com/stainless-sdks/open-transit-go/option" | ||
) | ||
|
||
func main() { | ||
|
||
// Create a new instance of the OneBusAway SDK with the settings | ||
client := onebusaway.NewClient( | ||
option.WithAPIKey("TEST"), | ||
option.WithBaseURL("https://api.pugetsound.onebusaway.org/"), | ||
) | ||
|
||
ctx := context.Background() | ||
|
||
// Define the trip ID | ||
tripID := "1_100000" | ||
|
||
reportProblemWithTrip, err := client.ReportProblemWithTrip.Get(ctx, tripID, onebusaway.ReportProblemWithTripGetParams{ | ||
UserComment: onebusaway.F("This is a test report"), | ||
ServiceDate: onebusaway.F(time.Now().Unix()), | ||
VehicleID: onebusaway.F("1000"), | ||
UserLat: onebusaway.F(47.6062), | ||
UserLon: onebusaway.F(-122.3321), | ||
UserOnVehicle: onebusaway.F(true), | ||
UserVehicleNumber: onebusaway.F("1234"), | ||
StopID: onebusaway.F("1_100000"), | ||
}) | ||
|
||
if err != nil { | ||
log.Fatalf("Error reporting problem with trip: %v", err) | ||
} | ||
|
||
fmt.Println(reportProblemWithTrip) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package main | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"log" | ||
|
||
onebusaway "github.com/stainless-sdks/open-transit-go" | ||
"github.com/stainless-sdks/open-transit-go/option" | ||
) | ||
|
||
func main() { | ||
|
||
// Create a new instance of the OneBusAway SDK with the settings | ||
client := onebusaway.NewClient( | ||
option.WithAPIKey("TEST"), | ||
option.WithBaseURL("https://api.pugetsound.onebusaway.org/"), | ||
) | ||
|
||
ctx := context.Background() | ||
|
||
routeID := "1_100224" | ||
|
||
route, err := client.Route.Get(ctx, routeID) | ||
|
||
if err != nil { | ||
log.Fatalf("Error fetching route: %v", err) | ||
} | ||
|
||
fmt.Print(route) | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package main | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"log" | ||
|
||
onebusaway "github.com/stainless-sdks/open-transit-go" | ||
"github.com/stainless-sdks/open-transit-go/option" | ||
) | ||
|
||
func main() { | ||
|
||
// Create a new instance of the OneBusAway SDK with the settings | ||
client := onebusaway.NewClient( | ||
option.WithAPIKey("TEST"), | ||
option.WithBaseURL("https://api.pugetsound.onebusaway.org/"), | ||
) | ||
|
||
ctx := context.Background() | ||
|
||
// Define the agency ID | ||
agencyID := "1" | ||
|
||
// Fetch the routes for the agency | ||
routes, err := client.RoutesForAgency.List(ctx, agencyID) | ||
|
||
if err != nil { | ||
log.Fatalf("Error fetching routes: %v", err) | ||
} | ||
|
||
fmt.Print(routes.Data.JSON.RawJSON()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package main | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"log" | ||
|
||
onebusaway "github.com/stainless-sdks/open-transit-go" | ||
"github.com/stainless-sdks/open-transit-go/option" | ||
) | ||
|
||
func main() { | ||
|
||
// Create a new instance of the OneBusAway SDK with the settings | ||
client := onebusaway.NewClient( | ||
option.WithAPIKey("TEST"), | ||
option.WithBaseURL("https://api.pugetsound.onebusaway.org/"), | ||
) | ||
|
||
ctx := context.Background() | ||
|
||
location := onebusaway.RoutesForLocationListParams{ | ||
Lat: onebusaway.F(47.6097), | ||
Lon: onebusaway.F(-122.3331), | ||
} | ||
|
||
// Fetch the routes for the location | ||
routes, err := client.RoutesForLocation.List(ctx, location) | ||
|
||
if err != nil { | ||
log.Fatalf("Error fetching routes: %v", err) | ||
} | ||
|
||
fmt.Print(routes.Data.JSON.RawJSON()) | ||
|
||
} |
Oops, something went wrong.