Skip to content

Commit

Permalink
chore(internal): codegen related update (#80)
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-app[bot] committed Nov 23, 2024
1 parent 6e570b7 commit 428f2fd
Show file tree
Hide file tree
Showing 31 changed files with 652 additions and 617 deletions.
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,22 @@ val client = OnebusawaySdkOkHttpClient.builder()
.build()
```

## Logging

We use the standard [OkHttp logging interceptor](https://github.com/square/okhttp/tree/master/okhttp-logging-interceptor).

You can enable logging by setting the environment variable `ONEBUSAWAY_SDK_LOG` to `info`.

```sh
$ export ONEBUSAWAY_SDK_LOG=info
```

Or to `debug` for more verbose logging.

```sh
$ export ONEBUSAWAY_SDK_LOG=debug
```

## Semantic versioning

This package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions, though certain backwards-incompatible changes may be released as minor versions:
Expand Down
1 change: 1 addition & 0 deletions onebusaway-sdk-kotlin-client-okhttp/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ dependencies {
api(project(":onebusaway-sdk-kotlin-core"))

implementation("com.squareup.okhttp3:okhttp:4.12.0")
implementation("com.squareup.okhttp3:logging-interceptor:4.12.0")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.8.0")

testImplementation(kotlin("test"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import okhttp3.Request
import okhttp3.RequestBody
import okhttp3.RequestBody.Companion.toRequestBody
import okhttp3.Response
import okhttp3.logging.HttpLoggingInterceptor
import okio.BufferedSink
import org.onebusaway.core.RequestOptions
import org.onebusaway.core.http.Headers
Expand All @@ -30,14 +31,28 @@ private constructor(private val okHttpClient: okhttp3.OkHttpClient, private val
HttpClient {

private fun getClient(requestOptions: RequestOptions): okhttp3.OkHttpClient {
val timeout = requestOptions.timeout ?: return okHttpClient
return okHttpClient
.newBuilder()
.connectTimeout(timeout)
.readTimeout(timeout)
.writeTimeout(timeout)
.callTimeout(if (timeout.seconds == 0L) timeout else timeout.plusSeconds(30))
.build()
val clientBuilder = okHttpClient.newBuilder()

val logLevel =
when (System.getenv("ONEBUSAWAY_SDK_LOG")?.lowercase()) {
"info" -> HttpLoggingInterceptor.Level.BASIC
"debug" -> HttpLoggingInterceptor.Level.BODY
else -> null
}
if (logLevel != null) {
clientBuilder.addNetworkInterceptor(HttpLoggingInterceptor().setLevel(logLevel))
}

val timeout = requestOptions.timeout
if (timeout != null) {
clientBuilder
.connectTimeout(timeout)
.readTimeout(timeout)
.writeTimeout(timeout)
.callTimeout(if (timeout.seconds == 0L) timeout else timeout.plusSeconds(30))
}

return clientBuilder.build()
}

override fun execute(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,26 +14,13 @@ constructor(
private val additionalQueryParams: QueryParams,
) {

internal fun getHeaders(): Headers = additionalHeaders

internal fun getQueryParams(): QueryParams = additionalQueryParams

fun _additionalHeaders(): Headers = additionalHeaders

fun _additionalQueryParams(): QueryParams = additionalQueryParams

override fun equals(other: Any?): Boolean {
if (this === other) {
return true
}

return /* spotless:off */ other is AgenciesWithCoverageListParams && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */
}

override fun hashCode(): Int = /* spotless:off */ Objects.hash(additionalHeaders, additionalQueryParams) /* spotless:on */
internal fun getHeaders(): Headers = additionalHeaders

override fun toString() =
"AgenciesWithCoverageListParams{additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}"
internal fun getQueryParams(): QueryParams = additionalQueryParams

fun toBuilder() = Builder().from(this)

Expand All @@ -49,8 +36,8 @@ constructor(
private var additionalQueryParams: QueryParams.Builder = QueryParams.builder()

internal fun from(agenciesWithCoverageListParams: AgenciesWithCoverageListParams) = apply {
additionalHeaders(agenciesWithCoverageListParams.additionalHeaders)
additionalQueryParams(agenciesWithCoverageListParams.additionalQueryParams)
additionalHeaders = agenciesWithCoverageListParams.additionalHeaders.toBuilder()
additionalQueryParams = agenciesWithCoverageListParams.additionalQueryParams.toBuilder()
}

fun additionalHeaders(additionalHeaders: Headers) = apply {
Expand Down Expand Up @@ -154,4 +141,17 @@ constructor(
fun build(): AgenciesWithCoverageListParams =
AgenciesWithCoverageListParams(additionalHeaders.build(), additionalQueryParams.build())
}

override fun equals(other: Any?): Boolean {
if (this === other) {
return true
}

return /* spotless:off */ other is AgenciesWithCoverageListParams && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */
}

override fun hashCode(): Int = /* spotless:off */ Objects.hash(additionalHeaders, additionalQueryParams) /* spotless:on */

override fun toString() =
"AgenciesWithCoverageListParams{additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}"
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ constructor(

fun agencyId(): String = agencyId

fun _additionalHeaders(): Headers = additionalHeaders

fun _additionalQueryParams(): QueryParams = additionalQueryParams

internal fun getHeaders(): Headers = additionalHeaders

internal fun getQueryParams(): QueryParams = additionalQueryParams
Expand All @@ -28,23 +32,6 @@ constructor(
}
}

fun _additionalHeaders(): Headers = additionalHeaders

fun _additionalQueryParams(): QueryParams = additionalQueryParams

override fun equals(other: Any?): Boolean {
if (this === other) {
return true
}

return /* spotless:off */ other is AgencyRetrieveParams && agencyId == other.agencyId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */
}

override fun hashCode(): Int = /* spotless:off */ Objects.hash(agencyId, additionalHeaders, additionalQueryParams) /* spotless:on */

override fun toString() =
"AgencyRetrieveParams{agencyId=$agencyId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}"

fun toBuilder() = Builder().from(this)

companion object {
Expand All @@ -60,9 +47,9 @@ constructor(
private var additionalQueryParams: QueryParams.Builder = QueryParams.builder()

internal fun from(agencyRetrieveParams: AgencyRetrieveParams) = apply {
this.agencyId = agencyRetrieveParams.agencyId
additionalHeaders(agencyRetrieveParams.additionalHeaders)
additionalQueryParams(agencyRetrieveParams.additionalQueryParams)
agencyId = agencyRetrieveParams.agencyId
additionalHeaders = agencyRetrieveParams.additionalHeaders.toBuilder()
additionalQueryParams = agencyRetrieveParams.additionalQueryParams.toBuilder()
}

fun agencyId(agencyId: String) = apply { this.agencyId = agencyId }
Expand Down Expand Up @@ -172,4 +159,17 @@ constructor(
additionalQueryParams.build(),
)
}

override fun equals(other: Any?): Boolean {
if (this === other) {
return true
}

return /* spotless:off */ other is AgencyRetrieveParams && agencyId == other.agencyId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */
}

override fun hashCode(): Int = /* spotless:off */ Objects.hash(agencyId, additionalHeaders, additionalQueryParams) /* spotless:on */

override fun toString() =
"AgencyRetrieveParams{agencyId=$agencyId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}"
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ constructor(

fun time(): OffsetDateTime? = time

fun _additionalHeaders(): Headers = additionalHeaders

fun _additionalQueryParams(): QueryParams = additionalQueryParams

internal fun getHeaders(): Headers = additionalHeaders

internal fun getQueryParams(): QueryParams {
Expand All @@ -48,23 +52,6 @@ constructor(
}
}

fun _additionalHeaders(): Headers = additionalHeaders

fun _additionalQueryParams(): QueryParams = additionalQueryParams

override fun equals(other: Any?): Boolean {
if (this === other) {
return true
}

return /* spotless:off */ other is ArrivalAndDepartureListParams && stopId == other.stopId && minutesAfter == other.minutesAfter && minutesBefore == other.minutesBefore && time == other.time && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */
}

override fun hashCode(): Int = /* spotless:off */ Objects.hash(stopId, minutesAfter, minutesBefore, time, additionalHeaders, additionalQueryParams) /* spotless:on */

override fun toString() =
"ArrivalAndDepartureListParams{stopId=$stopId, minutesAfter=$minutesAfter, minutesBefore=$minutesBefore, time=$time, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}"

fun toBuilder() = Builder().from(this)

companion object {
Expand All @@ -83,12 +70,12 @@ constructor(
private var additionalQueryParams: QueryParams.Builder = QueryParams.builder()

internal fun from(arrivalAndDepartureListParams: ArrivalAndDepartureListParams) = apply {
this.stopId = arrivalAndDepartureListParams.stopId
this.minutesAfter = arrivalAndDepartureListParams.minutesAfter
this.minutesBefore = arrivalAndDepartureListParams.minutesBefore
this.time = arrivalAndDepartureListParams.time
additionalHeaders(arrivalAndDepartureListParams.additionalHeaders)
additionalQueryParams(arrivalAndDepartureListParams.additionalQueryParams)
stopId = arrivalAndDepartureListParams.stopId
minutesAfter = arrivalAndDepartureListParams.minutesAfter
minutesBefore = arrivalAndDepartureListParams.minutesBefore
time = arrivalAndDepartureListParams.time
additionalHeaders = arrivalAndDepartureListParams.additionalHeaders.toBuilder()
additionalQueryParams = arrivalAndDepartureListParams.additionalQueryParams.toBuilder()
}

fun stopId(stopId: String) = apply { this.stopId = stopId }
Expand Down Expand Up @@ -210,4 +197,17 @@ constructor(
additionalQueryParams.build(),
)
}

override fun equals(other: Any?): Boolean {
if (this === other) {
return true
}

return /* spotless:off */ other is ArrivalAndDepartureListParams && stopId == other.stopId && minutesAfter == other.minutesAfter && minutesBefore == other.minutesBefore && time == other.time && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */
}

override fun hashCode(): Int = /* spotless:off */ Objects.hash(stopId, minutesAfter, minutesBefore, time, additionalHeaders, additionalQueryParams) /* spotless:on */

override fun toString() =
"ArrivalAndDepartureListParams{stopId=$stopId, minutesAfter=$minutesAfter, minutesBefore=$minutesBefore, time=$time, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}"
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ constructor(

fun vehicleId(): String? = vehicleId

fun _additionalHeaders(): Headers = additionalHeaders

fun _additionalQueryParams(): QueryParams = additionalQueryParams

internal fun getHeaders(): Headers = additionalHeaders

internal fun getQueryParams(): QueryParams {
Expand All @@ -52,23 +56,6 @@ constructor(
}
}

fun _additionalHeaders(): Headers = additionalHeaders

fun _additionalQueryParams(): QueryParams = additionalQueryParams

override fun equals(other: Any?): Boolean {
if (this === other) {
return true
}

return /* spotless:off */ other is ArrivalAndDepartureRetrieveParams && stopId == other.stopId && serviceDate == other.serviceDate && tripId == other.tripId && stopSequence == other.stopSequence && time == other.time && vehicleId == other.vehicleId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */
}

override fun hashCode(): Int = /* spotless:off */ Objects.hash(stopId, serviceDate, tripId, stopSequence, time, vehicleId, additionalHeaders, additionalQueryParams) /* spotless:on */

override fun toString() =
"ArrivalAndDepartureRetrieveParams{stopId=$stopId, serviceDate=$serviceDate, tripId=$tripId, stopSequence=$stopSequence, time=$time, vehicleId=$vehicleId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}"

fun toBuilder() = Builder().from(this)

companion object {
Expand All @@ -90,14 +77,15 @@ constructor(

internal fun from(arrivalAndDepartureRetrieveParams: ArrivalAndDepartureRetrieveParams) =
apply {
this.stopId = arrivalAndDepartureRetrieveParams.stopId
this.serviceDate = arrivalAndDepartureRetrieveParams.serviceDate
this.tripId = arrivalAndDepartureRetrieveParams.tripId
this.stopSequence = arrivalAndDepartureRetrieveParams.stopSequence
this.time = arrivalAndDepartureRetrieveParams.time
this.vehicleId = arrivalAndDepartureRetrieveParams.vehicleId
additionalHeaders(arrivalAndDepartureRetrieveParams.additionalHeaders)
additionalQueryParams(arrivalAndDepartureRetrieveParams.additionalQueryParams)
stopId = arrivalAndDepartureRetrieveParams.stopId
serviceDate = arrivalAndDepartureRetrieveParams.serviceDate
tripId = arrivalAndDepartureRetrieveParams.tripId
stopSequence = arrivalAndDepartureRetrieveParams.stopSequence
time = arrivalAndDepartureRetrieveParams.time
vehicleId = arrivalAndDepartureRetrieveParams.vehicleId
additionalHeaders = arrivalAndDepartureRetrieveParams.additionalHeaders.toBuilder()
additionalQueryParams =
arrivalAndDepartureRetrieveParams.additionalQueryParams.toBuilder()
}

fun stopId(stopId: String) = apply { this.stopId = stopId }
Expand Down Expand Up @@ -222,4 +210,17 @@ constructor(
additionalQueryParams.build(),
)
}

override fun equals(other: Any?): Boolean {
if (this === other) {
return true
}

return /* spotless:off */ other is ArrivalAndDepartureRetrieveParams && stopId == other.stopId && serviceDate == other.serviceDate && tripId == other.tripId && stopSequence == other.stopSequence && time == other.time && vehicleId == other.vehicleId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */
}

override fun hashCode(): Int = /* spotless:off */ Objects.hash(stopId, serviceDate, tripId, stopSequence, time, vehicleId, additionalHeaders, additionalQueryParams) /* spotless:on */

override fun toString() =
"ArrivalAndDepartureRetrieveParams{stopId=$stopId, serviceDate=$serviceDate, tripId=$tripId, stopSequence=$stopSequence, time=$time, vehicleId=$vehicleId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}"
}
Loading

0 comments on commit 428f2fd

Please sign in to comment.