diff --git a/README.md b/README.md index e6a26f64..3a4b49af 100644 --- a/README.md +++ b/README.md @@ -51,8 +51,7 @@ import org.onebusaway.models.CurrentTimeRetrieveResponse // Configures using the `ONEBUSAWAY_API_KEY` environment variable val client: OnebusawaySdkClient = OnebusawaySdkOkHttpClient.fromEnv() -val params: CurrentTimeRetrieveParams = CurrentTimeRetrieveParams.builder().build() -val currentTime: CurrentTimeRetrieveResponse = client.currentTime().retrieve(params) +val currentTime: CurrentTimeRetrieveResponse = client.currentTime().retrieve() ``` ## Client configuration @@ -128,8 +127,7 @@ import org.onebusaway.models.CurrentTimeRetrieveResponse // Configures using the `ONEBUSAWAY_API_KEY` environment variable val client: OnebusawaySdkClient = OnebusawaySdkOkHttpClient.fromEnv() -val params: CurrentTimeRetrieveParams = CurrentTimeRetrieveParams.builder().build() -val currentTime: CurrentTimeRetrieveResponse = client.async().currentTime().retrieve(params) +val currentTime: CurrentTimeRetrieveResponse = client.async().currentTime().retrieve() ``` Or create an asynchronous client from the beginning: @@ -143,8 +141,7 @@ import org.onebusaway.models.CurrentTimeRetrieveResponse // Configures using the `ONEBUSAWAY_API_KEY` environment variable val client: OnebusawaySdkClientAsync = OnebusawaySdkOkHttpClientAsync.fromEnv() -val params: CurrentTimeRetrieveParams = CurrentTimeRetrieveParams.builder().build() -val currentTime: CurrentTimeRetrieveResponse = client.currentTime().retrieve(params) +val currentTime: CurrentTimeRetrieveResponse = client.currentTime().retrieve() ``` The asynchronous client supports the same options as the synchronous one, except most methods are [suspending](https://kotlinlang.org/docs/coroutines-guide.html). @@ -226,9 +223,7 @@ To set a custom timeout, configure the method call using the `timeout` method: import org.onebusaway.models.CurrentTimeRetrieveParams import org.onebusaway.models.CurrentTimeRetrieveResponse -val currentTime: CurrentTimeRetrieveResponse = client.currentTime().retrieve( - params, RequestOptions.builder().timeout(Duration.ofSeconds(30)).build() -) +val currentTime: CurrentTimeRetrieveResponse = client.currentTime().retrieve(RequestOptions.builder().timeout(Duration.ofSeconds(30)).build()) ``` Or configure the default for all method calls at the client level: @@ -356,9 +351,7 @@ Or configure the method call to validate the response using the `responseValidat import org.onebusaway.models.CurrentTimeRetrieveParams import org.onebusaway.models.CurrentTimeRetrieveResponse -val currentTime: CurrentTimeRetrieveResponse = client.currentTime().retrieve( - params, RequestOptions.builder().responseValidation(true).build() -) +val currentTime: CurrentTimeRetrieveResponse = client.currentTime().retrieve(RequestOptions.builder().responseValidation(true).build()) ``` Or configure the default for all method calls at the client level: diff --git a/onebusaway-sdk-kotlin-core/src/main/kotlin/org/onebusaway/models/AgenciesWithCoverageListParams.kt b/onebusaway-sdk-kotlin-core/src/main/kotlin/org/onebusaway/models/AgenciesWithCoverageListParams.kt index 323686c0..52a812e7 100644 --- a/onebusaway-sdk-kotlin-core/src/main/kotlin/org/onebusaway/models/AgenciesWithCoverageListParams.kt +++ b/onebusaway-sdk-kotlin-core/src/main/kotlin/org/onebusaway/models/AgenciesWithCoverageListParams.kt @@ -30,6 +30,8 @@ private constructor( companion object { + fun none(): AgenciesWithCoverageListParams = builder().build() + fun builder() = Builder() } diff --git a/onebusaway-sdk-kotlin-core/src/main/kotlin/org/onebusaway/models/ConfigRetrieveParams.kt b/onebusaway-sdk-kotlin-core/src/main/kotlin/org/onebusaway/models/ConfigRetrieveParams.kt index f2cf29f1..344a2ff1 100644 --- a/onebusaway-sdk-kotlin-core/src/main/kotlin/org/onebusaway/models/ConfigRetrieveParams.kt +++ b/onebusaway-sdk-kotlin-core/src/main/kotlin/org/onebusaway/models/ConfigRetrieveParams.kt @@ -27,6 +27,8 @@ private constructor( companion object { + fun none(): ConfigRetrieveParams = builder().build() + fun builder() = Builder() } diff --git a/onebusaway-sdk-kotlin-core/src/main/kotlin/org/onebusaway/models/CurrentTimeRetrieveParams.kt b/onebusaway-sdk-kotlin-core/src/main/kotlin/org/onebusaway/models/CurrentTimeRetrieveParams.kt index f360e847..efcc7fc9 100644 --- a/onebusaway-sdk-kotlin-core/src/main/kotlin/org/onebusaway/models/CurrentTimeRetrieveParams.kt +++ b/onebusaway-sdk-kotlin-core/src/main/kotlin/org/onebusaway/models/CurrentTimeRetrieveParams.kt @@ -27,6 +27,8 @@ private constructor( companion object { + fun none(): CurrentTimeRetrieveParams = builder().build() + fun builder() = Builder() } diff --git a/onebusaway-sdk-kotlin-core/src/main/kotlin/org/onebusaway/services/async/AgenciesWithCoverageServiceAsync.kt b/onebusaway-sdk-kotlin-core/src/main/kotlin/org/onebusaway/services/async/AgenciesWithCoverageServiceAsync.kt index be68aa05..dfdc7542 100644 --- a/onebusaway-sdk-kotlin-core/src/main/kotlin/org/onebusaway/services/async/AgenciesWithCoverageServiceAsync.kt +++ b/onebusaway-sdk-kotlin-core/src/main/kotlin/org/onebusaway/services/async/AgenciesWithCoverageServiceAsync.kt @@ -13,7 +13,14 @@ interface AgenciesWithCoverageServiceAsync { * center of their coverage area. */ suspend fun list( - params: AgenciesWithCoverageListParams, + params: AgenciesWithCoverageListParams = AgenciesWithCoverageListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): AgenciesWithCoverageListResponse + + /** + * Returns a list of all transit agencies currently supported by OneBusAway along with the + * center of their coverage area. + */ + suspend fun list(requestOptions: RequestOptions): AgenciesWithCoverageListResponse = + list(AgenciesWithCoverageListParams.none(), requestOptions) } diff --git a/onebusaway-sdk-kotlin-core/src/main/kotlin/org/onebusaway/services/async/ConfigServiceAsync.kt b/onebusaway-sdk-kotlin-core/src/main/kotlin/org/onebusaway/services/async/ConfigServiceAsync.kt index c464f3b0..6f22ba50 100644 --- a/onebusaway-sdk-kotlin-core/src/main/kotlin/org/onebusaway/services/async/ConfigServiceAsync.kt +++ b/onebusaway-sdk-kotlin-core/src/main/kotlin/org/onebusaway/services/async/ConfigServiceAsync.kt @@ -10,7 +10,11 @@ interface ConfigServiceAsync { /** config */ suspend fun retrieve( - params: ConfigRetrieveParams, + params: ConfigRetrieveParams = ConfigRetrieveParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): ConfigRetrieveResponse + + /** config */ + suspend fun retrieve(requestOptions: RequestOptions): ConfigRetrieveResponse = + retrieve(ConfigRetrieveParams.none(), requestOptions) } diff --git a/onebusaway-sdk-kotlin-core/src/main/kotlin/org/onebusaway/services/async/CurrentTimeServiceAsync.kt b/onebusaway-sdk-kotlin-core/src/main/kotlin/org/onebusaway/services/async/CurrentTimeServiceAsync.kt index 73f89f95..968f0e71 100644 --- a/onebusaway-sdk-kotlin-core/src/main/kotlin/org/onebusaway/services/async/CurrentTimeServiceAsync.kt +++ b/onebusaway-sdk-kotlin-core/src/main/kotlin/org/onebusaway/services/async/CurrentTimeServiceAsync.kt @@ -10,7 +10,11 @@ interface CurrentTimeServiceAsync { /** current-time */ suspend fun retrieve( - params: CurrentTimeRetrieveParams, + params: CurrentTimeRetrieveParams = CurrentTimeRetrieveParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CurrentTimeRetrieveResponse + + /** current-time */ + suspend fun retrieve(requestOptions: RequestOptions): CurrentTimeRetrieveResponse = + retrieve(CurrentTimeRetrieveParams.none(), requestOptions) } diff --git a/onebusaway-sdk-kotlin-core/src/main/kotlin/org/onebusaway/services/blocking/AgenciesWithCoverageService.kt b/onebusaway-sdk-kotlin-core/src/main/kotlin/org/onebusaway/services/blocking/AgenciesWithCoverageService.kt index e8f4da8a..25a5e566 100644 --- a/onebusaway-sdk-kotlin-core/src/main/kotlin/org/onebusaway/services/blocking/AgenciesWithCoverageService.kt +++ b/onebusaway-sdk-kotlin-core/src/main/kotlin/org/onebusaway/services/blocking/AgenciesWithCoverageService.kt @@ -13,7 +13,14 @@ interface AgenciesWithCoverageService { * center of their coverage area. */ fun list( - params: AgenciesWithCoverageListParams, + params: AgenciesWithCoverageListParams = AgenciesWithCoverageListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): AgenciesWithCoverageListResponse + + /** + * Returns a list of all transit agencies currently supported by OneBusAway along with the + * center of their coverage area. + */ + fun list(requestOptions: RequestOptions): AgenciesWithCoverageListResponse = + list(AgenciesWithCoverageListParams.none(), requestOptions) } diff --git a/onebusaway-sdk-kotlin-core/src/main/kotlin/org/onebusaway/services/blocking/ConfigService.kt b/onebusaway-sdk-kotlin-core/src/main/kotlin/org/onebusaway/services/blocking/ConfigService.kt index 317f77fc..f40ab0e1 100644 --- a/onebusaway-sdk-kotlin-core/src/main/kotlin/org/onebusaway/services/blocking/ConfigService.kt +++ b/onebusaway-sdk-kotlin-core/src/main/kotlin/org/onebusaway/services/blocking/ConfigService.kt @@ -10,7 +10,11 @@ interface ConfigService { /** config */ fun retrieve( - params: ConfigRetrieveParams, + params: ConfigRetrieveParams = ConfigRetrieveParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): ConfigRetrieveResponse + + /** config */ + fun retrieve(requestOptions: RequestOptions): ConfigRetrieveResponse = + retrieve(ConfigRetrieveParams.none(), requestOptions) } diff --git a/onebusaway-sdk-kotlin-core/src/main/kotlin/org/onebusaway/services/blocking/CurrentTimeService.kt b/onebusaway-sdk-kotlin-core/src/main/kotlin/org/onebusaway/services/blocking/CurrentTimeService.kt index 3a489618..844c425f 100644 --- a/onebusaway-sdk-kotlin-core/src/main/kotlin/org/onebusaway/services/blocking/CurrentTimeService.kt +++ b/onebusaway-sdk-kotlin-core/src/main/kotlin/org/onebusaway/services/blocking/CurrentTimeService.kt @@ -10,7 +10,11 @@ interface CurrentTimeService { /** current-time */ fun retrieve( - params: CurrentTimeRetrieveParams, + params: CurrentTimeRetrieveParams = CurrentTimeRetrieveParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CurrentTimeRetrieveResponse + + /** current-time */ + fun retrieve(requestOptions: RequestOptions): CurrentTimeRetrieveResponse = + retrieve(CurrentTimeRetrieveParams.none(), requestOptions) } diff --git a/onebusaway-sdk-kotlin-core/src/test/kotlin/org/onebusaway/services/blocking/AgenciesWithCoverageServiceTest.kt b/onebusaway-sdk-kotlin-core/src/test/kotlin/org/onebusaway/services/blocking/AgenciesWithCoverageServiceTest.kt index a4753b7a..43b3732f 100644 --- a/onebusaway-sdk-kotlin-core/src/test/kotlin/org/onebusaway/services/blocking/AgenciesWithCoverageServiceTest.kt +++ b/onebusaway-sdk-kotlin-core/src/test/kotlin/org/onebusaway/services/blocking/AgenciesWithCoverageServiceTest.kt @@ -6,7 +6,6 @@ import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith import org.onebusaway.TestServerExtension import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClient -import org.onebusaway.models.AgenciesWithCoverageListParams @ExtendWith(TestServerExtension::class) class AgenciesWithCoverageServiceTest { @@ -19,8 +18,7 @@ class AgenciesWithCoverageServiceTest { .apiKey("My API Key") .build() val agenciesWithCoverageService = client.agenciesWithCoverage() - val agenciesWithCoverageListResponse = - agenciesWithCoverageService.list(AgenciesWithCoverageListParams.builder().build()) + val agenciesWithCoverageListResponse = agenciesWithCoverageService.list() println(agenciesWithCoverageListResponse) } } diff --git a/onebusaway-sdk-kotlin-core/src/test/kotlin/org/onebusaway/services/blocking/ConfigServiceTest.kt b/onebusaway-sdk-kotlin-core/src/test/kotlin/org/onebusaway/services/blocking/ConfigServiceTest.kt index 70704a46..2943965f 100644 --- a/onebusaway-sdk-kotlin-core/src/test/kotlin/org/onebusaway/services/blocking/ConfigServiceTest.kt +++ b/onebusaway-sdk-kotlin-core/src/test/kotlin/org/onebusaway/services/blocking/ConfigServiceTest.kt @@ -6,7 +6,6 @@ import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith import org.onebusaway.TestServerExtension import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClient -import org.onebusaway.models.ConfigRetrieveParams @ExtendWith(TestServerExtension::class) class ConfigServiceTest { @@ -19,7 +18,7 @@ class ConfigServiceTest { .apiKey("My API Key") .build() val configService = client.config() - val configRetrieveResponse = configService.retrieve(ConfigRetrieveParams.builder().build()) + val configRetrieveResponse = configService.retrieve() println(configRetrieveResponse) } } diff --git a/onebusaway-sdk-kotlin-core/src/test/kotlin/org/onebusaway/services/blocking/CurrentTimeServiceTest.kt b/onebusaway-sdk-kotlin-core/src/test/kotlin/org/onebusaway/services/blocking/CurrentTimeServiceTest.kt index 10b9f47d..bd714b98 100644 --- a/onebusaway-sdk-kotlin-core/src/test/kotlin/org/onebusaway/services/blocking/CurrentTimeServiceTest.kt +++ b/onebusaway-sdk-kotlin-core/src/test/kotlin/org/onebusaway/services/blocking/CurrentTimeServiceTest.kt @@ -6,7 +6,6 @@ import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith import org.onebusaway.TestServerExtension import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClient -import org.onebusaway.models.CurrentTimeRetrieveParams @ExtendWith(TestServerExtension::class) class CurrentTimeServiceTest { @@ -19,8 +18,7 @@ class CurrentTimeServiceTest { .apiKey("My API Key") .build() val currentTimeService = client.currentTime() - val currentTimeRetrieveResponse = - currentTimeService.retrieve(CurrentTimeRetrieveParams.builder().build()) + val currentTimeRetrieveResponse = currentTimeService.retrieve() println(currentTimeRetrieveResponse) } }