From 4fdd2f4eed2f1d3493d03925128005ccaed531f1 Mon Sep 17 00:00:00 2001 From: ganfra Date: Wed, 6 May 2020 15:53:28 +0200 Subject: [PATCH] Create WidgetsAPI --- .../session/widgets/RegisterWidgetResponse.kt | 25 +++++++++++++ .../internal/session/widgets/WidgetsAPI.kt | 36 +++++++++++++++++++ 2 files changed, 61 insertions(+) create mode 100644 matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/widgets/RegisterWidgetResponse.kt create mode 100644 matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/widgets/WidgetsAPI.kt diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/widgets/RegisterWidgetResponse.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/widgets/RegisterWidgetResponse.kt new file mode 100644 index 0000000000..d84e36ce95 --- /dev/null +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/widgets/RegisterWidgetResponse.kt @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2020 New Vector Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package im.vector.matrix.android.internal.session.widgets + +import com.squareup.moshi.Json +import com.squareup.moshi.JsonClass + +@JsonClass(generateAdapter = true) +data class RegisterWidgetResponse( + @Json(name = "scalar_token") val scalarToken: String? +) diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/widgets/WidgetsAPI.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/widgets/WidgetsAPI.kt new file mode 100644 index 0000000000..9a90561414 --- /dev/null +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/widgets/WidgetsAPI.kt @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2020 New Vector Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package im.vector.matrix.android.internal.session.widgets + +import retrofit2.Call +import retrofit2.http.GET +import retrofit2.http.POST +import retrofit2.http.Query + +internal interface WidgetsAPI { + /** + * register to the server + * + * @param requestOpenIdTokenResponse the body content (Ref: https://github.com/matrix-org/matrix-doc/pull/1961) + */ + + //TODO Require work on RequestOpenIdTokenResponse from Benoit + @POST("register") + //fun register(@Body requestOpenIdTokenResponse: RequestOpenIdTokenResponse, @Query("v") version: String?): Call + + @GET("account") + fun validateToken(@Query("scalar_token") scalarToken: String?, @Query("v") version: String?): Call +} \ No newline at end of file