module Network.AWS.CognitoSync.RegisterDevice
(
registerDevice
, RegisterDevice
, rdIdentityPoolId
, rdIdentityId
, rdPlatform
, rdToken
, registerDeviceResponse
, RegisterDeviceResponse
, rdrsDeviceId
, rdrsStatus
) where
import Network.AWS.CognitoSync.Types
import Network.AWS.CognitoSync.Types.Product
import Network.AWS.Prelude
import Network.AWS.Request
import Network.AWS.Response
data RegisterDevice = RegisterDevice'
{ _rdIdentityPoolId :: !Text
, _rdIdentityId :: !Text
, _rdPlatform :: !Platform
, _rdToken :: !Text
} deriving (Eq,Read,Show,Data,Typeable,Generic)
registerDevice
:: Text
-> Text
-> Platform
-> Text
-> RegisterDevice
registerDevice pIdentityPoolId_ pIdentityId_ pPlatform_ pToken_ =
RegisterDevice'
{ _rdIdentityPoolId = pIdentityPoolId_
, _rdIdentityId = pIdentityId_
, _rdPlatform = pPlatform_
, _rdToken = pToken_
}
rdIdentityPoolId :: Lens' RegisterDevice Text
rdIdentityPoolId = lens _rdIdentityPoolId (\ s a -> s{_rdIdentityPoolId = a});
rdIdentityId :: Lens' RegisterDevice Text
rdIdentityId = lens _rdIdentityId (\ s a -> s{_rdIdentityId = a});
rdPlatform :: Lens' RegisterDevice Platform
rdPlatform = lens _rdPlatform (\ s a -> s{_rdPlatform = a});
rdToken :: Lens' RegisterDevice Text
rdToken = lens _rdToken (\ s a -> s{_rdToken = a});
instance AWSRequest RegisterDevice where
type Rs RegisterDevice = RegisterDeviceResponse
request = postJSON cognitoSync
response
= receiveJSON
(\ s h x ->
RegisterDeviceResponse' <$>
(x .?> "DeviceId") <*> (pure (fromEnum s)))
instance ToHeaders RegisterDevice where
toHeaders
= const
(mconcat
["Content-Type" =#
("application/x-amz-json-1.1" :: ByteString)])
instance ToJSON RegisterDevice where
toJSON RegisterDevice'{..}
= object
(catMaybes
[Just ("Platform" .= _rdPlatform),
Just ("Token" .= _rdToken)])
instance ToPath RegisterDevice where
toPath RegisterDevice'{..}
= mconcat
["/identitypools/", toBS _rdIdentityPoolId,
"/identity/", toBS _rdIdentityId, "/device"]
instance ToQuery RegisterDevice where
toQuery = const mempty
data RegisterDeviceResponse = RegisterDeviceResponse'
{ _rdrsDeviceId :: !(Maybe Text)
, _rdrsStatus :: !Int
} deriving (Eq,Read,Show,Data,Typeable,Generic)
registerDeviceResponse
:: Int
-> RegisterDeviceResponse
registerDeviceResponse pStatus_ =
RegisterDeviceResponse'
{ _rdrsDeviceId = Nothing
, _rdrsStatus = pStatus_
}
rdrsDeviceId :: Lens' RegisterDeviceResponse (Maybe Text)
rdrsDeviceId = lens _rdrsDeviceId (\ s a -> s{_rdrsDeviceId = a});
rdrsStatus :: Lens' RegisterDeviceResponse Int
rdrsStatus = lens _rdrsStatus (\ s a -> s{_rdrsStatus = a});