module MSGraphAPI.Users.Group (
listUserJoinedTeams
, listMeJoinedTeams
, listUserAssociatedTeams
, listMeAssociatedTeams
, listTeamChannels
, listChannelMessages
, getChannelMessage
, listMessageReplies
, listGroupsDriveItems
, Group(..)
, Channel(..)
, ChatMessage(..)
, ChatMessageBody(..)
)where
import GHC.Generics (Generic(..))
import qualified Data.Aeson as A (ToJSON(..), FromJSON(..), genericParseJSON)
import Network.OAuth.OAuth2.Internal (AccessToken(..))
import Network.HTTP.Req (Req)
import Data.Text (Text, unpack)
import Data.Time (ZonedTime)
import qualified MSGraphAPI.Internal.Common as MSG (Collection(..), get, aesonOptions)
import MSGraphAPI.Files.DriveItem (DriveItem)
data Group = Group {
Group -> Text
gId :: Text
, Group -> Text
gDisplayName :: Text
, Group -> Text
gDescription :: Text
} deriving (Group -> Group -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Group -> Group -> Bool
$c/= :: Group -> Group -> Bool
== :: Group -> Group -> Bool
$c== :: Group -> Group -> Bool
Eq, Eq Group
Group -> Group -> Bool
Group -> Group -> Ordering
Group -> Group -> Group
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: Group -> Group -> Group
$cmin :: Group -> Group -> Group
max :: Group -> Group -> Group
$cmax :: Group -> Group -> Group
>= :: Group -> Group -> Bool
$c>= :: Group -> Group -> Bool
> :: Group -> Group -> Bool
$c> :: Group -> Group -> Bool
<= :: Group -> Group -> Bool
$c<= :: Group -> Group -> Bool
< :: Group -> Group -> Bool
$c< :: Group -> Group -> Bool
compare :: Group -> Group -> Ordering
$ccompare :: Group -> Group -> Ordering
Ord, Int -> Group -> ShowS
[Group] -> ShowS
Group -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Group] -> ShowS
$cshowList :: [Group] -> ShowS
show :: Group -> String
$cshow :: Group -> String
showsPrec :: Int -> Group -> ShowS
$cshowsPrec :: Int -> Group -> ShowS
Show, forall x. Rep Group x -> Group
forall x. Group -> Rep Group x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Group x -> Group
$cfrom :: forall x. Group -> Rep Group x
Generic)
instance A.FromJSON Group where
parseJSON :: Value -> Parser Group
parseJSON = forall a.
(Generic a, GFromJSON Zero (Rep a)) =>
Options -> Value -> Parser a
A.genericParseJSON (String -> Options
MSG.aesonOptions String
"g")
instance A.ToJSON Group
data Channel = Channel {
Channel -> Text
chId :: Text
, Channel -> Text
chDisplayName :: Text
, Channel -> Text
chDescription :: Text
} deriving (Channel -> Channel -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Channel -> Channel -> Bool
$c/= :: Channel -> Channel -> Bool
== :: Channel -> Channel -> Bool
$c== :: Channel -> Channel -> Bool
Eq, Eq Channel
Channel -> Channel -> Bool
Channel -> Channel -> Ordering
Channel -> Channel -> Channel
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: Channel -> Channel -> Channel
$cmin :: Channel -> Channel -> Channel
max :: Channel -> Channel -> Channel
$cmax :: Channel -> Channel -> Channel
>= :: Channel -> Channel -> Bool
$c>= :: Channel -> Channel -> Bool
> :: Channel -> Channel -> Bool
$c> :: Channel -> Channel -> Bool
<= :: Channel -> Channel -> Bool
$c<= :: Channel -> Channel -> Bool
< :: Channel -> Channel -> Bool
$c< :: Channel -> Channel -> Bool
compare :: Channel -> Channel -> Ordering
$ccompare :: Channel -> Channel -> Ordering
Ord, Int -> Channel -> ShowS
[Channel] -> ShowS
Channel -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Channel] -> ShowS
$cshowList :: [Channel] -> ShowS
show :: Channel -> String
$cshow :: Channel -> String
showsPrec :: Int -> Channel -> ShowS
$cshowsPrec :: Int -> Channel -> ShowS
Show, forall x. Rep Channel x -> Channel
forall x. Channel -> Rep Channel x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Channel x -> Channel
$cfrom :: forall x. Channel -> Rep Channel x
Generic)
instance A.FromJSON Channel where
parseJSON :: Value -> Parser Channel
parseJSON = forall a.
(Generic a, GFromJSON Zero (Rep a)) =>
Options -> Value -> Parser a
A.genericParseJSON (String -> Options
MSG.aesonOptions String
"ch")
instance A.ToJSON Channel
listTeamChannels :: Text
-> AccessToken -> Req (MSG.Collection Channel)
listTeamChannels :: Text -> AccessToken -> Req (Collection Channel)
listTeamChannels Text
tid = forall a.
FromJSON a =>
[Text] -> Option 'Https -> AccessToken -> Req a
MSG.get [Text
"teams", Text
tid, Text
"allChannels"] forall a. Monoid a => a
mempty
listChannelMessages ::
Text
-> Text
-> AccessToken -> Req (MSG.Collection ChatMessage)
listChannelMessages :: Text -> Text -> AccessToken -> Req (Collection ChatMessage)
listChannelMessages Text
tid Text
chid =
forall a.
FromJSON a =>
[Text] -> Option 'Https -> AccessToken -> Req a
MSG.get [Text
"teams", Text
tid, Text
"channels", Text
chid, Text
"messages"] forall a. Monoid a => a
mempty
getChannelMessage :: Text
-> Text
-> Text
-> AccessToken -> Req ChatMessage
getChannelMessage :: Text -> Text -> Text -> AccessToken -> Req ChatMessage
getChannelMessage Text
tid Text
chid Text
mid =
forall a.
FromJSON a =>
[Text] -> Option 'Https -> AccessToken -> Req a
MSG.get [Text
"teams", Text
tid, Text
"channels", Text
chid, Text
"messages", Text
mid] forall a. Monoid a => a
mempty
listMessageReplies ::
Text
-> Text
-> Text
-> AccessToken -> Req (MSG.Collection ChatMessage)
listMessageReplies :: Text -> Text -> Text -> AccessToken -> Req (Collection ChatMessage)
listMessageReplies Text
tid Text
chid Text
mid =
forall a.
FromJSON a =>
[Text] -> Option 'Https -> AccessToken -> Req a
MSG.get [Text
"teams", Text
tid, Text
"channels", Text
chid, Text
"messages", Text
mid, Text
"replies"] forall a. Monoid a => a
mempty
data ChatMessage = ChatMessage {
ChatMessage -> ChatMessageBody
chamBody :: ChatMessageBody
, ChatMessage -> Text
chamId :: Text
, ChatMessage -> ZonedTime
chamCreatedDateTime :: ZonedTime
, ChatMessage -> Maybe ZonedTime
chamDeletedDateTime :: Maybe ZonedTime
} deriving (Int -> ChatMessage -> ShowS
[ChatMessage] -> ShowS
ChatMessage -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ChatMessage] -> ShowS
$cshowList :: [ChatMessage] -> ShowS
show :: ChatMessage -> String
$cshow :: ChatMessage -> String
showsPrec :: Int -> ChatMessage -> ShowS
$cshowsPrec :: Int -> ChatMessage -> ShowS
Show, forall x. Rep ChatMessage x -> ChatMessage
forall x. ChatMessage -> Rep ChatMessage x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ChatMessage x -> ChatMessage
$cfrom :: forall x. ChatMessage -> Rep ChatMessage x
Generic)
instance A.FromJSON ChatMessage where
parseJSON :: Value -> Parser ChatMessage
parseJSON = forall a.
(Generic a, GFromJSON Zero (Rep a)) =>
Options -> Value -> Parser a
A.genericParseJSON (String -> Options
MSG.aesonOptions String
"cham")
instance A.ToJSON ChatMessage
data ChatMessageBody = ChatMessageBody {
ChatMessageBody -> Text
chambId :: Text
} deriving (ChatMessageBody -> ChatMessageBody -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ChatMessageBody -> ChatMessageBody -> Bool
$c/= :: ChatMessageBody -> ChatMessageBody -> Bool
== :: ChatMessageBody -> ChatMessageBody -> Bool
$c== :: ChatMessageBody -> ChatMessageBody -> Bool
Eq, Eq ChatMessageBody
ChatMessageBody -> ChatMessageBody -> Bool
ChatMessageBody -> ChatMessageBody -> Ordering
ChatMessageBody -> ChatMessageBody -> ChatMessageBody
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: ChatMessageBody -> ChatMessageBody -> ChatMessageBody
$cmin :: ChatMessageBody -> ChatMessageBody -> ChatMessageBody
max :: ChatMessageBody -> ChatMessageBody -> ChatMessageBody
$cmax :: ChatMessageBody -> ChatMessageBody -> ChatMessageBody
>= :: ChatMessageBody -> ChatMessageBody -> Bool
$c>= :: ChatMessageBody -> ChatMessageBody -> Bool
> :: ChatMessageBody -> ChatMessageBody -> Bool
$c> :: ChatMessageBody -> ChatMessageBody -> Bool
<= :: ChatMessageBody -> ChatMessageBody -> Bool
$c<= :: ChatMessageBody -> ChatMessageBody -> Bool
< :: ChatMessageBody -> ChatMessageBody -> Bool
$c< :: ChatMessageBody -> ChatMessageBody -> Bool
compare :: ChatMessageBody -> ChatMessageBody -> Ordering
$ccompare :: ChatMessageBody -> ChatMessageBody -> Ordering
Ord, forall x. Rep ChatMessageBody x -> ChatMessageBody
forall x. ChatMessageBody -> Rep ChatMessageBody x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ChatMessageBody x -> ChatMessageBody
$cfrom :: forall x. ChatMessageBody -> Rep ChatMessageBody x
Generic)
instance Show ChatMessageBody where
show :: ChatMessageBody -> String
show = Text -> String
unpack forall b c a. (b -> c) -> (a -> b) -> a -> c
. ChatMessageBody -> Text
chambId
instance A.FromJSON ChatMessageBody where
parseJSON :: Value -> Parser ChatMessageBody
parseJSON = forall a.
(Generic a, GFromJSON Zero (Rep a)) =>
Options -> Value -> Parser a
A.genericParseJSON (String -> Options
MSG.aesonOptions String
"chamb")
instance A.ToJSON ChatMessageBody
listUserAssociatedTeams :: Text
-> AccessToken -> Req (MSG.Collection Group)
listUserAssociatedTeams :: Text -> AccessToken -> Req (Collection Group)
listUserAssociatedTeams Text
uid = forall a.
FromJSON a =>
[Text] -> Option 'Https -> AccessToken -> Req a
MSG.get [Text
"users", Text
uid, Text
"teamwork", Text
"associatedTeams"] forall a. Monoid a => a
mempty
listMeAssociatedTeams :: AccessToken -> Req (MSG.Collection Group)
listMeAssociatedTeams :: AccessToken -> Req (Collection Group)
listMeAssociatedTeams = forall a.
FromJSON a =>
[Text] -> Option 'Https -> AccessToken -> Req a
MSG.get [Text
"me", Text
"teamwork", Text
"associatedTeams"] forall a. Monoid a => a
mempty
listUserJoinedTeams :: Text
-> AccessToken -> Req (MSG.Collection Group)
listUserJoinedTeams :: Text -> AccessToken -> Req (Collection Group)
listUserJoinedTeams Text
uid = forall a.
FromJSON a =>
[Text] -> Option 'Https -> AccessToken -> Req a
MSG.get [Text
"users", Text
uid, Text
"joinedTeams"] forall a. Monoid a => a
mempty
listMeJoinedTeams :: AccessToken -> Req (MSG.Collection Group)
listMeJoinedTeams :: AccessToken -> Req (Collection Group)
listMeJoinedTeams = forall a.
FromJSON a =>
[Text] -> Option 'Https -> AccessToken -> Req a
MSG.get [Text
"me", Text
"joinedTeams"] forall a. Monoid a => a
mempty
listGroupsDriveItems :: Text
-> AccessToken -> Req (MSG.Collection DriveItem)
listGroupsDriveItems :: Text -> AccessToken -> Req (Collection DriveItem)
listGroupsDriveItems Text
gid = forall a.
FromJSON a =>
[Text] -> Option 'Https -> AccessToken -> Req a
MSG.get [Text
"groups", Text
gid, Text
"drive", Text
"root", Text
"children"] forall a. Monoid a => a
mempty