Skip to content

Commit

Permalink
[Kotlin] Allow other content-types when only interested in status-cod…
Browse files Browse the repository at this point in the history
…e / Unit (#19801)

* Allow Unit response

* Updating samples

* Improve comment for Unit shortcut
  • Loading branch information
roelwuytens-androme authored Oct 7, 2024
1 parent 9a0fc59 commit 7d1e999
Show file tree
Hide file tree
Showing 21 changed files with 105 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,11 @@ import com.squareup.moshi.adapter
val body = response.body
if(body == null) {
return null
}
if (T::class.java == File::class.java) {
} else if (T::class.java == Unit::class.java) {
// No need to parse the body when we're not interested in the body
// Useful when API is returning other Content-Type
return null
} else if (T::class.java == File::class.java) {
// return tempFile
val contentDisposition = response.header("Content-Disposition")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,11 @@ open class ApiClient(val baseUrl: String, val client: Call.Factory = defaultClie
val body = response.body
if(body == null) {
return null
}
if (T::class.java == File::class.java) {
} else if (T::class.java == Unit::class.java) {
// No need to parse the body when we're not interested in the body
// Useful when API is returning other Content-Type
return null
} else if (T::class.java == File::class.java) {
// return tempFile
val contentDisposition = response.header("Content-Disposition")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,11 @@ open class ApiClient(val baseUrl: String, val client: Call.Factory = defaultClie
val body = response.body
if(body == null) {
return null
}
if (T::class.java == File::class.java) {
} else if (T::class.java == Unit::class.java) {
// No need to parse the body when we're not interested in the body
// Useful when API is returning other Content-Type
return null
} else if (T::class.java == File::class.java) {
// return tempFile
val contentDisposition = response.header("Content-Disposition")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,11 @@ open class ApiClient(val baseUrl: String, val client: Call.Factory = defaultClie
val body = response.body
if(body == null) {
return null
}
if (T::class.java == File::class.java) {
} else if (T::class.java == Unit::class.java) {
// No need to parse the body when we're not interested in the body
// Useful when API is returning other Content-Type
return null
} else if (T::class.java == File::class.java) {
// return tempFile
val contentDisposition = response.header("Content-Disposition")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,11 @@ open class ApiClient(val baseUrl: String, val client: Call.Factory = defaultClie
val body = response.body
if(body == null) {
return null
}
if (T::class.java == File::class.java) {
} else if (T::class.java == Unit::class.java) {
// No need to parse the body when we're not interested in the body
// Useful when API is returning other Content-Type
return null
} else if (T::class.java == File::class.java) {
// return tempFile
val contentDisposition = response.header("Content-Disposition")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,11 @@ open class ApiClient(val baseUrl: String, val client: Call.Factory = defaultClie
val body = response.body
if(body == null) {
return null
}
if (T::class.java == File::class.java) {
} else if (T::class.java == Unit::class.java) {
// No need to parse the body when we're not interested in the body
// Useful when API is returning other Content-Type
return null
} else if (T::class.java == File::class.java) {
// return tempFile
val contentDisposition = response.header("Content-Disposition")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,11 @@ open class ApiClient(val baseUrl: String, val client: Call.Factory = defaultClie
val body = response.body
if(body == null) {
return null
}
if (T::class.java == File::class.java) {
} else if (T::class.java == Unit::class.java) {
// No need to parse the body when we're not interested in the body
// Useful when API is returning other Content-Type
return null
} else if (T::class.java == File::class.java) {
// return tempFile
val contentDisposition = response.header("Content-Disposition")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,11 @@ open class ApiClient(val baseUrl: String, val client: Call.Factory = defaultClie
val body = response.body
if(body == null) {
return null
}
if (T::class.java == File::class.java) {
} else if (T::class.java == Unit::class.java) {
// No need to parse the body when we're not interested in the body
// Useful when API is returning other Content-Type
return null
} else if (T::class.java == File::class.java) {
// return tempFile
val contentDisposition = response.header("Content-Disposition")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,11 @@ open class ApiClient(val baseUrl: String, val client: Call.Factory = defaultClie
val body = response.body
if(body == null) {
return null
}
if (T::class.java == File::class.java) {
} else if (T::class.java == Unit::class.java) {
// No need to parse the body when we're not interested in the body
// Useful when API is returning other Content-Type
return null
} else if (T::class.java == File::class.java) {
// return tempFile
val contentDisposition = response.header("Content-Disposition")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,11 @@ open class ApiClient(val baseUrl: String, val client: Call.Factory = defaultClie
val body = response.body
if(body == null) {
return null
}
if (T::class.java == File::class.java) {
} else if (T::class.java == Unit::class.java) {
// No need to parse the body when we're not interested in the body
// Useful when API is returning other Content-Type
return null
} else if (T::class.java == File::class.java) {
// return tempFile
val contentDisposition = response.header("Content-Disposition")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,11 @@ open class ApiClient(val baseUrl: String, val client: Call.Factory = defaultClie
val body = response.body
if(body == null) {
return null
}
if (T::class.java == File::class.java) {
} else if (T::class.java == Unit::class.java) {
// No need to parse the body when we're not interested in the body
// Useful when API is returning other Content-Type
return null
} else if (T::class.java == File::class.java) {
// return tempFile
val contentDisposition = response.header("Content-Disposition")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,11 @@ open class ApiClient(val baseUrl: String, val client: Call.Factory = defaultClie
val body = response.body
if(body == null) {
return null
}
if (T::class.java == File::class.java) {
} else if (T::class.java == Unit::class.java) {
// No need to parse the body when we're not interested in the body
// Useful when API is returning other Content-Type
return null
} else if (T::class.java == File::class.java) {
// return tempFile
val contentDisposition = response.header("Content-Disposition")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,11 @@ open class ApiClient(val baseUrl: String, val client: Call.Factory = defaultClie
val body = response.body
if(body == null) {
return null
}
if (T::class.java == File::class.java) {
} else if (T::class.java == Unit::class.java) {
// No need to parse the body when we're not interested in the body
// Useful when API is returning other Content-Type
return null
} else if (T::class.java == File::class.java) {
// return tempFile
val contentDisposition = response.header("Content-Disposition")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,11 @@ open class ApiClient(val baseUrl: String, val client: Call.Factory = defaultClie
val body = response.body
if(body == null) {
return null
}
if (T::class.java == File::class.java) {
} else if (T::class.java == Unit::class.java) {
// No need to parse the body when we're not interested in the body
// Useful when API is returning other Content-Type
return null
} else if (T::class.java == File::class.java) {
// return tempFile
val contentDisposition = response.header("Content-Disposition")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,11 @@ open class ApiClient(val baseUrl: String, val client: Call.Factory = defaultClie
val body = response.body
if(body == null) {
return null
}
if (T::class.java == File::class.java) {
} else if (T::class.java == Unit::class.java) {
// No need to parse the body when we're not interested in the body
// Useful when API is returning other Content-Type
return null
} else if (T::class.java == File::class.java) {
// return tempFile
val contentDisposition = response.header("Content-Disposition")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,11 @@ internal open class ApiClient(val baseUrl: String, val client: Call.Factory = de
val body = response.body
if(body == null) {
return null
}
if (T::class.java == File::class.java) {
} else if (T::class.java == Unit::class.java) {
// No need to parse the body when we're not interested in the body
// Useful when API is returning other Content-Type
return null
} else if (T::class.java == File::class.java) {
// return tempFile
val contentDisposition = response.header("Content-Disposition")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,11 @@ open class ApiClient(val baseUrl: String, val client: Call.Factory = defaultClie
val body = response.body
if(body == null) {
return null
}
if (T::class.java == File::class.java) {
} else if (T::class.java == Unit::class.java) {
// No need to parse the body when we're not interested in the body
// Useful when API is returning other Content-Type
return null
} else if (T::class.java == File::class.java) {
// return tempFile
val contentDisposition = response.header("Content-Disposition")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,11 @@ open class ApiClient(val baseUrl: String, val client: Call.Factory = defaultClie
val body = response.body
if(body == null) {
return null
}
if (T::class.java == File::class.java) {
} else if (T::class.java == Unit::class.java) {
// No need to parse the body when we're not interested in the body
// Useful when API is returning other Content-Type
return null
} else if (T::class.java == File::class.java) {
// return tempFile
val contentDisposition = response.header("Content-Disposition")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,11 @@ open class ApiClient(val baseUrl: String, val client: Call.Factory = defaultClie
val body = response.body
if(body == null) {
return null
}
if (T::class.java == File::class.java) {
} else if (T::class.java == Unit::class.java) {
// No need to parse the body when we're not interested in the body
// Useful when API is returning other Content-Type
return null
} else if (T::class.java == File::class.java) {
// return tempFile
val contentDisposition = response.header("Content-Disposition")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,11 @@ open class ApiClient(val baseUrl: String, val client: Call.Factory = defaultClie
val body = response.body
if(body == null) {
return null
}
if (T::class.java == File::class.java) {
} else if (T::class.java == Unit::class.java) {
// No need to parse the body when we're not interested in the body
// Useful when API is returning other Content-Type
return null
} else if (T::class.java == File::class.java) {
// return tempFile
val contentDisposition = response.header("Content-Disposition")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,11 @@ open class ApiClient(val baseUrl: String, val client: Call.Factory = defaultClie
val body = response.body
if(body == null) {
return null
}
if (T::class.java == File::class.java) {
} else if (T::class.java == Unit::class.java) {
// No need to parse the body when we're not interested in the body
// Useful when API is returning other Content-Type
return null
} else if (T::class.java == File::class.java) {
// return tempFile
val contentDisposition = response.header("Content-Disposition")

Expand Down

0 comments on commit 7d1e999

Please sign in to comment.