package Ġcom . corn ell app dev . android . pol lo . networking Ċ Ċ import Ġcom . corn ell app dev . android . pol lo . models . User Ċ import Ġokhttp 3 . MediaType Ċ import Ġokhttp 3 . RequestBody Ċ import Ġorg . json . JSONArray Ċ import Ġorg . json . JSONException Ċ import Ġorg . json . JSONObject Ċ Ċ fun ĠEndpoint . Companion . join Group With Code ( code : ĠString ): ĠEndpoint Ġ{ ĊĠĠĠ Ġval Ġcode JSON Ġ= ĠJSONObject () ĊĠĠĠ Ġcode JSON . put (" code ", Ġcode ) ĊĠĠĠ Ġval Ġrequest Body Ġ= ĠRequest Body . create ( MediaType . get (" application / json ; Ġcharset = utf - 8 "), Ġcode JSON . toString ()) ĊĠĠĠ Ġreturn ĠEndpoint ( path Ġ= Ġ"/ join / session ", Ġheaders Ġ= Ġmap Of (" Authorization " Ġto Ġ" Bearer Ġ" Ġ+ ĠUser . current Session . accessToken ), Ġbody Ġ= Ġrequest Body , Ġmethod Ġ= ĠEndpoint Method . POST ) Ċ } Ċ Ċ fun ĠEndpoint . Companion . getAll Groups ( role : ĠString ): ĠEndpoint Ġ{ ĊĠĠĠ Ġreturn ĠEndpoint ("/ sessions / all /$ role ", Ġheaders Ġ= Ġmap Of (" Authorization " Ġto Ġ" Bearer Ġ" Ġ+ ĠUser . current Session . accessToken ), Ġmethod Ġ= ĠEndpoint Method . GET ) Ċ } Ċ Ċ fun ĠEndpoint . Companion . leave Group ( id : ĠString ): ĠEndpoint Ġ{ ĊĠĠĠ Ġreturn ĠEndpoint ("/ sessions /$ id / members ", Ġheaders Ġ= Ġmap Of (" Authorization " Ġto Ġ" Bearer Ġ${ User . current Session . accessToken } "), Ġmethod Ġ= ĠEndpoint Method . DELETE ) Ċ } Ċ Ċ fun ĠEndpoint . Companion . delete Group ( id : ĠString ): ĠEndpoint Ġ{ ĊĠĠĠ Ġreturn ĠEndpoint ("/ sessions /$ id ", Ġheaders Ġ= Ġmap Of (" Authorization " Ġto Ġ" Bearer Ġ${ User . current Session . accessToken } "), Ġmethod Ġ= ĠEndpoint Method . DELETE ) Ċ } Ċ Ċ fun ĠEndpoint . Companion . rename Group ( id : ĠString , Ġname : ĠString ): ĠEndpoint Ġ{ ĊĠĠĠ Ġval Ġname JSON Ġ= ĠJSONObject () ĊĠĠĠ Ġname JSON . put (" name ", Ġname ) ĊĠĠĠ Ġval Ġrequest Body Ġ= ĠRequest Body . create ( MediaType . get (" application / json ; Ġcharset = utf - 8 "), Ġname JSON . toString ()) ĊĠĠĠ Ġreturn ĠEndpoint ("/ sessions /$ id ", Ġheaders Ġ= Ġmap Of (" Authorization " Ġto Ġ" Bearer Ġ${ User . current Session . accessToken } "), Ġbody Ġ= Ġrequest Body , Ġmethod Ġ= ĠEndpoint Method . PUT ) Ċ } Ċ Ċ fun ĠEndpoint . Companion . start Session ( code : ĠString , Ġname : ĠString ) Ġ: ĠEndpoint Ġ{ ĊĠĠĠ Ġval Ġcode JSON Ġ= ĠJSONObject () ĊĠĠĠ Ġcode JSON . put (" code ", Ġcode ) ĊĠĠĠ Ġcode JSON . put (" name ", Ġname ) ĊĠĠĠ Ġval Ġrequest Body Ġ= ĠRequest Body . create ( MediaType . get (" application / json ; Ġcharset = utf - 8 "), Ġcode JSON . toString ()) ĊĊĠĠĠ Ġreturn ĠEndpoint ("/ start / session /", Ġheaders Ġ= Ġmap Of (" Authorization " Ġto Ġ" Bearer Ġ${ User . current Session . accessToken } "), Ġbody Ġ= Ġrequest Body , Ġmethod Ġ= ĠEndpoint Method . POST ) Ċ } Ċ Ċ fun ĠEndpoint . Companion . generate Code () Ġ: ĠEndpoint Ġ{ ĊĠĠĠ Ġreturn ĠEndpoint ("/ generate / code /", Ġheaders Ġ= Ġmap Of (" Authorization " Ġto Ġ" Bearer Ġ${ User . current Session . accessToken } "), Ġmethod Ġ= ĠEndpoint Method . GET ) Ċ }