-
Notifications
You must be signed in to change notification settings - Fork 183
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace ktorfit in remote controls (#905)
**Background** Ktorfit updates sometimes causes difficulties to update it. This PR replace ktorfit inside remote-controls module with raw ktor **Changes** - Remote ktorfit from remote-controls **Test plan** - Launch app - Open remote controls screen - Follow full userflow of this feature
- Loading branch information
1 parent
34e5d78
commit 26c8e34
Showing
6 changed files
with
80 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
...nd/src/commonMain/kotlin/com/flipperdevices/ifrmvp/api/infrared/InfraredBackendApiImpl.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
package com.flipperdevices.ifrmvp.api.infrared | ||
|
||
import com.flipperdevices.core.di.AppGraph | ||
import com.flipperdevices.ifrmvp.api.infrared.model.InfraredHost | ||
import com.flipperdevices.ifrmvp.backend.model.BrandsResponse | ||
import com.flipperdevices.ifrmvp.backend.model.CategoriesResponse | ||
import com.flipperdevices.ifrmvp.backend.model.IfrFileContentResponse | ||
import com.flipperdevices.ifrmvp.backend.model.PagesLayoutBackendModel | ||
import com.flipperdevices.ifrmvp.backend.model.SignalRequestModel | ||
import com.flipperdevices.ifrmvp.backend.model.SignalResponseModel | ||
import com.squareup.anvil.annotations.ContributesBinding | ||
import io.ktor.client.HttpClient | ||
import io.ktor.client.call.body | ||
import io.ktor.client.request.get | ||
import io.ktor.client.request.parameter | ||
import io.ktor.client.request.post | ||
import io.ktor.client.request.setBody | ||
import io.ktor.client.request.url | ||
import io.ktor.http.ContentType | ||
import io.ktor.http.contentType | ||
import javax.inject.Inject | ||
|
||
@ContributesBinding(AppGraph::class, InfraredBackendApi::class) | ||
class InfraredBackendApiImpl( | ||
private val httpClient: HttpClient, | ||
private val host: InfraredHost = InfraredHost.DEV | ||
) : InfraredBackendApi { | ||
@Inject | ||
constructor(httpClient: HttpClient) : this(httpClient, InfraredHost.DEV) | ||
|
||
override suspend fun getCategories(): CategoriesResponse { | ||
return httpClient.get { | ||
url("${host.url}/categories") | ||
contentType(ContentType.Application.Json) | ||
}.body() | ||
} | ||
|
||
override suspend fun getManufacturers(categoryId: Long): BrandsResponse { | ||
return httpClient.get { | ||
url("${host.url}/brands") | ||
parameter("category_id", categoryId) | ||
contentType(ContentType.Application.Json) | ||
}.body() | ||
} | ||
|
||
override suspend fun getSignal(request: SignalRequestModel): SignalResponseModel { | ||
return httpClient.post { | ||
url("${host.url}/signal") | ||
contentType(ContentType.Application.Json) | ||
setBody(request) | ||
}.body() | ||
} | ||
|
||
override suspend fun getIfrFileContent(ifrFileId: Long): IfrFileContentResponse { | ||
return httpClient.get { | ||
url("${host.url}/key") | ||
parameter("ifr_file_id", ifrFileId) | ||
contentType(ContentType.Application.Json) | ||
}.body() | ||
} | ||
|
||
override suspend fun getUiFile(ifrFileId: Long): PagesLayoutBackendModel { | ||
return httpClient.get { | ||
url("${host.url}/ui") | ||
parameter("ifr_file_id", ifrFileId) | ||
contentType(ContentType.Application.Json) | ||
}.body() | ||
} | ||
} |
41 changes: 0 additions & 41 deletions
41
.../src/commonMain/kotlin/com/flipperdevices/ifrmvp/api/infrared/di/InfraredKtorfitModule.kt
This file was deleted.
Oops, something went wrong.
6 changes: 6 additions & 0 deletions
6
...ackend/src/commonMain/kotlin/com/flipperdevices/ifrmvp/api/infrared/model/InfraredHost.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package com.flipperdevices.ifrmvp.api.infrared.model | ||
|
||
enum class InfraredHost(val url: String) { | ||
DEV("https://infrared.dev.flipp.dev/"), | ||
PROD("https://infrared.flipperzero.one/") | ||
} |