Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/skydoves/sandwich
Browse files Browse the repository at this point in the history
  • Loading branch information
skydoves committed Nov 16, 2023
2 parents f01cbbe + b33fa08 commit f41deee
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 36 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
runs-on: macos-latest
steps:
- name: Check out code
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Set up JDK
uses: actions/setup-java@v1
with:
Expand All @@ -28,7 +28,7 @@ jobs:
runs-on: macos-latest
steps:
- name: Check out code
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Set up JDK
uses: actions/setup-java@v1
with:
Expand All @@ -40,7 +40,7 @@ jobs:
build:
runs-on: macos-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: set up JDK
uses: actions/setup-java@v1
Expand All @@ -49,7 +49,7 @@ jobs:
java-version: 17

- name: Cache Gradle and wrapper
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: |
~/.gradle/caches
Expand Down
6 changes: 3 additions & 3 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ retrofit = "2.9.0"
okio = "3.6.0"
okhttp = "4.12.0"
ktor = "2.3.6"
ktorfit = "1.10.0"
ktorfit = "1.10.1"
coroutines = "1.7.3"
kotlinSerialization = "1.6.0"
kotlinSerialization = "1.6.1"
ksp = "1.9.20-1.0.14"
moshi = "1.15.0"
glide = "4.16.0"
androidxLifecycle = "2.6.2"
androidxMacroBenchmark = "1.2.0"
androidxMacroBenchmark = "1.2.1"
androidxProfileinstaller = "1.3.1"
androidxUiAutomator = "2.3.0-alpha05"
junit = "4.13.2"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ import io.ktor.http.Url
public suspend inline fun <reified T> HttpClient.requestApiResponse(
builder: HttpRequestBuilder = HttpRequestBuilder(),
): ApiResponse<T> {
val response = HttpStatement(builder, this).execute()
return apiResponseOf { response }
return apiResponseOf { HttpStatement(builder, this).execute() }
}

/**
Expand All @@ -42,10 +41,9 @@ public suspend inline fun <reified T> HttpClient.requestApiResponse(
* @return [ApiResponse]
*/
public suspend inline fun <reified T> HttpClient.requestApiResponse(
block: HttpRequestBuilder.() -> Unit,
crossinline block: HttpRequestBuilder.() -> Unit,
): ApiResponse<T> {
val response = request(HttpRequestBuilder().apply(block))
return apiResponseOf { response }
return apiResponseOf { request(HttpRequestBuilder().apply(block)) }
}

/**
Expand All @@ -55,13 +53,14 @@ public suspend inline fun <reified T> HttpClient.requestApiResponse(
*/
public suspend inline fun <reified T> HttpClient.requestApiResponse(
urlString: String,
block: HttpRequestBuilder.() -> Unit = {},
crossinline block: HttpRequestBuilder.() -> Unit = {},
): ApiResponse<T> {
val response = request {
url(urlString)
block()
return apiResponseOf {
request {
url(urlString)
block()
}
}
return apiResponseOf { response }
}

/**
Expand All @@ -71,13 +70,14 @@ public suspend inline fun <reified T> HttpClient.requestApiResponse(
*/
public suspend inline fun <reified T> HttpClient.requestApiResponse(
url: Url,
block: HttpRequestBuilder.() -> Unit = {},
crossinline block: HttpRequestBuilder.() -> Unit = {},
): ApiResponse<T> {
val response = request {
url(url)
block()
return apiResponseOf {
request {
url(url)
block()
}
}
return apiResponseOf { response }
}

/**
Expand All @@ -89,8 +89,7 @@ public suspend inline fun <reified T> HttpClient.getApiResponse(
builder: HttpRequestBuilder,
): ApiResponse<T> {
builder.method = HttpMethod.Get
val response = request(builder)
return apiResponseOf { response }
return apiResponseOf { request(builder) }
}

/**
Expand All @@ -102,8 +101,7 @@ public suspend inline fun <reified T> HttpClient.postApiResponse(
builder: HttpRequestBuilder,
): ApiResponse<T> {
builder.method = HttpMethod.Post
val response = request(builder)
return apiResponseOf { response }
return apiResponseOf { request(builder) }
}

/**
Expand All @@ -115,8 +113,7 @@ public suspend inline fun <reified T> HttpClient.putApiResponse(
builder: HttpRequestBuilder,
): ApiResponse<T> {
builder.method = HttpMethod.Put
val response = request(builder)
return apiResponseOf { response }
return apiResponseOf { request(builder) }
}

/**
Expand All @@ -128,8 +125,7 @@ public suspend inline fun <reified T> HttpClient.deleteApiResponse(
builder: HttpRequestBuilder,
): ApiResponse<T> {
builder.method = HttpMethod.Delete
val response = request(builder)
return apiResponseOf { response }
return apiResponseOf { request(builder) }
}

/**
Expand All @@ -141,8 +137,7 @@ public suspend inline fun <reified T> HttpClient.optionsApiResponse(
builder: HttpRequestBuilder,
): ApiResponse<T> {
builder.method = HttpMethod.Options
val response = request(builder)
return apiResponseOf { response }
return apiResponseOf { request(builder) }
}

/**
Expand All @@ -154,8 +149,7 @@ public suspend inline fun <reified T> HttpClient.patchApiResponse(
builder: HttpRequestBuilder,
): ApiResponse<T> {
builder.method = HttpMethod.Patch
val response = request(builder)
return apiResponseOf { response }
return apiResponseOf { request(builder) }
}

/**
Expand All @@ -167,8 +161,7 @@ public suspend inline fun <reified T> HttpClient.headApiResponse(
builder: HttpRequestBuilder,
): ApiResponse<T> {
builder.method = HttpMethod.Head
val response = request(builder)
return apiResponseOf { response }
return apiResponseOf { request(builder) }
}

/**
Expand Down

0 comments on commit f41deee

Please sign in to comment.