{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
{-# OPTIONS_GHC -fno-warn-duplicate-exports #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
module Network.Google.Resource.Gmail.Users.Messages.Insert
(
UsersMessagesInsertResource
, usersMessagesInsert
, UsersMessagesInsert
, uPayload
, uUserId
, uDeleted
, uInternalDateSource
) where
import Network.Google.Gmail.Types
import Network.Google.Prelude
type UsersMessagesInsertResource =
"gmail" :>
"v1" :>
"users" :>
Capture "userId" Text :>
"messages" :>
QueryParam "deleted" Bool :>
QueryParam "internalDateSource"
UsersMessagesInsertInternalDateSource
:>
QueryParam "alt" AltJSON :>
ReqBody '[JSON] Message :> Post '[JSON] Message
:<|>
"upload" :>
"gmail" :>
"v1" :>
"users" :>
Capture "userId" Text :>
"messages" :>
QueryParam "deleted" Bool :>
QueryParam "internalDateSource"
UsersMessagesInsertInternalDateSource
:>
QueryParam "alt" AltJSON :>
QueryParam "uploadType" Multipart :>
MultipartRelated '[JSON] Message :>
Post '[JSON] Message
data UsersMessagesInsert = UsersMessagesInsert'
{ _uPayload :: !Message
, _uUserId :: !Text
, _uDeleted :: !Bool
, _uInternalDateSource :: !UsersMessagesInsertInternalDateSource
} deriving (Eq,Show,Data,Typeable,Generic)
usersMessagesInsert
:: Message
-> UsersMessagesInsert
usersMessagesInsert pUPayload_ =
UsersMessagesInsert'
{ _uPayload = pUPayload_
, _uUserId = "me"
, _uDeleted = False
, _uInternalDateSource = UMIIDSReceivedTime
}
uPayload :: Lens' UsersMessagesInsert Message
uPayload = lens _uPayload (\ s a -> s{_uPayload = a})
uUserId :: Lens' UsersMessagesInsert Text
uUserId = lens _uUserId (\ s a -> s{_uUserId = a})
uDeleted :: Lens' UsersMessagesInsert Bool
uDeleted = lens _uDeleted (\ s a -> s{_uDeleted = a})
uInternalDateSource :: Lens' UsersMessagesInsert UsersMessagesInsertInternalDateSource
uInternalDateSource
= lens _uInternalDateSource
(\ s a -> s{_uInternalDateSource = a})
instance GoogleRequest UsersMessagesInsert where
type Rs UsersMessagesInsert = Message
type Scopes UsersMessagesInsert =
'["https://mail.google.com/",
"https://www.googleapis.com/auth/gmail.insert",
"https://www.googleapis.com/auth/gmail.modify"]
requestClient UsersMessagesInsert'{..}
= go _uUserId (Just _uDeleted)
(Just _uInternalDateSource)
(Just AltJSON)
_uPayload
gmailService
where go :<|> _
= buildClient
(Proxy :: Proxy UsersMessagesInsertResource)
mempty
instance GoogleRequest
(MediaUpload UsersMessagesInsert) where
type Rs (MediaUpload UsersMessagesInsert) = Message
type Scopes (MediaUpload UsersMessagesInsert) =
Scopes UsersMessagesInsert
requestClient
(MediaUpload UsersMessagesInsert'{..} body)
= go _uUserId (Just _uDeleted)
(Just _uInternalDateSource)
(Just AltJSON)
(Just Multipart)
_uPayload
body
gmailService
where _ :<|> go
= buildClient
(Proxy :: Proxy UsersMessagesInsertResource)
mempty