module Network.Google.Manufacturers.Types.Product where
import Network.Google.Manufacturers.Types.Sum
import Network.Google.Prelude
data Attributes = Attributes'
{ _aProductName :: !(Maybe Text)
, _aProductLine :: !(Maybe Text)
, _aProductType :: !(Maybe [Text])
, _aBrand :: !(Maybe Text)
, _aGtin :: !(Maybe [Text])
, _aTitle :: !(Maybe Text)
, _aMpn :: !(Maybe Text)
, _aProductPageURL :: !(Maybe Text)
} deriving (Eq,Show,Data,Typeable,Generic)
attributes
:: Attributes
attributes =
Attributes'
{ _aProductName = Nothing
, _aProductLine = Nothing
, _aProductType = Nothing
, _aBrand = Nothing
, _aGtin = Nothing
, _aTitle = Nothing
, _aMpn = Nothing
, _aProductPageURL = Nothing
}
aProductName :: Lens' Attributes (Maybe Text)
aProductName
= lens _aProductName (\ s a -> s{_aProductName = a})
aProductLine :: Lens' Attributes (Maybe Text)
aProductLine
= lens _aProductLine (\ s a -> s{_aProductLine = a})
aProductType :: Lens' Attributes [Text]
aProductType
= lens _aProductType (\ s a -> s{_aProductType = a})
. _Default
. _Coerce
aBrand :: Lens' Attributes (Maybe Text)
aBrand = lens _aBrand (\ s a -> s{_aBrand = a})
aGtin :: Lens' Attributes [Text]
aGtin
= lens _aGtin (\ s a -> s{_aGtin = a}) . _Default .
_Coerce
aTitle :: Lens' Attributes (Maybe Text)
aTitle = lens _aTitle (\ s a -> s{_aTitle = a})
aMpn :: Lens' Attributes (Maybe Text)
aMpn = lens _aMpn (\ s a -> s{_aMpn = a})
aProductPageURL :: Lens' Attributes (Maybe Text)
aProductPageURL
= lens _aProductPageURL
(\ s a -> s{_aProductPageURL = a})
instance FromJSON Attributes where
parseJSON
= withObject "Attributes"
(\ o ->
Attributes' <$>
(o .:? "productName") <*> (o .:? "productLine") <*>
(o .:? "productType" .!= mempty)
<*> (o .:? "brand")
<*> (o .:? "gtin" .!= mempty)
<*> (o .:? "title")
<*> (o .:? "mpn")
<*> (o .:? "productPageUrl"))
instance ToJSON Attributes where
toJSON Attributes'{..}
= object
(catMaybes
[("productName" .=) <$> _aProductName,
("productLine" .=) <$> _aProductLine,
("productType" .=) <$> _aProductType,
("brand" .=) <$> _aBrand, ("gtin" .=) <$> _aGtin,
("title" .=) <$> _aTitle, ("mpn" .=) <$> _aMpn,
("productPageUrl" .=) <$> _aProductPageURL])
data Product = Product'
{ _pParent :: !(Maybe Text)
, _pManuallyDeletedAttributes :: !(Maybe [Text])
, _pTargetCountry :: !(Maybe Text)
, _pManuallyProvidedAttributes :: !(Maybe Attributes)
, _pName :: !(Maybe Text)
, _pIssues :: !(Maybe [Issue])
, _pUploadedAttributes :: !(Maybe Attributes)
, _pContentLanguage :: !(Maybe Text)
, _pFinalAttributes :: !(Maybe Attributes)
, _pProductId :: !(Maybe Text)
} deriving (Eq,Show,Data,Typeable,Generic)
product
:: Product
product =
Product'
{ _pParent = Nothing
, _pManuallyDeletedAttributes = Nothing
, _pTargetCountry = Nothing
, _pManuallyProvidedAttributes = Nothing
, _pName = Nothing
, _pIssues = Nothing
, _pUploadedAttributes = Nothing
, _pContentLanguage = Nothing
, _pFinalAttributes = Nothing
, _pProductId = Nothing
}
pParent :: Lens' Product (Maybe Text)
pParent = lens _pParent (\ s a -> s{_pParent = a})
pManuallyDeletedAttributes :: Lens' Product [Text]
pManuallyDeletedAttributes
= lens _pManuallyDeletedAttributes
(\ s a -> s{_pManuallyDeletedAttributes = a})
. _Default
. _Coerce
pTargetCountry :: Lens' Product (Maybe Text)
pTargetCountry
= lens _pTargetCountry
(\ s a -> s{_pTargetCountry = a})
pManuallyProvidedAttributes :: Lens' Product (Maybe Attributes)
pManuallyProvidedAttributes
= lens _pManuallyProvidedAttributes
(\ s a -> s{_pManuallyProvidedAttributes = a})
pName :: Lens' Product (Maybe Text)
pName = lens _pName (\ s a -> s{_pName = a})
pIssues :: Lens' Product [Issue]
pIssues
= lens _pIssues (\ s a -> s{_pIssues = a}) . _Default
. _Coerce
pUploadedAttributes :: Lens' Product (Maybe Attributes)
pUploadedAttributes
= lens _pUploadedAttributes
(\ s a -> s{_pUploadedAttributes = a})
pContentLanguage :: Lens' Product (Maybe Text)
pContentLanguage
= lens _pContentLanguage
(\ s a -> s{_pContentLanguage = a})
pFinalAttributes :: Lens' Product (Maybe Attributes)
pFinalAttributes
= lens _pFinalAttributes
(\ s a -> s{_pFinalAttributes = a})
pProductId :: Lens' Product (Maybe Text)
pProductId
= lens _pProductId (\ s a -> s{_pProductId = a})
instance FromJSON Product where
parseJSON
= withObject "Product"
(\ o ->
Product' <$>
(o .:? "parent") <*>
(o .:? "manuallyDeletedAttributes" .!= mempty)
<*> (o .:? "targetCountry")
<*> (o .:? "manuallyProvidedAttributes")
<*> (o .:? "name")
<*> (o .:? "issues" .!= mempty)
<*> (o .:? "uploadedAttributes")
<*> (o .:? "contentLanguage")
<*> (o .:? "finalAttributes")
<*> (o .:? "productId"))
instance ToJSON Product where
toJSON Product'{..}
= object
(catMaybes
[("parent" .=) <$> _pParent,
("manuallyDeletedAttributes" .=) <$>
_pManuallyDeletedAttributes,
("targetCountry" .=) <$> _pTargetCountry,
("manuallyProvidedAttributes" .=) <$>
_pManuallyProvidedAttributes,
("name" .=) <$> _pName, ("issues" .=) <$> _pIssues,
("uploadedAttributes" .=) <$> _pUploadedAttributes,
("contentLanguage" .=) <$> _pContentLanguage,
("finalAttributes" .=) <$> _pFinalAttributes,
("productId" .=) <$> _pProductId])
data Issue = Issue'
{ _iAttribute :: !(Maybe Text)
, _iSeverity :: !(Maybe IssueSeverity)
, _iType :: !(Maybe Text)
, _iDescription :: !(Maybe Text)
} deriving (Eq,Show,Data,Typeable,Generic)
issue
:: Issue
issue =
Issue'
{ _iAttribute = Nothing
, _iSeverity = Nothing
, _iType = Nothing
, _iDescription = Nothing
}
iAttribute :: Lens' Issue (Maybe Text)
iAttribute
= lens _iAttribute (\ s a -> s{_iAttribute = a})
iSeverity :: Lens' Issue (Maybe IssueSeverity)
iSeverity
= lens _iSeverity (\ s a -> s{_iSeverity = a})
iType :: Lens' Issue (Maybe Text)
iType = lens _iType (\ s a -> s{_iType = a})
iDescription :: Lens' Issue (Maybe Text)
iDescription
= lens _iDescription (\ s a -> s{_iDescription = a})
instance FromJSON Issue where
parseJSON
= withObject "Issue"
(\ o ->
Issue' <$>
(o .:? "attribute") <*> (o .:? "severity") <*>
(o .:? "type")
<*> (o .:? "description"))
instance ToJSON Issue where
toJSON Issue'{..}
= object
(catMaybes
[("attribute" .=) <$> _iAttribute,
("severity" .=) <$> _iSeverity,
("type" .=) <$> _iType,
("description" .=) <$> _iDescription])
data ListProductsResponse = ListProductsResponse'
{ _lprNextPageToken :: !(Maybe Text)
, _lprProducts :: !(Maybe [Product])
} deriving (Eq,Show,Data,Typeable,Generic)
listProductsResponse
:: ListProductsResponse
listProductsResponse =
ListProductsResponse'
{ _lprNextPageToken = Nothing
, _lprProducts = Nothing
}
lprNextPageToken :: Lens' ListProductsResponse (Maybe Text)
lprNextPageToken
= lens _lprNextPageToken
(\ s a -> s{_lprNextPageToken = a})
lprProducts :: Lens' ListProductsResponse [Product]
lprProducts
= lens _lprProducts (\ s a -> s{_lprProducts = a}) .
_Default
. _Coerce
instance FromJSON ListProductsResponse where
parseJSON
= withObject "ListProductsResponse"
(\ o ->
ListProductsResponse' <$>
(o .:? "nextPageToken") <*>
(o .:? "products" .!= mempty))
instance ToJSON ListProductsResponse where
toJSON ListProductsResponse'{..}
= object
(catMaybes
[("nextPageToken" .=) <$> _lprNextPageToken,
("products" .=) <$> _lprProducts])