-
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
Stainless Bot
committed
Oct 4, 2024
1 parent
ca60afd
commit b1c0c68
Showing
25 changed files
with
855 additions
and
0 deletions.
There are no files selected for viewing
31 changes: 31 additions & 0 deletions
31
onebusaway-sdk-java-example/src/main/java/org/example/AgenciesWithCoverage.java
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 org.example; | ||
|
||
import org.onebusaway.client.OnebusawaySdkClient; | ||
import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClient; | ||
import org.onebusaway.models.*; | ||
|
||
public class AgenciesWithCoverage { | ||
|
||
// Retrieve constants from environment variables or fallback to default values | ||
static final String API_KEY = System.getenv("ONEBUSAWAY_API_KEY") != null ? System.getenv("ONEBUSAWAY_API_KEY") : "TEST"; | ||
static final String BASE_URL = System.getenv("ONEBUSAWAY_BASE_URL") != null ? System.getenv("ONEBUSAWAY_BASE_URL") : "https://api.pugetsound.onebusaway.org"; | ||
|
||
// Initialize the Onebusaway SDK client | ||
static final OnebusawaySdkClient client = OnebusawaySdkOkHttpClient.builder() | ||
.apiKey(API_KEY) | ||
.baseUrl(BASE_URL) | ||
.build(); | ||
|
||
public static void main(String[] args) { | ||
|
||
// Define the required Params | ||
AgenciesWithCoverageListParams params = AgenciesWithCoverageListParams.builder().build(); | ||
|
||
// Get the agencies with coverage | ||
AgenciesWithCoverageListResponse agencies = client.agenciesWithCoverage().list(params); | ||
|
||
for (AgenciesWithCoverageListResponse.Data.List agency : agencies.data().list()) { | ||
System.out.println(agency); | ||
} | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
onebusaway-sdk-java-example/src/main/java/org/example/Agency.java
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 org.example; | ||
|
||
import org.onebusaway.client.OnebusawaySdkClient; | ||
import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClient; | ||
import org.onebusaway.models.*; | ||
|
||
public class Agency { | ||
|
||
// Retrieve constants from environment variables or fallback to default values | ||
static final String API_KEY = System.getenv("ONEBUSAWAY_API_KEY") != null ? System.getenv("ONEBUSAWAY_API_KEY") : "TEST"; | ||
static final String BASE_URL = System.getenv("ONEBUSAWAY_BASE_URL") != null ? System.getenv("ONEBUSAWAY_BASE_URL") : "https://api.pugetsound.onebusaway.org"; | ||
|
||
// Initialize the Onebusaway SDK client | ||
static final OnebusawaySdkClient client = OnebusawaySdkOkHttpClient.builder() | ||
.apiKey(API_KEY) | ||
.baseUrl(BASE_URL) | ||
.build(); | ||
|
||
|
||
public static void main(String[] args) { | ||
|
||
// Define the agency ID | ||
String agencyId = "1"; | ||
|
||
// Define the parameters for the agency retrieval request | ||
AgencyRetrieveParams params = AgencyRetrieveParams.builder().agencyId(agencyId).build(); | ||
|
||
// Retrieve the agency information | ||
AgencyRetrieveResponse agency = client.agency().retrieve(params); | ||
|
||
System.out.println(agency); | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
onebusaway-sdk-java-example/src/main/java/org/example/ArrivalAndDepartureForStop.java
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,39 @@ | ||
package org.example; | ||
|
||
import org.onebusaway.client.OnebusawaySdkClient; | ||
import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClient; | ||
import org.onebusaway.models.*; | ||
|
||
public class ArrivalAndDepartureForStop { | ||
|
||
// Retrieve constants from environment variables or fallback to default values | ||
static final String API_KEY = System.getenv("ONEBUSAWAY_API_KEY") != null ? System.getenv("ONEBUSAWAY_API_KEY") : "TEST"; | ||
static final String BASE_URL = System.getenv("ONEBUSAWAY_BASE_URL") != null ? System.getenv("ONEBUSAWAY_BASE_URL") : "https://api.pugetsound.onebusaway.org"; | ||
|
||
// Initialize the Onebusaway SDK client | ||
static final OnebusawaySdkClient client = OnebusawaySdkOkHttpClient.builder() | ||
.apiKey(API_KEY) | ||
.baseUrl(BASE_URL) | ||
.build(); | ||
|
||
public static void main(String[] args) { | ||
|
||
// Define the stop ID and trip ID | ||
String stopId = "1_75403"; | ||
String tripId = "1_604670535"; | ||
|
||
// Define the service date directly as a Unix timestamp (in seconds) | ||
long serviceDate = 1810918000; // Example timestamp | ||
|
||
// Create parameters for arrival and departure request | ||
ArrivalAndDepartureRetrieveParams params = ArrivalAndDepartureRetrieveParams.builder() | ||
.stopId(stopId) | ||
.tripId(tripId) | ||
.serviceDate(serviceDate) // Use the Unix timestamp directly | ||
.build(); | ||
|
||
// Retrieve arrival and departure information | ||
ArrivalAndDepartureRetrieveResponse arrivalAndDepartureForStop = client.arrivalAndDeparture().retrieve(params); | ||
System.out.println(arrivalAndDepartureForStop); | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
onebusaway-sdk-java-example/src/main/java/org/example/ArrivalsAndDeparturesForStop.java
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,41 @@ | ||
package org.example; | ||
|
||
import org.onebusaway.client.OnebusawaySdkClient; | ||
import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClient; | ||
import org.onebusaway.models.*; | ||
public class ArrivalsAndDeparturesForStop { | ||
|
||
// Retrieve constants from environment variables or fallback to default values | ||
static final String API_KEY = System.getenv("ONEBUSAWAY_API_KEY") != null ? System.getenv("ONEBUSAWAY_API_KEY") : "TEST"; | ||
static final String BASE_URL = System.getenv("ONEBUSAWAY_BASE_URL") != null ? System.getenv("ONEBUSAWAY_BASE_URL") : "https://api.pugetsound.onebusaway.org"; | ||
|
||
// Initialize the Onebusaway SDK client | ||
static final OnebusawaySdkClient client = OnebusawaySdkOkHttpClient.builder() | ||
.apiKey(API_KEY) | ||
.baseUrl(BASE_URL) | ||
.build(); | ||
|
||
|
||
public static void main(String[] args) { | ||
|
||
// Define the stop ID | ||
String stopId = "1_75403"; | ||
int minutesBefore = 5; | ||
int minutesAfter = 35; | ||
|
||
// Define the parameters for the arrival and departure list request | ||
ArrivalAndDepartureListParams params = ArrivalAndDepartureListParams.builder() | ||
.stopId(stopId) | ||
.minutesBefore(minutesBefore) | ||
.minutesAfter(minutesAfter) | ||
.build(); | ||
|
||
// Retrieve arrival and departure information | ||
ArrivalAndDepartureListResponse arrivalsAndDeparturesForStop = client.arrivalAndDeparture().list(params); | ||
|
||
for (ArrivalAndDepartureListResponse.Data.Entry.ArrivalsAndDeparture arrivalAndDeparture : arrivalsAndDeparturesForStop.data().entry().arrivalsAndDepartures()) { | ||
System.out.println(arrivalAndDeparture); | ||
} | ||
} | ||
|
||
} |
43 changes: 43 additions & 0 deletions
43
onebusaway-sdk-java-example/src/main/java/org/example/Block.java
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,43 @@ | ||
package org.example; | ||
|
||
import org.onebusaway.client.OnebusawaySdkClient; | ||
import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClient; | ||
import org.onebusaway.errors.OnebusawaySdkServiceException; | ||
import org.onebusaway.models.*; | ||
public class Block { | ||
|
||
// Retrieve constants from environment variables or fallback to default values | ||
static final String API_KEY = System.getenv("ONEBUSAWAY_API_KEY") != null ? System.getenv("ONEBUSAWAY_API_KEY") : "TEST"; | ||
static final String BASE_URL = System.getenv("ONEBUSAWAY_BASE_URL") != null ? System.getenv("ONEBUSAWAY_BASE_URL") : "https://api.pugetsound.onebusaway.org"; | ||
|
||
// Initialize the Onebusaway SDK client | ||
static final OnebusawaySdkClient client = OnebusawaySdkOkHttpClient.builder() | ||
.apiKey(API_KEY) | ||
.baseUrl(BASE_URL) | ||
.build(); | ||
|
||
|
||
public static void main(String[] args) { | ||
|
||
// Define the block ID | ||
String blockId = "1_7331695"; | ||
|
||
try { | ||
// Define the parameters for the block retrieval request | ||
BlockRetrieveParams params = BlockRetrieveParams.builder().blockId(blockId).build(); | ||
|
||
// Retrieve the block information | ||
BlockRetrieveResponse block = client.block().retrieve(params); | ||
|
||
System.out.println(block); | ||
|
||
} catch (OnebusawaySdkServiceException e) { | ||
|
||
// Handle the SDK-specific service exception | ||
System.err.println("Error occurred: " + e.getMessage()); | ||
System.err.println("Status Code: " + e.statusCode()); | ||
} catch (Exception e) { | ||
e.printStackTrace(); | ||
} | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
onebusaway-sdk-java-example/src/main/java/org/example/CurrentTime.java
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 org.example; | ||
|
||
import org.onebusaway.client.OnebusawaySdkClient; | ||
import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClient; | ||
import org.onebusaway.models.*; | ||
|
||
public class CurrentTime { | ||
|
||
// Retrieve constants from environment variables or fallback to default values | ||
static final String API_KEY = System.getenv("ONEBUSAWAY_API_KEY") != null ? System.getenv("ONEBUSAWAY_API_KEY") : "TEST"; | ||
static final String BASE_URL = System.getenv("ONEBUSAWAY_BASE_URL") != null ? System.getenv("ONEBUSAWAY_BASE_URL") : "https://api.pugetsound.onebusaway.org"; | ||
|
||
// Initialize the Onebusaway SDK client | ||
static final OnebusawaySdkClient client = OnebusawaySdkOkHttpClient.builder() | ||
.apiKey(API_KEY) | ||
.baseUrl(BASE_URL) | ||
.build(); | ||
|
||
|
||
public static void main(String[] args) { | ||
|
||
// Define the parameters for the current time retrieval request | ||
CurrentTimeRetrieveParams params = CurrentTimeRetrieveParams.builder().build(); | ||
|
||
// Retrieve the current time information | ||
CurrentTimeRetrieveResponse currentTime = client.currentTime().retrieve(params); | ||
|
||
System.out.println(currentTime); | ||
} | ||
|
||
|
||
} |
39 changes: 39 additions & 0 deletions
39
onebusaway-sdk-java-example/src/main/java/org/example/Route.java
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,39 @@ | ||
package org.example; | ||
|
||
import org.onebusaway.client.OnebusawaySdkClient; | ||
import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClient; | ||
import org.onebusaway.models.*; | ||
|
||
|
||
public class Route { | ||
|
||
// Retrieve constants from environment variables or fallback to default values | ||
static final String API_KEY = System.getenv("ONEBUSAWAY_API_KEY") != null ? System.getenv("ONEBUSAWAY_API_KEY") : "TEST"; | ||
static final String BASE_URL = System.getenv("ONEBUSAWAY_BASE_URL") != null ? System.getenv("ONEBUSAWAY_BASE_URL") : "https://api.pugetsound.onebusaway.org"; | ||
|
||
// Initialize the Onebusaway SDK client | ||
static final OnebusawaySdkClient client = OnebusawaySdkOkHttpClient.builder() | ||
.apiKey(API_KEY) | ||
.baseUrl(BASE_URL) | ||
.build(); | ||
|
||
|
||
public static void main(String[] args) { | ||
|
||
// Define the route ID | ||
String routeId = "1_100224"; | ||
|
||
try { | ||
|
||
RouteRetrieveParams params = org.onebusaway.models.RouteRetrieveParams.builder().routeId(routeId).build(); | ||
|
||
RouteRetrieveResponse route = client.route().retrieve(params); | ||
|
||
System.out.println(route); | ||
|
||
} catch (org.onebusaway.errors.OnebusawaySdkServiceException e) { | ||
System.err.println("Error occurred: " + e.getMessage()); | ||
System.err.println("Status Code: " + e.statusCode()); | ||
} | ||
} | ||
} |
49 changes: 49 additions & 0 deletions
49
onebusaway-sdk-java-example/src/main/java/org/example/RouteForAgency.java
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,49 @@ | ||
package org.example; | ||
|
||
import org.onebusaway.client.OnebusawaySdkClient; | ||
import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClient; | ||
import org.onebusaway.errors.OnebusawaySdkServiceException; | ||
import org.onebusaway.models.*; | ||
|
||
public class RouteForAgency { | ||
|
||
// Retrieve constants from environment variables or fallback to default values | ||
static final String API_KEY = System.getenv("ONEBUSAWAY_API_KEY") != null ? System.getenv("ONEBUSAWAY_API_KEY") : "TEST"; | ||
static final String BASE_URL = System.getenv("ONEBUSAWAY_BASE_URL") != null ? System.getenv("ONEBUSAWAY_BASE_URL") : "https://api.pugetsound.onebusaway.org"; | ||
|
||
// Initialize the Onebusaway SDK client | ||
static final OnebusawaySdkClient client = OnebusawaySdkOkHttpClient.builder() | ||
.apiKey(API_KEY) | ||
.baseUrl(BASE_URL) | ||
.build(); | ||
|
||
|
||
public static void main(String[] args) { | ||
|
||
try { | ||
|
||
// Define the agency ID | ||
String agencyId = "1"; | ||
|
||
// Create the parameters for the routes for agency list request | ||
RoutesForAgencyListParams params = RoutesForAgencyListParams.builder() | ||
.agencyId(agencyId) | ||
.build(); | ||
|
||
// Retrieve the routes for the agency | ||
RoutesForAgencyListResponse routesForAgency = client.routesForAgency().list(params); | ||
|
||
for (RoutesForAgencyListResponse.Data.List route : routesForAgency.data().list()) { | ||
System.out.println(route); | ||
} | ||
} | ||
catch (OnebusawaySdkServiceException e) { | ||
System.err.println("Error occurred: " + e.getMessage()); | ||
System.err.println("Status Code: " + e.statusCode()); | ||
} | ||
catch (Exception e) { | ||
System.err.println("Error occurred: " + e.getMessage()); | ||
} | ||
} | ||
|
||
} |
47 changes: 47 additions & 0 deletions
47
onebusaway-sdk-java-example/src/main/java/org/example/RoutesForLocation.java
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,47 @@ | ||
package org.example; | ||
|
||
import org.onebusaway.client.OnebusawaySdkClient; | ||
import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClient; | ||
import org.onebusaway.models.*; | ||
|
||
public class RoutesForLocation { | ||
|
||
// Retrieve constants from environment variables or fallback to default values | ||
static final String API_KEY = System.getenv("ONEBUSAWAY_API_KEY") != null ? System.getenv("ONEBUSAWAY_API_KEY") : "TEST"; | ||
static final String BASE_URL = System.getenv("ONEBUSAWAY_BASE_URL") != null ? System.getenv("ONEBUSAWAY_BASE_URL") : "https://api.pugetsound.onebusaway.org"; | ||
|
||
// Initialize the Onebusaway SDK client | ||
static final OnebusawaySdkClient client = OnebusawaySdkOkHttpClient.builder() | ||
.apiKey(API_KEY) | ||
.baseUrl(BASE_URL) | ||
.build(); | ||
|
||
|
||
public static void main(String[] args) { | ||
|
||
try { | ||
// Define the location parameters | ||
double lat = 47.653435; | ||
double lon = -122.305641; | ||
double radius = 1000.0; | ||
|
||
// Create the parameters for the routes for location request | ||
RoutesForLocationListParams params = RoutesForLocationListParams.builder() | ||
.lat(lat) | ||
.lon(lon) | ||
.radius(radius) | ||
.build(); | ||
|
||
// Retrieve the routes for location | ||
RoutesForLocationListResponse routesForLocation = client.routesForLocation().list(params); | ||
|
||
for (RoutesForLocationListResponse.Data.List route : routesForLocation.data().list()) { | ||
System.out.println(route); | ||
} | ||
} | ||
catch (Exception e) { | ||
System.err.println("Error occurred: " + e.getMessage()); | ||
} | ||
} | ||
|
||
} |
Oops, something went wrong.