package Ġbe . sw sb . make ast ats . kotlin backend . pub g acl Ċ Ċ import Ġbe . sw sb . make ast ats . kotlin backend . pub g acl . model . Player Ċ import Ġbe . sw sb . make ast ats . kotlin backend . pub g acl . model . Pub g Api Wrapper Ċ import Ġcom . fasterxml . jackson . databind . ObjectMapper Ċ import Ġcom . fasterxml . jackson . module . kotlin . readValue Ċ import Ġcom . github . kit tin un f . fuel . Fuel Ċ import Ġcom . github . kit tin un f . fuel . core . Fuel Error Ċ import Ġcom . github . kit tin un f . fuel . core . Response Deserial izable Ċ import Ġcom . github . kit tin un f . fuel . rx . rx _ object Ċ import Ġcom . github . kit tin un f . result . Result Ċ import Ġio . reactivex . Single Ċ import Ġorg . springframework . stereotype . Service Ċ import Ġjava . io . Reader Ċ Ċ @ Service Ċ class ĠPlayer Service ( val Ġpub g Api Config : ĠPub g Api Config , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġval ĠobjectMapper : ĠObjectMapper ) Ġ{ ĊĊĠĠĠ Ġfun Ġfind Players By Names ( player Names : ĠList < String >? Ġ= Ġnull ): ĠSingle < Result < Pub g Api Wrapper < List < Player >>, ĠF uel Error >> Ġ{ ĊĠĠĠĠĠĠĠ Ġval ĠqueryParams : String Ġ= Ġplayer Name Query ( player Names ) ĊĠĠĠĠĠĠĠ Ġreturn ĠF uel . get ("${ pub g Api Config . baseUrl }/ players ${ queryParams }") ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. header ( map Of ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" Authorization " Ġto Ġ" Bearer : Ġ${ pub g Api Config . apiKey }", ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" Accept " Ġto Ġ" application / vnd . api + json " ĊĠĠĠĠĠĠĠ Ġ )). rx _ object ( Player Deserializer ( object Mapper )) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġplayer Name Query ( player Names : ĠList < String >? Ġ= Ġnull ): ĠString Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn Ġplayer Names ?. join ToString (", "," ? filter [ player Names ]=" ) Ġ?: Ġ"" ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġclass ĠPlayer Deserializer ( private Ġval ĠobjectMapper : ĠObjectMapper ): ĠResponse Deserial izable < Pub g Api Wrapper < List < Player >>> Ġ{ ĊĠĠĠĠĠĠĠ Ġoverride Ġfun Ġdeserialize ( reader : ĠReader ): ĠPub g Api Wrapper < List < Player >> Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġreturn ĠobjectMapper . readValue ( reader ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} Ċ }