module Network.AWS.CognitoSync.RegisterDevice
(
RegisterDevice
, registerDevice
, rdIdentityId
, rdIdentityPoolId
, rdPlatform
, rdToken
, RegisterDeviceResponse
, registerDeviceResponse
, rdrDeviceId
) where
import Network.AWS.Prelude
import Network.AWS.Request.RestJSON
import Network.AWS.CognitoSync.Types
import qualified GHC.Exts
data RegisterDevice = RegisterDevice
{ _rdIdentityId :: Text
, _rdIdentityPoolId :: Text
, _rdPlatform :: Platform
, _rdToken :: Text
} deriving (Eq, Show)
registerDevice :: Text
-> Text
-> Platform
-> Text
-> RegisterDevice
registerDevice p1 p2 p3 p4 = RegisterDevice
{ _rdIdentityPoolId = p1
, _rdIdentityId = p2
, _rdPlatform = p3
, _rdToken = p4
}
rdIdentityId :: Lens' RegisterDevice Text
rdIdentityId = lens _rdIdentityId (\s a -> s { _rdIdentityId = a })
rdIdentityPoolId :: Lens' RegisterDevice Text
rdIdentityPoolId = lens _rdIdentityPoolId (\s a -> s { _rdIdentityPoolId = 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 })
newtype RegisterDeviceResponse = RegisterDeviceResponse
{ _rdrDeviceId :: Maybe Text
} deriving (Eq, Ord, Show, Monoid)
registerDeviceResponse :: RegisterDeviceResponse
registerDeviceResponse = RegisterDeviceResponse
{ _rdrDeviceId = Nothing
}
rdrDeviceId :: Lens' RegisterDeviceResponse (Maybe Text)
rdrDeviceId = lens _rdrDeviceId (\s a -> s { _rdrDeviceId = a })
instance ToPath RegisterDevice where
toPath RegisterDevice{..} = mconcat
[ "/identitypools/"
, toText _rdIdentityPoolId
, "/identity/"
, toText _rdIdentityId
, "/device"
]
instance ToQuery RegisterDevice where
toQuery = const mempty
instance ToHeaders RegisterDevice
instance ToJSON RegisterDevice where
toJSON RegisterDevice{..} = object
[ "Platform" .= _rdPlatform
, "Token" .= _rdToken
]
instance AWSRequest RegisterDevice where
type Sv RegisterDevice = CognitoSync
type Rs RegisterDevice = RegisterDeviceResponse
request = post
response = jsonResponse
instance FromJSON RegisterDeviceResponse where
parseJSON = withObject "RegisterDeviceResponse" $ \o -> RegisterDeviceResponse
<$> o .:? "DeviceId"