module Network.Google.Gmail.Types.Product where
import Network.Google.Gmail.Types.Sum
import Network.Google.Prelude
newtype BatchDeleteMessagesRequest = BatchDeleteMessagesRequest'
{ _bdmrIds :: Maybe [Text]
} deriving (Eq,Show,Data,Typeable,Generic)
batchDeleteMessagesRequest
:: BatchDeleteMessagesRequest
batchDeleteMessagesRequest =
BatchDeleteMessagesRequest'
{ _bdmrIds = Nothing
}
bdmrIds :: Lens' BatchDeleteMessagesRequest [Text]
bdmrIds
= lens _bdmrIds (\ s a -> s{_bdmrIds = a}) . _Default
. _Coerce
instance FromJSON BatchDeleteMessagesRequest where
parseJSON
= withObject "BatchDeleteMessagesRequest"
(\ o ->
BatchDeleteMessagesRequest' <$>
(o .:? "ids" .!= mempty))
instance ToJSON BatchDeleteMessagesRequest where
toJSON BatchDeleteMessagesRequest'{..}
= object (catMaybes [("ids" .=) <$> _bdmrIds])
data ModifyThreadRequest = ModifyThreadRequest'
{ _mtrRemoveLabelIds :: !(Maybe [Text])
, _mtrAddLabelIds :: !(Maybe [Text])
} deriving (Eq,Show,Data,Typeable,Generic)
modifyThreadRequest
:: ModifyThreadRequest
modifyThreadRequest =
ModifyThreadRequest'
{ _mtrRemoveLabelIds = Nothing
, _mtrAddLabelIds = Nothing
}
mtrRemoveLabelIds :: Lens' ModifyThreadRequest [Text]
mtrRemoveLabelIds
= lens _mtrRemoveLabelIds
(\ s a -> s{_mtrRemoveLabelIds = a})
. _Default
. _Coerce
mtrAddLabelIds :: Lens' ModifyThreadRequest [Text]
mtrAddLabelIds
= lens _mtrAddLabelIds
(\ s a -> s{_mtrAddLabelIds = a})
. _Default
. _Coerce
instance FromJSON ModifyThreadRequest where
parseJSON
= withObject "ModifyThreadRequest"
(\ o ->
ModifyThreadRequest' <$>
(o .:? "removeLabelIds" .!= mempty) <*>
(o .:? "addLabelIds" .!= mempty))
instance ToJSON ModifyThreadRequest where
toJSON ModifyThreadRequest'{..}
= object
(catMaybes
[("removeLabelIds" .=) <$> _mtrRemoveLabelIds,
("addLabelIds" .=) <$> _mtrAddLabelIds])
data ModifyMessageRequest = ModifyMessageRequest'
{ _mmrRemoveLabelIds :: !(Maybe [Text])
, _mmrAddLabelIds :: !(Maybe [Text])
} deriving (Eq,Show,Data,Typeable,Generic)
modifyMessageRequest
:: ModifyMessageRequest
modifyMessageRequest =
ModifyMessageRequest'
{ _mmrRemoveLabelIds = Nothing
, _mmrAddLabelIds = Nothing
}
mmrRemoveLabelIds :: Lens' ModifyMessageRequest [Text]
mmrRemoveLabelIds
= lens _mmrRemoveLabelIds
(\ s a -> s{_mmrRemoveLabelIds = a})
. _Default
. _Coerce
mmrAddLabelIds :: Lens' ModifyMessageRequest [Text]
mmrAddLabelIds
= lens _mmrAddLabelIds
(\ s a -> s{_mmrAddLabelIds = a})
. _Default
. _Coerce
instance FromJSON ModifyMessageRequest where
parseJSON
= withObject "ModifyMessageRequest"
(\ o ->
ModifyMessageRequest' <$>
(o .:? "removeLabelIds" .!= mempty) <*>
(o .:? "addLabelIds" .!= mempty))
instance ToJSON ModifyMessageRequest where
toJSON ModifyMessageRequest'{..}
= object
(catMaybes
[("removeLabelIds" .=) <$> _mmrRemoveLabelIds,
("addLabelIds" .=) <$> _mmrAddLabelIds])
data History = History'
{ _hLabelsRemoved :: !(Maybe [HistoryLabelRemoved])
, _hMessagesDeleted :: !(Maybe [HistoryMessageDeleted])
, _hMessagesAdded :: !(Maybe [HistoryMessageAdded])
, _hLabelsAdded :: !(Maybe [HistoryLabelAdded])
, _hId :: !(Maybe (Textual Word64))
, _hMessages :: !(Maybe [Message])
} deriving (Eq,Show,Data,Typeable,Generic)
history
:: History
history =
History'
{ _hLabelsRemoved = Nothing
, _hMessagesDeleted = Nothing
, _hMessagesAdded = Nothing
, _hLabelsAdded = Nothing
, _hId = Nothing
, _hMessages = Nothing
}
hLabelsRemoved :: Lens' History [HistoryLabelRemoved]
hLabelsRemoved
= lens _hLabelsRemoved
(\ s a -> s{_hLabelsRemoved = a})
. _Default
. _Coerce
hMessagesDeleted :: Lens' History [HistoryMessageDeleted]
hMessagesDeleted
= lens _hMessagesDeleted
(\ s a -> s{_hMessagesDeleted = a})
. _Default
. _Coerce
hMessagesAdded :: Lens' History [HistoryMessageAdded]
hMessagesAdded
= lens _hMessagesAdded
(\ s a -> s{_hMessagesAdded = a})
. _Default
. _Coerce
hLabelsAdded :: Lens' History [HistoryLabelAdded]
hLabelsAdded
= lens _hLabelsAdded (\ s a -> s{_hLabelsAdded = a})
. _Default
. _Coerce
hId :: Lens' History (Maybe Word64)
hId
= lens _hId (\ s a -> s{_hId = a}) . mapping _Coerce
hMessages :: Lens' History [Message]
hMessages
= lens _hMessages (\ s a -> s{_hMessages = a}) .
_Default
. _Coerce
instance FromJSON History where
parseJSON
= withObject "History"
(\ o ->
History' <$>
(o .:? "labelsRemoved" .!= mempty) <*>
(o .:? "messagesDeleted" .!= mempty)
<*> (o .:? "messagesAdded" .!= mempty)
<*> (o .:? "labelsAdded" .!= mempty)
<*> (o .:? "id")
<*> (o .:? "messages" .!= mempty))
instance ToJSON History where
toJSON History'{..}
= object
(catMaybes
[("labelsRemoved" .=) <$> _hLabelsRemoved,
("messagesDeleted" .=) <$> _hMessagesDeleted,
("messagesAdded" .=) <$> _hMessagesAdded,
("labelsAdded" .=) <$> _hLabelsAdded,
("id" .=) <$> _hId, ("messages" .=) <$> _hMessages])
data ProFile = ProFile'
{ _pfMessagesTotal :: !(Maybe (Textual Int32))
, _pfThreadsTotal :: !(Maybe (Textual Int32))
, _pfHistoryId :: !(Maybe (Textual Word64))
, _pfEmailAddress :: !(Maybe Text)
} deriving (Eq,Show,Data,Typeable,Generic)
proFile
:: ProFile
proFile =
ProFile'
{ _pfMessagesTotal = Nothing
, _pfThreadsTotal = Nothing
, _pfHistoryId = Nothing
, _pfEmailAddress = Nothing
}
pfMessagesTotal :: Lens' ProFile (Maybe Int32)
pfMessagesTotal
= lens _pfMessagesTotal
(\ s a -> s{_pfMessagesTotal = a})
. mapping _Coerce
pfThreadsTotal :: Lens' ProFile (Maybe Int32)
pfThreadsTotal
= lens _pfThreadsTotal
(\ s a -> s{_pfThreadsTotal = a})
. mapping _Coerce
pfHistoryId :: Lens' ProFile (Maybe Word64)
pfHistoryId
= lens _pfHistoryId (\ s a -> s{_pfHistoryId = a}) .
mapping _Coerce
pfEmailAddress :: Lens' ProFile (Maybe Text)
pfEmailAddress
= lens _pfEmailAddress
(\ s a -> s{_pfEmailAddress = a})
instance FromJSON ProFile where
parseJSON
= withObject "ProFile"
(\ o ->
ProFile' <$>
(o .:? "messagesTotal") <*> (o .:? "threadsTotal")
<*> (o .:? "historyId")
<*> (o .:? "emailAddress"))
instance ToJSON ProFile where
toJSON ProFile'{..}
= object
(catMaybes
[("messagesTotal" .=) <$> _pfMessagesTotal,
("threadsTotal" .=) <$> _pfThreadsTotal,
("historyId" .=) <$> _pfHistoryId,
("emailAddress" .=) <$> _pfEmailAddress])
data MessagePartHeader = MessagePartHeader'
{ _mphValue :: !(Maybe Text)
, _mphName :: !(Maybe Text)
} deriving (Eq,Show,Data,Typeable,Generic)
messagePartHeader
:: MessagePartHeader
messagePartHeader =
MessagePartHeader'
{ _mphValue = Nothing
, _mphName = Nothing
}
mphValue :: Lens' MessagePartHeader (Maybe Text)
mphValue = lens _mphValue (\ s a -> s{_mphValue = a})
mphName :: Lens' MessagePartHeader (Maybe Text)
mphName = lens _mphName (\ s a -> s{_mphName = a})
instance FromJSON MessagePartHeader where
parseJSON
= withObject "MessagePartHeader"
(\ o ->
MessagePartHeader' <$>
(o .:? "value") <*> (o .:? "name"))
instance ToJSON MessagePartHeader where
toJSON MessagePartHeader'{..}
= object
(catMaybes
[("value" .=) <$> _mphValue,
("name" .=) <$> _mphName])
data ListHistoryResponse = ListHistoryResponse'
{ _lhrNextPageToken :: !(Maybe Text)
, _lhrHistory :: !(Maybe [History])
, _lhrHistoryId :: !(Maybe (Textual Word64))
} deriving (Eq,Show,Data,Typeable,Generic)
listHistoryResponse
:: ListHistoryResponse
listHistoryResponse =
ListHistoryResponse'
{ _lhrNextPageToken = Nothing
, _lhrHistory = Nothing
, _lhrHistoryId = Nothing
}
lhrNextPageToken :: Lens' ListHistoryResponse (Maybe Text)
lhrNextPageToken
= lens _lhrNextPageToken
(\ s a -> s{_lhrNextPageToken = a})
lhrHistory :: Lens' ListHistoryResponse [History]
lhrHistory
= lens _lhrHistory (\ s a -> s{_lhrHistory = a}) .
_Default
. _Coerce
lhrHistoryId :: Lens' ListHistoryResponse (Maybe Word64)
lhrHistoryId
= lens _lhrHistoryId (\ s a -> s{_lhrHistoryId = a})
. mapping _Coerce
instance FromJSON ListHistoryResponse where
parseJSON
= withObject "ListHistoryResponse"
(\ o ->
ListHistoryResponse' <$>
(o .:? "nextPageToken") <*>
(o .:? "history" .!= mempty)
<*> (o .:? "historyId"))
instance ToJSON ListHistoryResponse where
toJSON ListHistoryResponse'{..}
= object
(catMaybes
[("nextPageToken" .=) <$> _lhrNextPageToken,
("history" .=) <$> _lhrHistory,
("historyId" .=) <$> _lhrHistoryId])
data ListThreadsResponse = ListThreadsResponse'
{ _ltrNextPageToken :: !(Maybe Text)
, _ltrResultSizeEstimate :: !(Maybe (Textual Word32))
, _ltrThreads :: !(Maybe [Thread])
} deriving (Eq,Show,Data,Typeable,Generic)
listThreadsResponse
:: ListThreadsResponse
listThreadsResponse =
ListThreadsResponse'
{ _ltrNextPageToken = Nothing
, _ltrResultSizeEstimate = Nothing
, _ltrThreads = Nothing
}
ltrNextPageToken :: Lens' ListThreadsResponse (Maybe Text)
ltrNextPageToken
= lens _ltrNextPageToken
(\ s a -> s{_ltrNextPageToken = a})
ltrResultSizeEstimate :: Lens' ListThreadsResponse (Maybe Word32)
ltrResultSizeEstimate
= lens _ltrResultSizeEstimate
(\ s a -> s{_ltrResultSizeEstimate = a})
. mapping _Coerce
ltrThreads :: Lens' ListThreadsResponse [Thread]
ltrThreads
= lens _ltrThreads (\ s a -> s{_ltrThreads = a}) .
_Default
. _Coerce
instance FromJSON ListThreadsResponse where
parseJSON
= withObject "ListThreadsResponse"
(\ o ->
ListThreadsResponse' <$>
(o .:? "nextPageToken") <*>
(o .:? "resultSizeEstimate")
<*> (o .:? "threads" .!= mempty))
instance ToJSON ListThreadsResponse where
toJSON ListThreadsResponse'{..}
= object
(catMaybes
[("nextPageToken" .=) <$> _ltrNextPageToken,
("resultSizeEstimate" .=) <$> _ltrResultSizeEstimate,
("threads" .=) <$> _ltrThreads])
data MessagePart = MessagePart'
{ _mpParts :: !(Maybe [MessagePart])
, _mpBody :: !(Maybe MessagePartBody)
, _mpMimeType :: !(Maybe Text)
, _mpHeaders :: !(Maybe [MessagePartHeader])
, _mpPartId :: !(Maybe Text)
, _mpFilename :: !(Maybe Text)
} deriving (Eq,Show,Data,Typeable,Generic)
messagePart
:: MessagePart
messagePart =
MessagePart'
{ _mpParts = Nothing
, _mpBody = Nothing
, _mpMimeType = Nothing
, _mpHeaders = Nothing
, _mpPartId = Nothing
, _mpFilename = Nothing
}
mpParts :: Lens' MessagePart [MessagePart]
mpParts
= lens _mpParts (\ s a -> s{_mpParts = a}) . _Default
. _Coerce
mpBody :: Lens' MessagePart (Maybe MessagePartBody)
mpBody = lens _mpBody (\ s a -> s{_mpBody = a})
mpMimeType :: Lens' MessagePart (Maybe Text)
mpMimeType
= lens _mpMimeType (\ s a -> s{_mpMimeType = a})
mpHeaders :: Lens' MessagePart [MessagePartHeader]
mpHeaders
= lens _mpHeaders (\ s a -> s{_mpHeaders = a}) .
_Default
. _Coerce
mpPartId :: Lens' MessagePart (Maybe Text)
mpPartId = lens _mpPartId (\ s a -> s{_mpPartId = a})
mpFilename :: Lens' MessagePart (Maybe Text)
mpFilename
= lens _mpFilename (\ s a -> s{_mpFilename = a})
instance FromJSON MessagePart where
parseJSON
= withObject "MessagePart"
(\ o ->
MessagePart' <$>
(o .:? "parts" .!= mempty) <*> (o .:? "body") <*>
(o .:? "mimeType")
<*> (o .:? "headers" .!= mempty)
<*> (o .:? "partId")
<*> (o .:? "filename"))
instance ToJSON MessagePart where
toJSON MessagePart'{..}
= object
(catMaybes
[("parts" .=) <$> _mpParts, ("body" .=) <$> _mpBody,
("mimeType" .=) <$> _mpMimeType,
("headers" .=) <$> _mpHeaders,
("partId" .=) <$> _mpPartId,
("filename" .=) <$> _mpFilename])
data HistoryLabelAdded = HistoryLabelAdded'
{ _hlaLabelIds :: !(Maybe [Text])
, _hlaMessage :: !(Maybe Message)
} deriving (Eq,Show,Data,Typeable,Generic)
historyLabelAdded
:: HistoryLabelAdded
historyLabelAdded =
HistoryLabelAdded'
{ _hlaLabelIds = Nothing
, _hlaMessage = Nothing
}
hlaLabelIds :: Lens' HistoryLabelAdded [Text]
hlaLabelIds
= lens _hlaLabelIds (\ s a -> s{_hlaLabelIds = a}) .
_Default
. _Coerce
hlaMessage :: Lens' HistoryLabelAdded (Maybe Message)
hlaMessage
= lens _hlaMessage (\ s a -> s{_hlaMessage = a})
instance FromJSON HistoryLabelAdded where
parseJSON
= withObject "HistoryLabelAdded"
(\ o ->
HistoryLabelAdded' <$>
(o .:? "labelIds" .!= mempty) <*> (o .:? "message"))
instance ToJSON HistoryLabelAdded where
toJSON HistoryLabelAdded'{..}
= object
(catMaybes
[("labelIds" .=) <$> _hlaLabelIds,
("message" .=) <$> _hlaMessage])
newtype ListLabelsResponse = ListLabelsResponse'
{ _llrLabels :: Maybe [Label]
} deriving (Eq,Show,Data,Typeable,Generic)
listLabelsResponse
:: ListLabelsResponse
listLabelsResponse =
ListLabelsResponse'
{ _llrLabels = Nothing
}
llrLabels :: Lens' ListLabelsResponse [Label]
llrLabels
= lens _llrLabels (\ s a -> s{_llrLabels = a}) .
_Default
. _Coerce
instance FromJSON ListLabelsResponse where
parseJSON
= withObject "ListLabelsResponse"
(\ o ->
ListLabelsResponse' <$> (o .:? "labels" .!= mempty))
instance ToJSON ListLabelsResponse where
toJSON ListLabelsResponse'{..}
= object (catMaybes [("labels" .=) <$> _llrLabels])
newtype HistoryMessageDeleted = HistoryMessageDeleted'
{ _hmdMessage :: Maybe Message
} deriving (Eq,Show,Data,Typeable,Generic)
historyMessageDeleted
:: HistoryMessageDeleted
historyMessageDeleted =
HistoryMessageDeleted'
{ _hmdMessage = Nothing
}
hmdMessage :: Lens' HistoryMessageDeleted (Maybe Message)
hmdMessage
= lens _hmdMessage (\ s a -> s{_hmdMessage = a})
instance FromJSON HistoryMessageDeleted where
parseJSON
= withObject "HistoryMessageDeleted"
(\ o -> HistoryMessageDeleted' <$> (o .:? "message"))
instance ToJSON HistoryMessageDeleted where
toJSON HistoryMessageDeleted'{..}
= object (catMaybes [("message" .=) <$> _hmdMessage])
data MessagePartBody = MessagePartBody'
{ _mpbSize :: !(Maybe (Textual Int32))
, _mpbData :: !(Maybe Base64)
, _mpbAttachmentId :: !(Maybe Text)
} deriving (Eq,Show,Data,Typeable,Generic)
messagePartBody
:: MessagePartBody
messagePartBody =
MessagePartBody'
{ _mpbSize = Nothing
, _mpbData = Nothing
, _mpbAttachmentId = Nothing
}
mpbSize :: Lens' MessagePartBody (Maybe Int32)
mpbSize
= lens _mpbSize (\ s a -> s{_mpbSize = a}) .
mapping _Coerce
mpbData :: Lens' MessagePartBody (Maybe ByteString)
mpbData
= lens _mpbData (\ s a -> s{_mpbData = a}) .
mapping _Base64
mpbAttachmentId :: Lens' MessagePartBody (Maybe Text)
mpbAttachmentId
= lens _mpbAttachmentId
(\ s a -> s{_mpbAttachmentId = a})
instance FromJSON MessagePartBody where
parseJSON
= withObject "MessagePartBody"
(\ o ->
MessagePartBody' <$>
(o .:? "size") <*> (o .:? "data") <*>
(o .:? "attachmentId"))
instance ToJSON MessagePartBody where
toJSON MessagePartBody'{..}
= object
(catMaybes
[("size" .=) <$> _mpbSize, ("data" .=) <$> _mpbData,
("attachmentId" .=) <$> _mpbAttachmentId])
data ListDraftsResponse = ListDraftsResponse'
{ _ldrNextPageToken :: !(Maybe Text)
, _ldrResultSizeEstimate :: !(Maybe (Textual Word32))
, _ldrDrafts :: !(Maybe [Draft])
} deriving (Eq,Show,Data,Typeable,Generic)
listDraftsResponse
:: ListDraftsResponse
listDraftsResponse =
ListDraftsResponse'
{ _ldrNextPageToken = Nothing
, _ldrResultSizeEstimate = Nothing
, _ldrDrafts = Nothing
}
ldrNextPageToken :: Lens' ListDraftsResponse (Maybe Text)
ldrNextPageToken
= lens _ldrNextPageToken
(\ s a -> s{_ldrNextPageToken = a})
ldrResultSizeEstimate :: Lens' ListDraftsResponse (Maybe Word32)
ldrResultSizeEstimate
= lens _ldrResultSizeEstimate
(\ s a -> s{_ldrResultSizeEstimate = a})
. mapping _Coerce
ldrDrafts :: Lens' ListDraftsResponse [Draft]
ldrDrafts
= lens _ldrDrafts (\ s a -> s{_ldrDrafts = a}) .
_Default
. _Coerce
instance FromJSON ListDraftsResponse where
parseJSON
= withObject "ListDraftsResponse"
(\ o ->
ListDraftsResponse' <$>
(o .:? "nextPageToken") <*>
(o .:? "resultSizeEstimate")
<*> (o .:? "drafts" .!= mempty))
instance ToJSON ListDraftsResponse where
toJSON ListDraftsResponse'{..}
= object
(catMaybes
[("nextPageToken" .=) <$> _ldrNextPageToken,
("resultSizeEstimate" .=) <$> _ldrResultSizeEstimate,
("drafts" .=) <$> _ldrDrafts])
data WatchResponse = WatchResponse'
{ _wrExpiration :: !(Maybe (Textual Int64))
, _wrHistoryId :: !(Maybe (Textual Word64))
} deriving (Eq,Show,Data,Typeable,Generic)
watchResponse
:: WatchResponse
watchResponse =
WatchResponse'
{ _wrExpiration = Nothing
, _wrHistoryId = Nothing
}
wrExpiration :: Lens' WatchResponse (Maybe Int64)
wrExpiration
= lens _wrExpiration (\ s a -> s{_wrExpiration = a})
. mapping _Coerce
wrHistoryId :: Lens' WatchResponse (Maybe Word64)
wrHistoryId
= lens _wrHistoryId (\ s a -> s{_wrHistoryId = a}) .
mapping _Coerce
instance FromJSON WatchResponse where
parseJSON
= withObject "WatchResponse"
(\ o ->
WatchResponse' <$>
(o .:? "expiration") <*> (o .:? "historyId"))
instance ToJSON WatchResponse where
toJSON WatchResponse'{..}
= object
(catMaybes
[("expiration" .=) <$> _wrExpiration,
("historyId" .=) <$> _wrHistoryId])
data Draft = Draft'
{ _dId :: !(Maybe Text)
, _dMessage :: !(Maybe Message)
} deriving (Eq,Show,Data,Typeable,Generic)
draft
:: Draft
draft =
Draft'
{ _dId = Nothing
, _dMessage = Nothing
}
dId :: Lens' Draft (Maybe Text)
dId = lens _dId (\ s a -> s{_dId = a})
dMessage :: Lens' Draft (Maybe Message)
dMessage = lens _dMessage (\ s a -> s{_dMessage = a})
instance FromJSON Draft where
parseJSON
= withObject "Draft"
(\ o ->
Draft' <$> (o .:? "id") <*> (o .:? "message"))
instance ToJSON Draft where
toJSON Draft'{..}
= object
(catMaybes
[("id" .=) <$> _dId, ("message" .=) <$> _dMessage])
data WatchRequest = WatchRequest'
{ _wrLabelFilterAction :: !(Maybe WatchRequestLabelFilterAction)
, _wrTopicName :: !(Maybe Text)
, _wrLabelIds :: !(Maybe [Text])
} deriving (Eq,Show,Data,Typeable,Generic)
watchRequest
:: WatchRequest
watchRequest =
WatchRequest'
{ _wrLabelFilterAction = Nothing
, _wrTopicName = Nothing
, _wrLabelIds = Nothing
}
wrLabelFilterAction :: Lens' WatchRequest (Maybe WatchRequestLabelFilterAction)
wrLabelFilterAction
= lens _wrLabelFilterAction
(\ s a -> s{_wrLabelFilterAction = a})
wrTopicName :: Lens' WatchRequest (Maybe Text)
wrTopicName
= lens _wrTopicName (\ s a -> s{_wrTopicName = a})
wrLabelIds :: Lens' WatchRequest [Text]
wrLabelIds
= lens _wrLabelIds (\ s a -> s{_wrLabelIds = a}) .
_Default
. _Coerce
instance FromJSON WatchRequest where
parseJSON
= withObject "WatchRequest"
(\ o ->
WatchRequest' <$>
(o .:? "labelFilterAction") <*> (o .:? "topicName")
<*> (o .:? "labelIds" .!= mempty))
instance ToJSON WatchRequest where
toJSON WatchRequest'{..}
= object
(catMaybes
[("labelFilterAction" .=) <$> _wrLabelFilterAction,
("topicName" .=) <$> _wrTopicName,
("labelIds" .=) <$> _wrLabelIds])
data Message = Message'
{ _mRaw :: !(Maybe Base64)
, _mSnippet :: !(Maybe Text)
, _mSizeEstimate :: !(Maybe (Textual Int32))
, _mPayload :: !(Maybe MessagePart)
, _mHistoryId :: !(Maybe (Textual Word64))
, _mId :: !(Maybe Text)
, _mLabelIds :: !(Maybe [Text])
, _mThreadId :: !(Maybe Text)
, _mInternalDate :: !(Maybe (Textual Int64))
} deriving (Eq,Show,Data,Typeable,Generic)
message
:: Message
message =
Message'
{ _mRaw = Nothing
, _mSnippet = Nothing
, _mSizeEstimate = Nothing
, _mPayload = Nothing
, _mHistoryId = Nothing
, _mId = Nothing
, _mLabelIds = Nothing
, _mThreadId = Nothing
, _mInternalDate = Nothing
}
mRaw :: Lens' Message (Maybe ByteString)
mRaw
= lens _mRaw (\ s a -> s{_mRaw = a}) .
mapping _Base64
mSnippet :: Lens' Message (Maybe Text)
mSnippet = lens _mSnippet (\ s a -> s{_mSnippet = a})
mSizeEstimate :: Lens' Message (Maybe Int32)
mSizeEstimate
= lens _mSizeEstimate
(\ s a -> s{_mSizeEstimate = a})
. mapping _Coerce
mPayload :: Lens' Message (Maybe MessagePart)
mPayload = lens _mPayload (\ s a -> s{_mPayload = a})
mHistoryId :: Lens' Message (Maybe Word64)
mHistoryId
= lens _mHistoryId (\ s a -> s{_mHistoryId = a}) .
mapping _Coerce
mId :: Lens' Message (Maybe Text)
mId = lens _mId (\ s a -> s{_mId = a})
mLabelIds :: Lens' Message [Text]
mLabelIds
= lens _mLabelIds (\ s a -> s{_mLabelIds = a}) .
_Default
. _Coerce
mThreadId :: Lens' Message (Maybe Text)
mThreadId
= lens _mThreadId (\ s a -> s{_mThreadId = a})
mInternalDate :: Lens' Message (Maybe Int64)
mInternalDate
= lens _mInternalDate
(\ s a -> s{_mInternalDate = a})
. mapping _Coerce
instance FromJSON Message where
parseJSON
= withObject "Message"
(\ o ->
Message' <$>
(o .:? "raw") <*> (o .:? "snippet") <*>
(o .:? "sizeEstimate")
<*> (o .:? "payload")
<*> (o .:? "historyId")
<*> (o .:? "id")
<*> (o .:? "labelIds" .!= mempty)
<*> (o .:? "threadId")
<*> (o .:? "internalDate"))
instance ToJSON Message where
toJSON Message'{..}
= object
(catMaybes
[("raw" .=) <$> _mRaw, ("snippet" .=) <$> _mSnippet,
("sizeEstimate" .=) <$> _mSizeEstimate,
("payload" .=) <$> _mPayload,
("historyId" .=) <$> _mHistoryId, ("id" .=) <$> _mId,
("labelIds" .=) <$> _mLabelIds,
("threadId" .=) <$> _mThreadId,
("internalDate" .=) <$> _mInternalDate])
data HistoryLabelRemoved = HistoryLabelRemoved'
{ _hlrLabelIds :: !(Maybe [Text])
, _hlrMessage :: !(Maybe Message)
} deriving (Eq,Show,Data,Typeable,Generic)
historyLabelRemoved
:: HistoryLabelRemoved
historyLabelRemoved =
HistoryLabelRemoved'
{ _hlrLabelIds = Nothing
, _hlrMessage = Nothing
}
hlrLabelIds :: Lens' HistoryLabelRemoved [Text]
hlrLabelIds
= lens _hlrLabelIds (\ s a -> s{_hlrLabelIds = a}) .
_Default
. _Coerce
hlrMessage :: Lens' HistoryLabelRemoved (Maybe Message)
hlrMessage
= lens _hlrMessage (\ s a -> s{_hlrMessage = a})
instance FromJSON HistoryLabelRemoved where
parseJSON
= withObject "HistoryLabelRemoved"
(\ o ->
HistoryLabelRemoved' <$>
(o .:? "labelIds" .!= mempty) <*> (o .:? "message"))
instance ToJSON HistoryLabelRemoved where
toJSON HistoryLabelRemoved'{..}
= object
(catMaybes
[("labelIds" .=) <$> _hlrLabelIds,
("message" .=) <$> _hlrMessage])
data Thread = Thread'
{ _tSnippet :: !(Maybe Text)
, _tHistoryId :: !(Maybe (Textual Word64))
, _tId :: !(Maybe Text)
, _tMessages :: !(Maybe [Message])
} deriving (Eq,Show,Data,Typeable,Generic)
thread
:: Thread
thread =
Thread'
{ _tSnippet = Nothing
, _tHistoryId = Nothing
, _tId = Nothing
, _tMessages = Nothing
}
tSnippet :: Lens' Thread (Maybe Text)
tSnippet = lens _tSnippet (\ s a -> s{_tSnippet = a})
tHistoryId :: Lens' Thread (Maybe Word64)
tHistoryId
= lens _tHistoryId (\ s a -> s{_tHistoryId = a}) .
mapping _Coerce
tId :: Lens' Thread (Maybe Text)
tId = lens _tId (\ s a -> s{_tId = a})
tMessages :: Lens' Thread [Message]
tMessages
= lens _tMessages (\ s a -> s{_tMessages = a}) .
_Default
. _Coerce
instance FromJSON Thread where
parseJSON
= withObject "Thread"
(\ o ->
Thread' <$>
(o .:? "snippet") <*> (o .:? "historyId") <*>
(o .:? "id")
<*> (o .:? "messages" .!= mempty))
instance ToJSON Thread where
toJSON Thread'{..}
= object
(catMaybes
[("snippet" .=) <$> _tSnippet,
("historyId" .=) <$> _tHistoryId, ("id" .=) <$> _tId,
("messages" .=) <$> _tMessages])
data Label = Label'
{ _lThreadsUnread :: !(Maybe (Textual Int32))
, _lMessageListVisibility :: !(Maybe LabelMessageListVisibility)
, _lMessagesTotal :: !(Maybe (Textual Int32))
, _lMessagesUnread :: !(Maybe (Textual Int32))
, _lName :: !(Maybe Text)
, _lThreadsTotal :: !(Maybe (Textual Int32))
, _lLabelListVisibility :: !(Maybe LabelLabelListVisibility)
, _lId :: !(Maybe Text)
, _lType :: !(Maybe LabelType)
} deriving (Eq,Show,Data,Typeable,Generic)
label
:: Label
label =
Label'
{ _lThreadsUnread = Nothing
, _lMessageListVisibility = Nothing
, _lMessagesTotal = Nothing
, _lMessagesUnread = Nothing
, _lName = Nothing
, _lThreadsTotal = Nothing
, _lLabelListVisibility = Nothing
, _lId = Nothing
, _lType = Nothing
}
lThreadsUnread :: Lens' Label (Maybe Int32)
lThreadsUnread
= lens _lThreadsUnread
(\ s a -> s{_lThreadsUnread = a})
. mapping _Coerce
lMessageListVisibility :: Lens' Label (Maybe LabelMessageListVisibility)
lMessageListVisibility
= lens _lMessageListVisibility
(\ s a -> s{_lMessageListVisibility = a})
lMessagesTotal :: Lens' Label (Maybe Int32)
lMessagesTotal
= lens _lMessagesTotal
(\ s a -> s{_lMessagesTotal = a})
. mapping _Coerce
lMessagesUnread :: Lens' Label (Maybe Int32)
lMessagesUnread
= lens _lMessagesUnread
(\ s a -> s{_lMessagesUnread = a})
. mapping _Coerce
lName :: Lens' Label (Maybe Text)
lName = lens _lName (\ s a -> s{_lName = a})
lThreadsTotal :: Lens' Label (Maybe Int32)
lThreadsTotal
= lens _lThreadsTotal
(\ s a -> s{_lThreadsTotal = a})
. mapping _Coerce
lLabelListVisibility :: Lens' Label (Maybe LabelLabelListVisibility)
lLabelListVisibility
= lens _lLabelListVisibility
(\ s a -> s{_lLabelListVisibility = a})
lId :: Lens' Label (Maybe Text)
lId = lens _lId (\ s a -> s{_lId = a})
lType :: Lens' Label (Maybe LabelType)
lType = lens _lType (\ s a -> s{_lType = a})
instance FromJSON Label where
parseJSON
= withObject "Label"
(\ o ->
Label' <$>
(o .:? "threadsUnread") <*>
(o .:? "messageListVisibility")
<*> (o .:? "messagesTotal")
<*> (o .:? "messagesUnread")
<*> (o .:? "name")
<*> (o .:? "threadsTotal")
<*> (o .:? "labelListVisibility")
<*> (o .:? "id")
<*> (o .:? "type"))
instance ToJSON Label where
toJSON Label'{..}
= object
(catMaybes
[("threadsUnread" .=) <$> _lThreadsUnread,
("messageListVisibility" .=) <$>
_lMessageListVisibility,
("messagesTotal" .=) <$> _lMessagesTotal,
("messagesUnread" .=) <$> _lMessagesUnread,
("name" .=) <$> _lName,
("threadsTotal" .=) <$> _lThreadsTotal,
("labelListVisibility" .=) <$> _lLabelListVisibility,
("id" .=) <$> _lId, ("type" .=) <$> _lType])
data ListMessagesResponse = ListMessagesResponse'
{ _lmrNextPageToken :: !(Maybe Text)
, _lmrResultSizeEstimate :: !(Maybe (Textual Word32))
, _lmrMessages :: !(Maybe [Message])
} deriving (Eq,Show,Data,Typeable,Generic)
listMessagesResponse
:: ListMessagesResponse
listMessagesResponse =
ListMessagesResponse'
{ _lmrNextPageToken = Nothing
, _lmrResultSizeEstimate = Nothing
, _lmrMessages = Nothing
}
lmrNextPageToken :: Lens' ListMessagesResponse (Maybe Text)
lmrNextPageToken
= lens _lmrNextPageToken
(\ s a -> s{_lmrNextPageToken = a})
lmrResultSizeEstimate :: Lens' ListMessagesResponse (Maybe Word32)
lmrResultSizeEstimate
= lens _lmrResultSizeEstimate
(\ s a -> s{_lmrResultSizeEstimate = a})
. mapping _Coerce
lmrMessages :: Lens' ListMessagesResponse [Message]
lmrMessages
= lens _lmrMessages (\ s a -> s{_lmrMessages = a}) .
_Default
. _Coerce
instance FromJSON ListMessagesResponse where
parseJSON
= withObject "ListMessagesResponse"
(\ o ->
ListMessagesResponse' <$>
(o .:? "nextPageToken") <*>
(o .:? "resultSizeEstimate")
<*> (o .:? "messages" .!= mempty))
instance ToJSON ListMessagesResponse where
toJSON ListMessagesResponse'{..}
= object
(catMaybes
[("nextPageToken" .=) <$> _lmrNextPageToken,
("resultSizeEstimate" .=) <$> _lmrResultSizeEstimate,
("messages" .=) <$> _lmrMessages])
newtype HistoryMessageAdded = HistoryMessageAdded'
{ _hmaMessage :: Maybe Message
} deriving (Eq,Show,Data,Typeable,Generic)
historyMessageAdded
:: HistoryMessageAdded
historyMessageAdded =
HistoryMessageAdded'
{ _hmaMessage = Nothing
}
hmaMessage :: Lens' HistoryMessageAdded (Maybe Message)
hmaMessage
= lens _hmaMessage (\ s a -> s{_hmaMessage = a})
instance FromJSON HistoryMessageAdded where
parseJSON
= withObject "HistoryMessageAdded"
(\ o -> HistoryMessageAdded' <$> (o .:? "message"))
instance ToJSON HistoryMessageAdded where
toJSON HistoryMessageAdded'{..}
= object (catMaybes [("message" .=) <$> _hmaMessage])