@@ -781,6 +781,76 @@ extension WebAPI {
781781 failure ? ( error)
782782 }
783783 }
784+
785+ public func getReactionsForFile( _ file: String , full: Bool = true , reactions: ( ( [ Reaction ] ) -> Void ) ? , failure: FailureClosure ? ) {
786+ getReactionsForItem ( file, full: full, itemKey: " file " , reactions: reactions, failure: failure)
787+ }
788+
789+ public func getReactionsForComment( _ comment: String , full: Bool = true , reactions: ( ( [ Reaction ] ) -> Void ) ? , failure: FailureClosure ? ) {
790+ getReactionsForItem ( comment: comment, full: full, itemKey: " file " , reactions: reactions, failure: failure)
791+ }
792+
793+ public func getReactionsForMessage(
794+ _ channel: String ,
795+ timestamp: String ,
796+ full: Bool = true ,
797+ reactions: ( ( [ Reaction ] ) -> Void ) ? ,
798+ failure: FailureClosure ?
799+ ) {
800+ getReactionsForItem ( channel: channel, timestamp: timestamp, full: full, itemKey: " message " , reactions: reactions, failure: failure)
801+ }
802+
803+ private func getReactionsForItem(
804+ _ file: String ? = nil ,
805+ comment: String ? = nil ,
806+ channel: String ? = nil ,
807+ timestamp: String ? = nil ,
808+ full: Bool ,
809+ itemKey: String ,
810+ reactions: ( ( [ Reaction ] ) -> Void ) ? ,
811+ failure: FailureClosure ?
812+ ) {
813+ let parameters : [ String : Any ? ] = [
814+ " token " : token,
815+ " file " : file,
816+ " file_comment " : comment,
817+ " channel " : channel,
818+ " timestamp " : timestamp,
819+ " full " : full
820+ ]
821+ networkInterface. request ( . reactionsGet, parameters: parameters, successClosure: { ( response) in
822+ guard let item = response [ itemKey] as? [ [ String : Any ] ] else {
823+ reactions ? ( [ ] )
824+ return
825+ }
826+ reactions ? ( item. map ( { Reaction ( reaction: $0) } ) )
827+ } ) { ( error) in
828+ failure ? ( error)
829+ }
830+ }
831+
832+ public func reactionsListForUser(
833+ _ user: String ? = nil ,
834+ full: Bool = true ,
835+ count: Int = 100 ,
836+ page: Int = 1 ,
837+ success: ( ( _ items: [ Item ] ? ) -> Void ) ? ,
838+ failure: FailureClosure ?
839+ ) {
840+ let parameters : [ String : Any ? ] = [
841+ " token " : token,
842+ " user " : user,
843+ " full " : full,
844+ " count " : count,
845+ " page " : page
846+ ]
847+ networkInterface. request ( . reactionsList, parameters: parameters, successClosure: { ( response) in
848+ let items = response [ " items " ] as? [ [ String : Any ] ]
849+ success ? ( items? . map ( { Item ( item: $0) } ) )
850+ } ) { ( error) in
851+ failure ? ( error)
852+ }
853+ }
784854}
785855
786856// MARK: - Stars
0 commit comments