This reverts commit ee999bbe93
.
This commit is contained in:
parent
ee999bbe93
commit
12a91439e1
7 changed files with 4 additions and 78 deletions
|
@ -254,8 +254,6 @@ class Api {
|
|||
|
||||
fun sendMessage(subject: String, content: String, recipients: List<Recipient>) = messages.sendMessage(subject, content, recipients)
|
||||
|
||||
fun deleteMessages(messages: List<Pair<Int, Int>>) = this.messages.deleteMessages(messages)
|
||||
|
||||
fun getTimetable(startDate: LocalDate, endDate: LocalDate? = null) =
|
||||
if (useNewStudent) student.getTimetable(startDate, endDate) else snp.getTimetable(startDate, endDate)
|
||||
|
||||
|
|
|
@ -1,13 +0,0 @@
|
|||
package io.github.wulkanowy.api.messages
|
||||
|
||||
import com.google.gson.annotations.SerializedName
|
||||
|
||||
data class DeleteMessageRequest(
|
||||
|
||||
@SerializedName("Id")
|
||||
val messageId: Int,
|
||||
|
||||
@SerializedName("Folder")
|
||||
val folderId: Int
|
||||
|
||||
)
|
|
@ -1,7 +1,6 @@
|
|||
package io.github.wulkanowy.api.repository
|
||||
|
||||
import io.github.wulkanowy.api.getScriptParam
|
||||
import io.github.wulkanowy.api.messages.DeleteMessageRequest
|
||||
import io.github.wulkanowy.api.messages.Message
|
||||
import io.github.wulkanowy.api.messages.Recipient
|
||||
import io.github.wulkanowy.api.messages.ReportingUnit
|
||||
|
@ -88,22 +87,6 @@ class MessagesRepository(private val api: MessagesService) {
|
|||
}
|
||||
}
|
||||
|
||||
fun deleteMessages(messages: List<Pair<Int, Int>>): Single<Boolean> {
|
||||
return api.getStart().flatMap { res ->
|
||||
api.deleteMessage(
|
||||
messages.map { (messageId, folderId) ->
|
||||
DeleteMessageRequest(
|
||||
messageId = messageId,
|
||||
folderId = folderId
|
||||
)
|
||||
},
|
||||
getScriptParam("antiForgeryToken", res),
|
||||
getScriptParam("appGuid", res),
|
||||
getScriptParam("version", res)
|
||||
).map { it.success }
|
||||
}
|
||||
}
|
||||
|
||||
private fun String.normalizeRecipient(): String {
|
||||
return this.substringBeforeLast("-").substringBefore(" [").substringBeforeLast(" (").trim()
|
||||
}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package io.github.wulkanowy.api.service
|
||||
|
||||
import io.github.wulkanowy.api.ApiResponse
|
||||
import io.github.wulkanowy.api.messages.DeleteMessageRequest
|
||||
import io.github.wulkanowy.api.messages.Message
|
||||
import io.github.wulkanowy.api.messages.Recipient
|
||||
import io.github.wulkanowy.api.messages.ReportingUnit
|
||||
|
@ -58,12 +57,4 @@ interface MessagesService {
|
|||
@Header("X-V-AppGuid") appGuid: String,
|
||||
@Header("X-V-AppVersion") appVersion: String
|
||||
): Single<ApiResponse<SentMessage>>
|
||||
|
||||
@POST("Wiadomosc.mvc/UsunWiadomosc")
|
||||
fun deleteMessage(
|
||||
@Body deleteMessageRequests: List<DeleteMessageRequest>,
|
||||
@Header("X-V-RequestVerificationToken") token: String,
|
||||
@Header("X-V-AppGuid") appGuid: String,
|
||||
@Header("X-V-AppVersion") appVersion: String
|
||||
): Single<ApiResponse<Nothing>>
|
||||
}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package io.github.wulkanowy.api
|
||||
|
||||
import com.google.gson.GsonBuilder
|
||||
import com.google.gson.JsonParser
|
||||
import io.github.wulkanowy.api.grades.DateDeserializer
|
||||
import io.github.wulkanowy.api.grades.GradeDate
|
||||
import io.github.wulkanowy.api.interceptor.ErrorInterceptor
|
||||
|
@ -24,7 +23,6 @@ import retrofit2.converter.scalars.ScalarsConverterFactory
|
|||
abstract class BaseLocalTest : BaseTest() {
|
||||
|
||||
val server = MockWebServer()
|
||||
val jsonParser = JsonParser()
|
||||
|
||||
@After
|
||||
fun tearDown() {
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package io.github.wulkanowy.api.messages
|
||||
|
||||
import com.google.gson.JsonParser
|
||||
import io.github.wulkanowy.api.BaseLocalTest
|
||||
import io.github.wulkanowy.api.repository.MessagesRepository
|
||||
import io.github.wulkanowy.api.service.MessagesService
|
||||
|
@ -156,32 +157,10 @@ class MessagesTest : BaseLocalTest() {
|
|||
|
||||
server.takeRequest()
|
||||
|
||||
val expected = jsonParser.parse(MessagesTest::class.java.getResource("NowaWiadomosc.json").readText())
|
||||
val parser = JsonParser()
|
||||
val expected = parser.parse(MessagesTest::class.java.getResource("NowaWiadomosc.json").readText())
|
||||
val request = server.takeRequest()
|
||||
val actual = jsonParser.parse(request.body.readUtf8())
|
||||
|
||||
assertEquals(expected, actual)
|
||||
assertEquals(
|
||||
"lX9xvk-OBA0VmHrNIFcQp2xVBZhza9tJ1QbYVKXGM3lFUr0a-OTDo5xUSQ70ROYKf6ICZ1LSXCfDAURoCmDZ-OEedW8IKtyF1s63HyWKxbmHaP-vsVCsGlN6zRHwx1r4h",
|
||||
request.getHeader("X-V-RequestVerificationToken")
|
||||
)
|
||||
assertEquals("877c4a726ad61667f4e2237f0cf6307a", request.getHeader("X-V-AppGuid"))
|
||||
assertEquals("19.02.0001.32324", request.getHeader("X-V-AppVersion"))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun deleteMessageTest() {
|
||||
server.enqueue(MockResponse().setBody(MessagesTest::class.java.getResource("Start.html").readText()))
|
||||
server.enqueue(MockResponse().setBody("{\"success\": true}"))
|
||||
server.start(3000)
|
||||
|
||||
assertEquals(api.deleteMessages(listOf(Pair(74, 1), Pair(69, 2))).blockingGet(), true)
|
||||
|
||||
server.takeRequest()
|
||||
|
||||
val expected = jsonParser.parse(MessagesTest::class.java.getResource("UsunWiadomosc.json").readText())
|
||||
val request = server.takeRequest()
|
||||
val actual = jsonParser.parse(request.body.readUtf8())
|
||||
val actual = parser.parse(request.body.readUtf8())
|
||||
|
||||
assertEquals(expected, actual)
|
||||
assertEquals(
|
||||
|
|
|
@ -1,10 +0,0 @@
|
|||
[
|
||||
{
|
||||
"Id": 74,
|
||||
"Folder": 1
|
||||
},
|
||||
{
|
||||
"Id": 69,
|
||||
"Folder": 2
|
||||
}
|
||||
]
|
Loading…
Reference in a new issue