@@ -13,13 +13,12 @@ import io.circe.{ Decoder, Encoder }
1313import com .typesafe .scalalogging .StrictLogging
1414
1515import scala .concurrent .duration ._
16- import sttp .client3 ._
16+ import sttp .client4 ._
1717
18- import sttp .client3 .ResponseAs
18+ import sttp .client4 .ResponseAs
1919import sttp .model .MediaType
20- import sttp .client3 .BodySerializer
21- import sttp .client3 .StringBody
22- import sttp .client3 .{ Request => SttpRequest }
20+ import sttp .client4 .StringBody
21+ import sttp .client4 .{ Request => SttpRequest }
2322
2423/**
2524 * Sttp HTTP client.
@@ -28,17 +27,17 @@ import sttp.client3.{ Request => SttpRequest }
2827 * @param token Bot token
2928 */
3029class SttpClient [F [_]](token : String , telegramHost : String = " api.telegram.org" )(implicit
31- backend : SttpBackend [ F , Any ],
30+ backend : Backend [ F ],
3231 monadError : MonadError [F , Throwable ]
3332) extends RequestHandler [F ]()(using monadError)
3433 with StrictLogging {
3534
3635 val readTimeout : Duration = 50 .seconds
3736
38- private implicit def circeBodySerializer [B : Encoder ]: BodySerializer [ B ] =
39- b => StringBody (marshalling.toJson[B ](b), " utf-8" , MediaType .ApplicationJson )
37+ private def asJson [B : Encoder ]( b : B ) : StringBody =
38+ StringBody (marshalling.toJson[B ](b), " utf-8" , MediaType .ApplicationJson )
4039
41- private def asJson [B : Decoder ]: ResponseAs [B , Any ] =
40+ private def asJson [B : Decoder ]: ResponseAs [B ] =
4241 asStringAlways(" utf-8" ).map(s => marshalling.fromJson[B ](s))
4342
4443 private val apiBaseUrl = s " https:// $telegramHost/bot $token/ "
@@ -48,9 +47,9 @@ class SttpClient[F[_]](token: String, telegramHost: String = "api.telegram.org")
4847 )(implicit d : Decoder [request.Response ]): F [request.Response ] = {
4948 val url = apiBaseUrl + request.methodName
5049
51- val sttpRequest : Either [IllegalArgumentException , SttpRequest [String , Any ]] = request match {
50+ val sttpRequest : Either [IllegalArgumentException , SttpRequest [String ]] = request match {
5251 case r : JsonRequest =>
53- Right (quickRequest.post(uri " $url" ).body(request))
52+ Right (quickRequest.post(uri " $url" ).body(asJson( request) ))
5453
5554 case r : MultipartRequest =>
5655 val parts = r.getFiles.flatMap { case (camelKey, inputFile) =>
0 commit comments