module Network.Google.URLShortener.Types.Product where
import Network.Google.Prelude
import Network.Google.URLShortener.Types.Sum
data URL = URL'
{ _uStatus :: !(Maybe Text)
, _uKind :: !Text
, _uCreated :: !(Maybe Text)
, _uAnalytics :: !(Maybe AnalyticsSummary)
, _uLongURL :: !(Maybe Text)
, _uId :: !(Maybe Text)
} deriving (Eq,Show,Data,Typeable,Generic)
url
:: URL
url =
URL'
{ _uStatus = Nothing
, _uKind = "urlshortener#url"
, _uCreated = Nothing
, _uAnalytics = Nothing
, _uLongURL = Nothing
, _uId = Nothing
}
uStatus :: Lens' URL (Maybe Text)
uStatus = lens _uStatus (\ s a -> s{_uStatus = a})
uKind :: Lens' URL Text
uKind = lens _uKind (\ s a -> s{_uKind = a})
uCreated :: Lens' URL (Maybe Text)
uCreated = lens _uCreated (\ s a -> s{_uCreated = a})
uAnalytics :: Lens' URL (Maybe AnalyticsSummary)
uAnalytics
= lens _uAnalytics (\ s a -> s{_uAnalytics = a})
uLongURL :: Lens' URL (Maybe Text)
uLongURL = lens _uLongURL (\ s a -> s{_uLongURL = a})
uId :: Lens' URL (Maybe Text)
uId = lens _uId (\ s a -> s{_uId = a})
instance FromJSON URL where
parseJSON
= withObject "URL"
(\ o ->
URL' <$>
(o .:? "status") <*>
(o .:? "kind" .!= "urlshortener#url")
<*> (o .:? "created")
<*> (o .:? "analytics")
<*> (o .:? "longUrl")
<*> (o .:? "id"))
instance ToJSON URL where
toJSON URL'{..}
= object
(catMaybes
[("status" .=) <$> _uStatus, Just ("kind" .= _uKind),
("created" .=) <$> _uCreated,
("analytics" .=) <$> _uAnalytics,
("longUrl" .=) <$> _uLongURL, ("id" .=) <$> _uId])
data StringCount = StringCount'
{ _scCount :: !(Maybe (Textual Int64))
, _scId :: !(Maybe Text)
} deriving (Eq,Show,Data,Typeable,Generic)
stringCount
:: StringCount
stringCount =
StringCount'
{ _scCount = Nothing
, _scId = Nothing
}
scCount :: Lens' StringCount (Maybe Int64)
scCount
= lens _scCount (\ s a -> s{_scCount = a}) .
mapping _Coerce
scId :: Lens' StringCount (Maybe Text)
scId = lens _scId (\ s a -> s{_scId = a})
instance FromJSON StringCount where
parseJSON
= withObject "StringCount"
(\ o ->
StringCount' <$> (o .:? "count") <*> (o .:? "id"))
instance ToJSON StringCount where
toJSON StringCount'{..}
= object
(catMaybes
[("count" .=) <$> _scCount, ("id" .=) <$> _scId])
data AnalyticsSnapshot = AnalyticsSnapshot'
{ _asPlatforms :: !(Maybe [StringCount])
, _asShortURLClicks :: !(Maybe (Textual Int64))
, _asReferrers :: !(Maybe [StringCount])
, _asCountries :: !(Maybe [StringCount])
, _asLongURLClicks :: !(Maybe (Textual Int64))
, _asBrowsers :: !(Maybe [StringCount])
} deriving (Eq,Show,Data,Typeable,Generic)
analyticsSnapshot
:: AnalyticsSnapshot
analyticsSnapshot =
AnalyticsSnapshot'
{ _asPlatforms = Nothing
, _asShortURLClicks = Nothing
, _asReferrers = Nothing
, _asCountries = Nothing
, _asLongURLClicks = Nothing
, _asBrowsers = Nothing
}
asPlatforms :: Lens' AnalyticsSnapshot [StringCount]
asPlatforms
= lens _asPlatforms (\ s a -> s{_asPlatforms = a}) .
_Default
. _Coerce
asShortURLClicks :: Lens' AnalyticsSnapshot (Maybe Int64)
asShortURLClicks
= lens _asShortURLClicks
(\ s a -> s{_asShortURLClicks = a})
. mapping _Coerce
asReferrers :: Lens' AnalyticsSnapshot [StringCount]
asReferrers
= lens _asReferrers (\ s a -> s{_asReferrers = a}) .
_Default
. _Coerce
asCountries :: Lens' AnalyticsSnapshot [StringCount]
asCountries
= lens _asCountries (\ s a -> s{_asCountries = a}) .
_Default
. _Coerce
asLongURLClicks :: Lens' AnalyticsSnapshot (Maybe Int64)
asLongURLClicks
= lens _asLongURLClicks
(\ s a -> s{_asLongURLClicks = a})
. mapping _Coerce
asBrowsers :: Lens' AnalyticsSnapshot [StringCount]
asBrowsers
= lens _asBrowsers (\ s a -> s{_asBrowsers = a}) .
_Default
. _Coerce
instance FromJSON AnalyticsSnapshot where
parseJSON
= withObject "AnalyticsSnapshot"
(\ o ->
AnalyticsSnapshot' <$>
(o .:? "platforms" .!= mempty) <*>
(o .:? "shortUrlClicks")
<*> (o .:? "referrers" .!= mempty)
<*> (o .:? "countries" .!= mempty)
<*> (o .:? "longUrlClicks")
<*> (o .:? "browsers" .!= mempty))
instance ToJSON AnalyticsSnapshot where
toJSON AnalyticsSnapshot'{..}
= object
(catMaybes
[("platforms" .=) <$> _asPlatforms,
("shortUrlClicks" .=) <$> _asShortURLClicks,
("referrers" .=) <$> _asReferrers,
("countries" .=) <$> _asCountries,
("longUrlClicks" .=) <$> _asLongURLClicks,
("browsers" .=) <$> _asBrowsers])
data AnalyticsSummary = AnalyticsSummary'
{ _asWeek :: !(Maybe AnalyticsSnapshot)
, _asAllTime :: !(Maybe AnalyticsSnapshot)
, _asDay :: !(Maybe AnalyticsSnapshot)
, _asTwoHours :: !(Maybe AnalyticsSnapshot)
, _asMonth :: !(Maybe AnalyticsSnapshot)
} deriving (Eq,Show,Data,Typeable,Generic)
analyticsSummary
:: AnalyticsSummary
analyticsSummary =
AnalyticsSummary'
{ _asWeek = Nothing
, _asAllTime = Nothing
, _asDay = Nothing
, _asTwoHours = Nothing
, _asMonth = Nothing
}
asWeek :: Lens' AnalyticsSummary (Maybe AnalyticsSnapshot)
asWeek = lens _asWeek (\ s a -> s{_asWeek = a})
asAllTime :: Lens' AnalyticsSummary (Maybe AnalyticsSnapshot)
asAllTime
= lens _asAllTime (\ s a -> s{_asAllTime = a})
asDay :: Lens' AnalyticsSummary (Maybe AnalyticsSnapshot)
asDay = lens _asDay (\ s a -> s{_asDay = a})
asTwoHours :: Lens' AnalyticsSummary (Maybe AnalyticsSnapshot)
asTwoHours
= lens _asTwoHours (\ s a -> s{_asTwoHours = a})
asMonth :: Lens' AnalyticsSummary (Maybe AnalyticsSnapshot)
asMonth = lens _asMonth (\ s a -> s{_asMonth = a})
instance FromJSON AnalyticsSummary where
parseJSON
= withObject "AnalyticsSummary"
(\ o ->
AnalyticsSummary' <$>
(o .:? "week") <*> (o .:? "allTime") <*>
(o .:? "day")
<*> (o .:? "twoHours")
<*> (o .:? "month"))
instance ToJSON AnalyticsSummary where
toJSON AnalyticsSummary'{..}
= object
(catMaybes
[("week" .=) <$> _asWeek,
("allTime" .=) <$> _asAllTime, ("day" .=) <$> _asDay,
("twoHours" .=) <$> _asTwoHours,
("month" .=) <$> _asMonth])
data URLHistory = URLHistory'
{ _uhTotalItems :: !(Maybe (Textual Int32))
, _uhNextPageToken :: !(Maybe Text)
, _uhItemsPerPage :: !(Maybe (Textual Int32))
, _uhKind :: !Text
, _uhItems :: !(Maybe [URL])
} deriving (Eq,Show,Data,Typeable,Generic)
urlHistory
:: URLHistory
urlHistory =
URLHistory'
{ _uhTotalItems = Nothing
, _uhNextPageToken = Nothing
, _uhItemsPerPage = Nothing
, _uhKind = "urlshortener#urlHistory"
, _uhItems = Nothing
}
uhTotalItems :: Lens' URLHistory (Maybe Int32)
uhTotalItems
= lens _uhTotalItems (\ s a -> s{_uhTotalItems = a})
. mapping _Coerce
uhNextPageToken :: Lens' URLHistory (Maybe Text)
uhNextPageToken
= lens _uhNextPageToken
(\ s a -> s{_uhNextPageToken = a})
uhItemsPerPage :: Lens' URLHistory (Maybe Int32)
uhItemsPerPage
= lens _uhItemsPerPage
(\ s a -> s{_uhItemsPerPage = a})
. mapping _Coerce
uhKind :: Lens' URLHistory Text
uhKind = lens _uhKind (\ s a -> s{_uhKind = a})
uhItems :: Lens' URLHistory [URL]
uhItems
= lens _uhItems (\ s a -> s{_uhItems = a}) . _Default
. _Coerce
instance FromJSON URLHistory where
parseJSON
= withObject "URLHistory"
(\ o ->
URLHistory' <$>
(o .:? "totalItems") <*> (o .:? "nextPageToken") <*>
(o .:? "itemsPerPage")
<*> (o .:? "kind" .!= "urlshortener#urlHistory")
<*> (o .:? "items" .!= mempty))
instance ToJSON URLHistory where
toJSON URLHistory'{..}
= object
(catMaybes
[("totalItems" .=) <$> _uhTotalItems,
("nextPageToken" .=) <$> _uhNextPageToken,
("itemsPerPage" .=) <$> _uhItemsPerPage,
Just ("kind" .= _uhKind), ("items" .=) <$> _uhItems])