Skip to content
This repository was archived by the owner on Mar 19, 2024. It is now read-only.

Commit 37250fc

Browse files
committed
Apply CR suggestions
1 parent f35f416 commit 37250fc

File tree

3 files changed

+11
-14
lines changed

3 files changed

+11
-14
lines changed

owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/oauth/RegisterClientRemoteOperation.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,10 @@ class RegisterClientRemoteOperation(
4747
try {
4848
val requestBody = clientRegistrationParams.toRequestBody()
4949

50-
val postMethod = PostMethod(URL(clientRegistrationParams.registrationEndpoint), requestBody)
50+
val postMethod = PostMethod(
51+
url = URL(clientRegistrationParams.registrationEndpoint),
52+
postRequestBody = requestBody
53+
)
5154

5255
val status = client.executeHttpMethod(postMethod)
5356

owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/oauth/params/ClientRegistrationParams.kt

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,17 +40,13 @@ data class ClientRegistrationParams(
4040
val tokenEndpointAuthMethod: String,
4141
val applicationType: String
4242
) {
43-
fun toRequestBody(): RequestBody {
44-
val jsonObject = JSONObject().apply {
43+
fun toRequestBody(): RequestBody =
44+
JSONObject().apply {
4545
put(PARAM_APPLICATION_TYPE, applicationType)
4646
put(PARAM_CLIENT_NAME, clientName)
4747
put(PARAM_REDIRECT_URIS, JSONArray(redirectUris))
4848
put(PARAM_TOKEN_ENDPOINT_AUTH_METHOD, tokenEndpointAuthMethod)
49-
}
50-
51-
val mediaType = CONTENT_TYPE_JSON.toMediaType()
52-
return jsonObject.toString().toRequestBody(mediaType)
53-
}
49+
}.toString().toRequestBody(CONTENT_TYPE_JSON.toMediaType())
5450

5551
companion object {
5652
private const val PARAM_APPLICATION_TYPE = "application_type"

owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/oauth/params/TokenRequestParams.kt

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,12 @@ sealed class TokenRequestParams(
4242
val redirectUri: String
4343
) : TokenRequestParams(tokenEndpoint, clientAuth, grantType) {
4444

45-
override fun toRequestBody(): RequestBody {
46-
return FormBody.Builder()
45+
override fun toRequestBody(): RequestBody =
46+
FormBody.Builder()
4747
.add(HttpConstants.OAUTH_HEADER_AUTHORIZATION_CODE, authorizationCode)
4848
.add(HttpConstants.OAUTH_HEADER_GRANT_TYPE, grantType)
4949
.add(HttpConstants.OAUTH_HEADER_REDIRECT_URI, redirectUri)
5050
.build()
51-
}
5251
}
5352

5453
class RefreshToken(
@@ -58,14 +57,13 @@ sealed class TokenRequestParams(
5857
val refreshToken: String? = null
5958
) : TokenRequestParams(tokenEndpoint, clientAuth, grantType) {
6059

61-
override fun toRequestBody(): RequestBody {
62-
return FormBody.Builder().apply {
60+
override fun toRequestBody(): RequestBody =
61+
FormBody.Builder().apply {
6362
add(HttpConstants.OAUTH_HEADER_GRANT_TYPE, grantType)
6463
if (!refreshToken.isNullOrBlank()) {
6564
add(HttpConstants.OAUTH_HEADER_REFRESH_TOKEN, refreshToken)
6665
}
6766
}.build()
6867

69-
}
7068
}
7169
}

0 commit comments

Comments
 (0)