package Ġde . ch rist ine co enen . code . z app . app . medi at he k . api Ċ Ċ import Ġde . ch rist ine co enen . code . z app . app . medi at he k . api . request . Query Request Ċ import Ġde . ch rist ine co enen . code . z app . models . shows . Med iat he k Show Ċ import Ġde . ch rist ine co enen . code . z app . utils . api . UserAgent Interceptor Ċ import Ġio . reactivex . Single Ċ import Ġio . reactivex . schedul ers . Schedulers Ċ import Ġokhttp 3 . Connection Spec Ċ import Ġokhttp 3 . Ok HttpClient Ċ import Ġokhttp 3 . Tls Version Ċ import Ġretrofit 2 . Ret rofit Ċ import Ġretrofit 2 . adapter . rx java 2 . Rx Java 2 Call Adapter Factory Ċ import Ġretrofit 2 . converter . gson . Gson Converter Factory Ċ import Ġretrofit 2 . http . Body ĊĊ Ċ class ĠMed iat he k Api Ġ{ ĊĊ ĉ private Ġval Ġapi Service : ĠMed iat he k ApiService ĊĊ ĉ init Ġ{ Ċĉ ĉ // Ġworkaround Ġto Ġavoid ĠSSL Handshake Exception Ġon ĠAndroid Ġ 7 Ġdevices Ċĉ ĉ // Ġsee : Ġhttps :// stackoverflow . com / questions / 3 9 1 3 3 4 3 7 / ssl handshake exception - handshake - failed - on - android - n - 7 - 0 Ċĉ ĉ val Ġspec : ĠConnection Spec Ġ= ĠConnection Spec . Builder ( Connection Spec . MO DER N _ TLS ) Ċĉĉ ĉ . tls Versions ( Tls Version . TLS _ 1 _ 1 , ĠT ls Version . TLS _ 1 _ 2 , ĠT ls Version . TLS _ 1 _ 3 ) Ċĉĉ ĉ . build () ĊĊĉ ĉ val Ġclient : ĠOk HttpClient Ġ= ĠOk HttpClient . Builder () Ċĉĉ ĉ . connection Specs ( listOf ( spec )) Ċĉĉ ĉ . add Interceptor ( UserAgent Interceptor ()) Ċĉĉ ĉ . build () ĊĊĉ ĉ val Ġretrofit Ġ= ĠRet rofit . Builder () Ċĉĉ ĉ . baseUrl (" https :// medi at he k view web . de / api /") Ċĉĉ ĉ . client ( client ) Ċĉĉ ĉ . add Converter Factory ( Gson Converter Factory . create ()) Ċĉĉ ĉ . add Call Adapter Factory ( Rx Java 2 Call Adapter Factory . create ()) Ċĉĉ ĉ . build () ĊĊĉ ĉ api Service Ġ= Ġretrofit . create ( Med iat he k ApiService :: class . java ) Ċ ĉ } ĊĊ ĉ fun Ġlist Shows (@ Body Ġquery Request : ĠQuery Request ): ĠSingle < List < Med iat he k Show >> Ġ{ Ċĉ ĉ return Ġapi Service Ċĉĉ ĉ . list Shows ( query Request ) Ċĉĉ ĉ . subscribe On ( Schedulers . io ()) Ċĉĉ ĉ . map Ġ{ Ċĉĉĉ ĉ if Ġ( it . result Ġ== Ġnull Ġ|| Ġit . err Ġ!= Ġnull ) Ġ{ Ċĉĉĉĉ ĉ throw ĠRuntimeException (" Empty Ġresult ") Ċĉĉĉ ĉ } Ċĉĉĉ ĉ it . result . results Ċĉĉ ĉ } Ċ ĉ } Ċ } Ċ