mirror of
https://github.com/vector-im/element-android.git
synced 2024-11-16 02:05:06 +08:00
Data classes for the search response created.
This commit is contained in:
parent
5fcabca87c
commit
04b41fce30
@ -365,4 +365,7 @@ internal interface RoomAPI {
|
||||
fun deleteTag(@Path("userId") userId: String,
|
||||
@Path("roomId") roomId: String,
|
||||
@Path("tag") tag: String): Call<Unit>
|
||||
|
||||
@POST(NetworkConstants.URI_API_PREFIX_PATH_R0 + "search")
|
||||
fun search()
|
||||
}
|
||||
|
@ -15,13 +15,13 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.matrix.android.sdk.internal.session.room.search
|
||||
package org.matrix.android.sdk.internal.session.room.search.request
|
||||
|
||||
import com.squareup.moshi.Json
|
||||
import com.squareup.moshi.JsonClass
|
||||
|
||||
@JsonClass(generateAdapter = true)
|
||||
data class SearchBody(
|
||||
data class SearchRequestBody(
|
||||
@Json(name = "search_categories")
|
||||
val searchCategories: SearchCategories
|
||||
val searchCategories: SearchRequestCategories
|
||||
)
|
@ -15,14 +15,14 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.matrix.android.sdk.internal.session.room.search
|
||||
package org.matrix.android.sdk.internal.session.room.search.request
|
||||
|
||||
import com.squareup.moshi.Json
|
||||
import com.squareup.moshi.JsonClass
|
||||
|
||||
@JsonClass(generateAdapter = true)
|
||||
data class SearchCategories(
|
||||
data class SearchRequestCategories(
|
||||
// Mapping of category name to search criteria.
|
||||
@Json(name = "room_events")
|
||||
val roomEvents: RoomEvents? = null
|
||||
val roomEvents: SearchRequestRoomEvents? = null
|
||||
)
|
@ -15,13 +15,13 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.matrix.android.sdk.internal.session.room.search
|
||||
package org.matrix.android.sdk.internal.session.room.search.request
|
||||
|
||||
import com.squareup.moshi.Json
|
||||
import com.squareup.moshi.JsonClass
|
||||
|
||||
@JsonClass(generateAdapter = true)
|
||||
data class EventContext(
|
||||
data class SearchRequestEventContext(
|
||||
// How many events before the result are returned.
|
||||
@Json(name = "before_limit")
|
||||
val beforeLimit: Int? = null,
|
@ -15,13 +15,13 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.matrix.android.sdk.internal.session.room.search
|
||||
package org.matrix.android.sdk.internal.session.room.search.request
|
||||
|
||||
import com.squareup.moshi.Json
|
||||
import com.squareup.moshi.JsonClass
|
||||
|
||||
@JsonClass(generateAdapter = true)
|
||||
data class Filter(
|
||||
data class SearchRequestFilter(
|
||||
// The maximum number of events to return.
|
||||
@Json(name = "limit")
|
||||
val limit: Int? = null,
|
@ -15,7 +15,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.matrix.android.sdk.internal.session.room.search
|
||||
package org.matrix.android.sdk.internal.session.room.search.request
|
||||
|
||||
import com.squareup.moshi.JsonClass
|
||||
|
||||
@ -23,7 +23,7 @@ import com.squareup.moshi.JsonClass
|
||||
* Represents the order in which to search for results.
|
||||
*/
|
||||
@JsonClass(generateAdapter = false)
|
||||
enum class Order(val value: String) {
|
||||
enum class SearchRequestOrder(val value: String) {
|
||||
RANK("rank"),
|
||||
RECENT("recent")
|
||||
}
|
@ -15,22 +15,22 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.matrix.android.sdk.internal.session.room.search
|
||||
package org.matrix.android.sdk.internal.session.room.search.request
|
||||
|
||||
import com.squareup.moshi.Json
|
||||
import com.squareup.moshi.JsonClass
|
||||
|
||||
@JsonClass(generateAdapter = true)
|
||||
data class RoomEvents(
|
||||
data class SearchRequestRoomEvents(
|
||||
// Required. The string to search events for.
|
||||
@Json(name = "search_term")
|
||||
val searchTerm: String,
|
||||
@Json(name = "filter")
|
||||
val filter: Filter? = null,
|
||||
val filter: SearchRequestFilter? = null,
|
||||
// By default, this is "rank". One of: ["recent", "rank"]
|
||||
@Json(name = "order_by")
|
||||
val orderBy: Order? = null,
|
||||
val orderBy: SearchRequestOrder? = null,
|
||||
// Configures whether any context for the events returned are included in the response.
|
||||
@Json(name = "event_context")
|
||||
val eventContext: EventContext? = null
|
||||
val eventContext: SearchRequestEventContext? = null
|
||||
)
|
@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Copyright 2020 New Vector Ltd
|
||||
* Copyright 2020 The Matrix.org Foundation C.I.C.
|
||||
*
|
||||
* 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 org.matrix.android.sdk.internal.session.room.search.response
|
||||
|
||||
import com.squareup.moshi.Json
|
||||
import com.squareup.moshi.JsonClass
|
||||
|
||||
@JsonClass(generateAdapter = true)
|
||||
data class SearchResponse(
|
||||
// Required. Describes which categories to search in and their criteria.
|
||||
@Json(name = "search_categories")
|
||||
val searchCategories: SearchResponseCategories
|
||||
)
|
@ -0,0 +1,27 @@
|
||||
/*
|
||||
* Copyright 2020 New Vector Ltd
|
||||
* Copyright 2020 The Matrix.org Foundation C.I.C.
|
||||
*
|
||||
* 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 org.matrix.android.sdk.internal.session.room.search.response
|
||||
|
||||
import com.squareup.moshi.Json
|
||||
import com.squareup.moshi.JsonClass
|
||||
|
||||
@JsonClass(generateAdapter = true)
|
||||
data class SearchResponseCategories(
|
||||
@Json(name = "room_events")
|
||||
val roomEvents: SearchResponseRoomEvents? = null
|
||||
)
|
@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Copyright 2020 New Vector Ltd
|
||||
* Copyright 2020 The Matrix.org Foundation C.I.C.
|
||||
*
|
||||
* 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 org.matrix.android.sdk.internal.session.room.search.response
|
||||
|
||||
import com.squareup.moshi.Json
|
||||
import com.squareup.moshi.JsonClass
|
||||
import org.matrix.android.sdk.api.session.events.model.Event
|
||||
import org.matrix.android.sdk.api.util.JsonDict
|
||||
|
||||
@JsonClass(generateAdapter = true)
|
||||
data class SearchResponseEventContext(
|
||||
// Events just before the result.
|
||||
@Json(name = "events_before")
|
||||
val eventsBefore: List<Event>,
|
||||
// Events just after the result.
|
||||
@Json(name = "events_after")
|
||||
val eventsAfter: List<Event>,
|
||||
// Pagination token for the start of the chunk
|
||||
@Json(name = "start")
|
||||
val start: String? = null,
|
||||
// Pagination token for the end of the chunk
|
||||
@Json(name = "end")
|
||||
val end: String? = null,
|
||||
// The historic profile information of the users that sent the events returned. The string key is the user ID for which the profile belongs to.
|
||||
@Json(name = "profile_info")
|
||||
val profileInfo: JsonDict? = null
|
||||
)
|
@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Copyright 2020 New Vector Ltd
|
||||
* Copyright 2020 The Matrix.org Foundation C.I.C.
|
||||
*
|
||||
* 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 org.matrix.android.sdk.internal.session.room.search.response
|
||||
|
||||
import com.squareup.moshi.Json
|
||||
import com.squareup.moshi.JsonClass
|
||||
import org.matrix.android.sdk.api.session.events.model.Event
|
||||
|
||||
@JsonClass(generateAdapter = true)
|
||||
data class SearchResponseItem(
|
||||
// A number that describes how closely this result matches the search. Higher is closer.
|
||||
@Json(name = "rank")
|
||||
val rank: Int? = null,
|
||||
// The event that matched.
|
||||
@Json(name = "result")
|
||||
val event: Event
|
||||
)
|
@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Copyright 2020 New Vector Ltd
|
||||
* Copyright 2020 The Matrix.org Foundation C.I.C.
|
||||
*
|
||||
* 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 org.matrix.android.sdk.internal.session.room.search.response
|
||||
|
||||
import com.squareup.moshi.Json
|
||||
import com.squareup.moshi.JsonClass
|
||||
|
||||
@JsonClass(generateAdapter = true)
|
||||
class SearchResponseRoomEvents(
|
||||
// List of results in the requested order.
|
||||
@Json(name = "results")
|
||||
val results: List<SearchResponseItem>? = null,
|
||||
@Json(name = "count")
|
||||
val count: Int? = null,
|
||||
// List of words which should be highlighted, useful for stemming which may change the query terms.
|
||||
@Json(name = "highlights")
|
||||
val highlights: List<String>? = null
|
||||
)
|
Loading…
Reference in New Issue
Block a user