package Ġcom . equ alex perts . slack . api . con versations Ċ Ċ import Ġcom . equ alex perts . slack . api . con versations . model . Conversation Ċ import Ġcom . equ alex perts . slack . api . con versations . model . Conversation History Ċ import Ġcom . equ alex perts . slack . api . con versations . model . Conversation List Ċ import Ġcom . equ alex perts . slack . api . con versations . model . Conversation Members Ċ import Ġcom . equ alex perts . slack . api . rest . Slack Retry Support Ċ import Ġcom . equ alex perts . slack . api . rest . Slack Retry Support . Slack Error Decoder Ċ import Ġcom . equ alex perts . slack . api . rest . fe ign Builder Ċ import Ġcom . equ alex perts . slack . api . rest . model . Message Ċ import Ġcom . equ alex perts . slack . api . rest . model . Timestamp Ċ import Ġcom . equ alex perts . slack . api . users . model . User Ċ import Ġfe ign . Param Ċ import Ġfe ign . Request Line Ċ import Ġorg . slf 4 j . LoggerFactory Ċ import Ġjava . net . URI Ċ Ċ fun ĠCon versations Slack Api . list All (): ĠSet < Conversation > Ġ{ ĊĠĠĠ Ġval Ġlogger Ġ= ĠLoggerFactory . getLogger ( this :: class . java . name ) ĊĊĠĠĠ Ġlogger . info (" Retrie ving ĠChannels ") ĊĊĠĠĠ Ġval Ġchannels Ġ= Ġmutable Set Of < Conversation >() ĊĊĠĠĠ Ġvar Ġmore Channels ToList : ĠBoolean ĊĠĠĠ Ġvar Ġcursor Value Ġ= Ġ"" ĊĠĠĠ Ġdo Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġchannel List Ġ= Ġlist ( cursor Value ) ĊĠĠĠĠĠĠĠ Ġval Ġnext Cursor Ġ= Ġchannel List . response _ metadata . next _ cursor ĊĊĠĠĠĠĠĠĠ Ġlogger . debug (" Channels Ġfound , Ġadding Ġto Ġlist Ġ${ channel List . channels }") ĊĠĠĠĠĠĠĠ Ġchannels Ġ+= Ġchannel List . channels ĊĊĠĠĠĠĠĠĠ Ġif Ġ(! next Cursor . isBlank ()) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġlogger . debug (" Found Ġnew Ġcursor Ġtoken Ġto Ġretrieve Ġmore Ġchannels Ġfrom , Ġusing Ġcursor Ġtoken Ġ$ next Cursor ") ĊĠĠĠĠĠĠĠĠĠĠĠ Ġmore Channels ToList Ġ= Ġtrue ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcursor Value Ġ= Ġnext Cursor ĊĊĠĠĠĠĠĠĠ Ġ} Ġelse Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġlogger . debug (" No Ġnew Ġcursor Ġtoken , Ġall Ġchannels Ġfound ") ĊĠĠĠĠĠĠĠĠĠĠĠ Ġmore Channels ToList Ġ= Ġfalse ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠ Ġ} Ġwhile Ġ( more Channels ToList ) ĊĠĠĠ Ġlogger . info ("${ channels . size } Ġchannels Ġfound ") ĊĠĠĠ Ġreturn Ġchannels Ċ } ĊĊ Ċ fun ĠCon versations Slack Api . getFull Conversation History ( conversation Id : ĠString ): ĠList < Message > Ġ{ ĊĠĠĠ Ġval Ġlogger Ġ= ĠLoggerFactory . getLogger ( this :: class . java . name ) ĊĊĠĠĠ Ġlogger . info (" Retrie ving ĠMessages ") ĊĊĠĠĠ Ġval Ġmessages Ġ= Ġmutable ListOf < Message >() ĊĊĠĠĠ Ġvar Ġmore Messages To Get : ĠBoolean ĊĠĠĠ Ġvar Ġcursor Value Ġ= Ġ"" ĊĠĠĠ Ġdo Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġconversation History Ġ= Ġchannel History ( conversation Id , Ġcursor Value ) ĊĠĠĠĠĠĠĠ Ġval Ġnext Cursor Ġ= Ġconversation History . response _ metadata ?. next _ cursor ĊĊĠĠĠĠĠĠĠ Ġlogger . debug (" Messages Ġfound , Ġadding Ġto Ġlist Ġ${ conversation History . messages }") ĊĠĠĠĠĠĠĠ Ġmessages Ġ+= Ġconversation History . messages ĊĊĠĠĠĠĠĠĠ Ġval Ġnext Cursor Present Ġ= Ġnext Cursor ?. let Ġ{ Ġ! it . isBlank () Ġ} Ġ?: Ġfalse ĊĠĠĠĠĠĠĠ Ġif Ġ( next Cursor Present ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġlogger . debug (" Found Ġnew Ġcursor Ġtoken Ġto Ġretrieve Ġmore Ġmessages Ġfrom , Ġusing Ġcursor Ġtoken Ġ$ next Cursor ") ĊĠĠĠĠĠĠĠĠĠĠĠ Ġmore Messages To Get Ġ= Ġtrue ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcursor Value Ġ= Ġnext Cursor !! ĊĊĠĠĠĠĠĠĠ Ġ} Ġelse Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġlogger . debug (" No Ġnew Ġcursor Ġtoken , Ġall Ġmessages Ġfound ") ĊĠĠĠĠĠĠĠĠĠĠĠ Ġmore Messages To Get Ġ= Ġfalse ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠ Ġ} Ġwhile Ġ( more Messages To Get ) ĊĠĠĠ Ġlogger . info ("${ messages . size } Ġmessages Ġfound ") ĊĠĠĠ Ġreturn Ġmessages Ċ } Ċ Ċ interface ĠCon versations Slack Api Ġ{ ĊĠĠĠ Ġ@ Request Line (" GET Ġ/ api / con versations . list ? exclude _ arch ived = true & exclude _ members = true & cursor ={ cursor Value }") ĊĠĠĠ Ġfun Ġlist (@ Param (" cursor Value ") Ġcursor Value : ĠString Ġ= Ġ"") : ĠCon versation List ĊĊĠĠĠ Ġ@ Request Line (" GET Ġ/ api / con versations . members ? channel ={ channel }& limit = 1 0 0 0 & cursor ={ cursor Value }") ĊĠĠĠ Ġfun Ġmembers (@ Param (" channel ", Ġexpand er Ġ= ĠCon versation . Channel Id Expand er :: class ) Ġchannel : ĠCon versation , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ@ Param (" cursor Value ") Ġcursor Value : ĠString Ġ= Ġ"") : ĠCon versation Members ĊĊĠĠĠ Ġ@ Request Line (" GET Ġ/ api / con versations . archive ? channel ={ channel }") ĊĠĠĠ Ġfun Ġchannels Archive ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ@ Param (" channel ", Ġexpand er Ġ= ĠCon versation . Channel Id Expand er :: class ) Ġchannel : ĠCon versation ĊĠĠĠ Ġ) ĊĊĠĠĠ Ġ@ Request Line (" GET Ġ/ api / con versations . history ? channel ={ channel }& ol dest ={ ol dest }& latest ={ latest }& inclusive = true ") ĊĠĠĠ Ġfun Ġchannel History ( ĊĠĠĠĠĠĠĠ Ġ@ Param (" channel ", Ġexpand er Ġ= ĠCon versation . Channel Id Expand er :: class ) Ġchannel : ĠCon versation , ĊĠĠĠĠĠĠĠ Ġ@ Param (" ol dest ") Ġoldest : ĠTimestamp , ĊĠĠĠĠĠĠĠ Ġ@ Param (" latest ") Ġlatest : ĠTimestamp ĊĠĠĠ Ġ): ĠCon versation History ĊĊĠĠĠ Ġ@ Request Line (" GET Ġ/ api / con versations . history ? channel ={ channel }& cursor ={ cursor Value }& count = 2 0 0 ") ĊĠĠĠ Ġfun Ġchannel History ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ@ Param (" channel ") Ġchannel : ĠString , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ@ Param (" cursor Value ") Ġcursor Value : ĠString Ġ= Ġ"" ĊĠĠĠ Ġ): ĠCon versation History ĊĊĠĠĠ Ġ@ Request Line (" GET Ġ/ api / con versations . open ? users ={ user }") ĊĠĠĠ Ġfun Ġconversation Open (@ Param (" user ", Ġexpand er Ġ= ĠUser . UserId Expand er :: class ) Ġuser : ĠUser ): ĠOpen Conversation Response ĊĊĠĠĠ Ġ@ Request Line (" GET Ġ/ api / con versations . rename ? channel ={ channel }& name ={ name }") ĊĠĠĠ Ġfun Ġchannel Rename ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ@ Param (" channel ", Ġexpand er Ġ= ĠCon versation . Channel Id Expand er :: class ) Ġchannel : ĠCon versation , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ@ Param (" name ") Ġname : ĠString ĊĠĠĠ Ġ) ĊĊĠĠĠ Ġ@ Request Line (" GET Ġ/ api / con versations . invite ? channel ={ channel }& users ={ users }") ĊĠĠĠ Ġfun Ġinvite (@ Param (" channel ") Ġchannel : ĠString , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ@ Param (" users ") Ġusers : ĠList < String >) ĊĊĠĠĠ Ġcompanion Ġobject Ġ{ ĊĊĠĠĠĠĠĠĠ Ġfun Ġfactory ( uri : ĠURI , Ġtoken : ĠString , Ġsle eper : Ġ( Long ) Ġ-> ĠUnit ): ĠCon versations Slack Api Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġreturn Ġfe ign Builder () ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. request Interceptor Ġ{ Ġit . header (" Authorization ", Ġ" Bearer Ġ$ token ") Ġ} ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. error Decoder ( Slack Error Decoder ()) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. retry er ( Slack Retry Support ( sle eper )) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. target ( Con versations Slack Api :: class . java , Ġuri . toString ()) ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠ Ġ} Ċ } Ċ Ċ data Ġclass ĠOpen Conversation Response ( val Ġchannel : ĠChannel Id ) Ċ Ċ data Ġclass ĠChannel Id ( val Ġid : ĠString ) Ċ