{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.IoT1ClickDevices.ClaimDevicesByClaimCode
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Adds device(s) to your account (i.e., claim one or more devices) if and
-- only if you received a claim code with the device(s).
module Amazonka.IoT1ClickDevices.ClaimDevicesByClaimCode
  ( -- * Creating a Request
    ClaimDevicesByClaimCode (..),
    newClaimDevicesByClaimCode,

    -- * Request Lenses
    claimDevicesByClaimCode_claimCode,

    -- * Destructuring the Response
    ClaimDevicesByClaimCodeResponse (..),
    newClaimDevicesByClaimCodeResponse,

    -- * Response Lenses
    claimDevicesByClaimCodeResponse_claimCode,
    claimDevicesByClaimCodeResponse_total,
    claimDevicesByClaimCodeResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.IoT1ClickDevices.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newClaimDevicesByClaimCode' smart constructor.
data ClaimDevicesByClaimCode = ClaimDevicesByClaimCode'
  { -- | The claim code, starting with \"C-\", as provided by the device
    -- manufacturer.
    ClaimDevicesByClaimCode -> Text
claimCode :: Prelude.Text
  }
  deriving (ClaimDevicesByClaimCode -> ClaimDevicesByClaimCode -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ClaimDevicesByClaimCode -> ClaimDevicesByClaimCode -> Bool
$c/= :: ClaimDevicesByClaimCode -> ClaimDevicesByClaimCode -> Bool
== :: ClaimDevicesByClaimCode -> ClaimDevicesByClaimCode -> Bool
$c== :: ClaimDevicesByClaimCode -> ClaimDevicesByClaimCode -> Bool
Prelude.Eq, ReadPrec [ClaimDevicesByClaimCode]
ReadPrec ClaimDevicesByClaimCode
Int -> ReadS ClaimDevicesByClaimCode
ReadS [ClaimDevicesByClaimCode]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ClaimDevicesByClaimCode]
$creadListPrec :: ReadPrec [ClaimDevicesByClaimCode]
readPrec :: ReadPrec ClaimDevicesByClaimCode
$creadPrec :: ReadPrec ClaimDevicesByClaimCode
readList :: ReadS [ClaimDevicesByClaimCode]
$creadList :: ReadS [ClaimDevicesByClaimCode]
readsPrec :: Int -> ReadS ClaimDevicesByClaimCode
$creadsPrec :: Int -> ReadS ClaimDevicesByClaimCode
Prelude.Read, Int -> ClaimDevicesByClaimCode -> ShowS
[ClaimDevicesByClaimCode] -> ShowS
ClaimDevicesByClaimCode -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ClaimDevicesByClaimCode] -> ShowS
$cshowList :: [ClaimDevicesByClaimCode] -> ShowS
show :: ClaimDevicesByClaimCode -> String
$cshow :: ClaimDevicesByClaimCode -> String
showsPrec :: Int -> ClaimDevicesByClaimCode -> ShowS
$cshowsPrec :: Int -> ClaimDevicesByClaimCode -> ShowS
Prelude.Show, forall x. Rep ClaimDevicesByClaimCode x -> ClaimDevicesByClaimCode
forall x. ClaimDevicesByClaimCode -> Rep ClaimDevicesByClaimCode x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ClaimDevicesByClaimCode x -> ClaimDevicesByClaimCode
$cfrom :: forall x. ClaimDevicesByClaimCode -> Rep ClaimDevicesByClaimCode x
Prelude.Generic)

-- |
-- Create a value of 'ClaimDevicesByClaimCode' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'claimCode', 'claimDevicesByClaimCode_claimCode' - The claim code, starting with \"C-\", as provided by the device
-- manufacturer.
newClaimDevicesByClaimCode ::
  -- | 'claimCode'
  Prelude.Text ->
  ClaimDevicesByClaimCode
newClaimDevicesByClaimCode :: Text -> ClaimDevicesByClaimCode
newClaimDevicesByClaimCode Text
pClaimCode_ =
  ClaimDevicesByClaimCode' {$sel:claimCode:ClaimDevicesByClaimCode' :: Text
claimCode = Text
pClaimCode_}

-- | The claim code, starting with \"C-\", as provided by the device
-- manufacturer.
claimDevicesByClaimCode_claimCode :: Lens.Lens' ClaimDevicesByClaimCode Prelude.Text
claimDevicesByClaimCode_claimCode :: Lens' ClaimDevicesByClaimCode Text
claimDevicesByClaimCode_claimCode = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ClaimDevicesByClaimCode' {Text
claimCode :: Text
$sel:claimCode:ClaimDevicesByClaimCode' :: ClaimDevicesByClaimCode -> Text
claimCode} -> Text
claimCode) (\s :: ClaimDevicesByClaimCode
s@ClaimDevicesByClaimCode' {} Text
a -> ClaimDevicesByClaimCode
s {$sel:claimCode:ClaimDevicesByClaimCode' :: Text
claimCode = Text
a} :: ClaimDevicesByClaimCode)

instance Core.AWSRequest ClaimDevicesByClaimCode where
  type
    AWSResponse ClaimDevicesByClaimCode =
      ClaimDevicesByClaimCodeResponse
  request :: (Service -> Service)
-> ClaimDevicesByClaimCode -> Request ClaimDevicesByClaimCode
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.putJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy ClaimDevicesByClaimCode
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse ClaimDevicesByClaimCode)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe Text -> Maybe Int -> Int -> ClaimDevicesByClaimCodeResponse
ClaimDevicesByClaimCodeResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"claimCode")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"total")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable ClaimDevicesByClaimCode where
  hashWithSalt :: Int -> ClaimDevicesByClaimCode -> Int
hashWithSalt Int
_salt ClaimDevicesByClaimCode' {Text
claimCode :: Text
$sel:claimCode:ClaimDevicesByClaimCode' :: ClaimDevicesByClaimCode -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
claimCode

instance Prelude.NFData ClaimDevicesByClaimCode where
  rnf :: ClaimDevicesByClaimCode -> ()
rnf ClaimDevicesByClaimCode' {Text
claimCode :: Text
$sel:claimCode:ClaimDevicesByClaimCode' :: ClaimDevicesByClaimCode -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
claimCode

instance Data.ToHeaders ClaimDevicesByClaimCode where
  toHeaders :: ClaimDevicesByClaimCode -> ResponseHeaders
toHeaders =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToJSON ClaimDevicesByClaimCode where
  toJSON :: ClaimDevicesByClaimCode -> Value
toJSON = forall a b. a -> b -> a
Prelude.const (Object -> Value
Data.Object forall a. Monoid a => a
Prelude.mempty)

instance Data.ToPath ClaimDevicesByClaimCode where
  toPath :: ClaimDevicesByClaimCode -> ByteString
toPath ClaimDevicesByClaimCode' {Text
claimCode :: Text
$sel:claimCode:ClaimDevicesByClaimCode' :: ClaimDevicesByClaimCode -> Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat [ByteString
"/claims/", forall a. ToByteString a => a -> ByteString
Data.toBS Text
claimCode]

instance Data.ToQuery ClaimDevicesByClaimCode where
  toQuery :: ClaimDevicesByClaimCode -> QueryString
toQuery = forall a b. a -> b -> a
Prelude.const forall a. Monoid a => a
Prelude.mempty

-- | /See:/ 'newClaimDevicesByClaimCodeResponse' smart constructor.
data ClaimDevicesByClaimCodeResponse = ClaimDevicesByClaimCodeResponse'
  { -- | The claim code provided by the device manufacturer.
    ClaimDevicesByClaimCodeResponse -> Maybe Text
claimCode :: Prelude.Maybe Prelude.Text,
    -- | The total number of devices associated with the claim code that has been
    -- processed in the claim request.
    ClaimDevicesByClaimCodeResponse -> Maybe Int
total :: Prelude.Maybe Prelude.Int,
    -- | The response's http status code.
    ClaimDevicesByClaimCodeResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (ClaimDevicesByClaimCodeResponse
-> ClaimDevicesByClaimCodeResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ClaimDevicesByClaimCodeResponse
-> ClaimDevicesByClaimCodeResponse -> Bool
$c/= :: ClaimDevicesByClaimCodeResponse
-> ClaimDevicesByClaimCodeResponse -> Bool
== :: ClaimDevicesByClaimCodeResponse
-> ClaimDevicesByClaimCodeResponse -> Bool
$c== :: ClaimDevicesByClaimCodeResponse
-> ClaimDevicesByClaimCodeResponse -> Bool
Prelude.Eq, ReadPrec [ClaimDevicesByClaimCodeResponse]
ReadPrec ClaimDevicesByClaimCodeResponse
Int -> ReadS ClaimDevicesByClaimCodeResponse
ReadS [ClaimDevicesByClaimCodeResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ClaimDevicesByClaimCodeResponse]
$creadListPrec :: ReadPrec [ClaimDevicesByClaimCodeResponse]
readPrec :: ReadPrec ClaimDevicesByClaimCodeResponse
$creadPrec :: ReadPrec ClaimDevicesByClaimCodeResponse
readList :: ReadS [ClaimDevicesByClaimCodeResponse]
$creadList :: ReadS [ClaimDevicesByClaimCodeResponse]
readsPrec :: Int -> ReadS ClaimDevicesByClaimCodeResponse
$creadsPrec :: Int -> ReadS ClaimDevicesByClaimCodeResponse
Prelude.Read, Int -> ClaimDevicesByClaimCodeResponse -> ShowS
[ClaimDevicesByClaimCodeResponse] -> ShowS
ClaimDevicesByClaimCodeResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ClaimDevicesByClaimCodeResponse] -> ShowS
$cshowList :: [ClaimDevicesByClaimCodeResponse] -> ShowS
show :: ClaimDevicesByClaimCodeResponse -> String
$cshow :: ClaimDevicesByClaimCodeResponse -> String
showsPrec :: Int -> ClaimDevicesByClaimCodeResponse -> ShowS
$cshowsPrec :: Int -> ClaimDevicesByClaimCodeResponse -> ShowS
Prelude.Show, forall x.
Rep ClaimDevicesByClaimCodeResponse x
-> ClaimDevicesByClaimCodeResponse
forall x.
ClaimDevicesByClaimCodeResponse
-> Rep ClaimDevicesByClaimCodeResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ClaimDevicesByClaimCodeResponse x
-> ClaimDevicesByClaimCodeResponse
$cfrom :: forall x.
ClaimDevicesByClaimCodeResponse
-> Rep ClaimDevicesByClaimCodeResponse x
Prelude.Generic)

-- |
-- Create a value of 'ClaimDevicesByClaimCodeResponse' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'claimCode', 'claimDevicesByClaimCodeResponse_claimCode' - The claim code provided by the device manufacturer.
--
-- 'total', 'claimDevicesByClaimCodeResponse_total' - The total number of devices associated with the claim code that has been
-- processed in the claim request.
--
-- 'httpStatus', 'claimDevicesByClaimCodeResponse_httpStatus' - The response's http status code.
newClaimDevicesByClaimCodeResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ClaimDevicesByClaimCodeResponse
newClaimDevicesByClaimCodeResponse :: Int -> ClaimDevicesByClaimCodeResponse
newClaimDevicesByClaimCodeResponse Int
pHttpStatus_ =
  ClaimDevicesByClaimCodeResponse'
    { $sel:claimCode:ClaimDevicesByClaimCodeResponse' :: Maybe Text
claimCode =
        forall a. Maybe a
Prelude.Nothing,
      $sel:total:ClaimDevicesByClaimCodeResponse' :: Maybe Int
total = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ClaimDevicesByClaimCodeResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The claim code provided by the device manufacturer.
claimDevicesByClaimCodeResponse_claimCode :: Lens.Lens' ClaimDevicesByClaimCodeResponse (Prelude.Maybe Prelude.Text)
claimDevicesByClaimCodeResponse_claimCode :: Lens' ClaimDevicesByClaimCodeResponse (Maybe Text)
claimDevicesByClaimCodeResponse_claimCode = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ClaimDevicesByClaimCodeResponse' {Maybe Text
claimCode :: Maybe Text
$sel:claimCode:ClaimDevicesByClaimCodeResponse' :: ClaimDevicesByClaimCodeResponse -> Maybe Text
claimCode} -> Maybe Text
claimCode) (\s :: ClaimDevicesByClaimCodeResponse
s@ClaimDevicesByClaimCodeResponse' {} Maybe Text
a -> ClaimDevicesByClaimCodeResponse
s {$sel:claimCode:ClaimDevicesByClaimCodeResponse' :: Maybe Text
claimCode = Maybe Text
a} :: ClaimDevicesByClaimCodeResponse)

-- | The total number of devices associated with the claim code that has been
-- processed in the claim request.
claimDevicesByClaimCodeResponse_total :: Lens.Lens' ClaimDevicesByClaimCodeResponse (Prelude.Maybe Prelude.Int)
claimDevicesByClaimCodeResponse_total :: Lens' ClaimDevicesByClaimCodeResponse (Maybe Int)
claimDevicesByClaimCodeResponse_total = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ClaimDevicesByClaimCodeResponse' {Maybe Int
total :: Maybe Int
$sel:total:ClaimDevicesByClaimCodeResponse' :: ClaimDevicesByClaimCodeResponse -> Maybe Int
total} -> Maybe Int
total) (\s :: ClaimDevicesByClaimCodeResponse
s@ClaimDevicesByClaimCodeResponse' {} Maybe Int
a -> ClaimDevicesByClaimCodeResponse
s {$sel:total:ClaimDevicesByClaimCodeResponse' :: Maybe Int
total = Maybe Int
a} :: ClaimDevicesByClaimCodeResponse)

-- | The response's http status code.
claimDevicesByClaimCodeResponse_httpStatus :: Lens.Lens' ClaimDevicesByClaimCodeResponse Prelude.Int
claimDevicesByClaimCodeResponse_httpStatus :: Lens' ClaimDevicesByClaimCodeResponse Int
claimDevicesByClaimCodeResponse_httpStatus = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ClaimDevicesByClaimCodeResponse' {Int
httpStatus :: Int
$sel:httpStatus:ClaimDevicesByClaimCodeResponse' :: ClaimDevicesByClaimCodeResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: ClaimDevicesByClaimCodeResponse
s@ClaimDevicesByClaimCodeResponse' {} Int
a -> ClaimDevicesByClaimCodeResponse
s {$sel:httpStatus:ClaimDevicesByClaimCodeResponse' :: Int
httpStatus = Int
a} :: ClaimDevicesByClaimCodeResponse)

instance
  Prelude.NFData
    ClaimDevicesByClaimCodeResponse
  where
  rnf :: ClaimDevicesByClaimCodeResponse -> ()
rnf ClaimDevicesByClaimCodeResponse' {Int
Maybe Int
Maybe Text
httpStatus :: Int
total :: Maybe Int
claimCode :: Maybe Text
$sel:httpStatus:ClaimDevicesByClaimCodeResponse' :: ClaimDevicesByClaimCodeResponse -> Int
$sel:total:ClaimDevicesByClaimCodeResponse' :: ClaimDevicesByClaimCodeResponse -> Maybe Int
$sel:claimCode:ClaimDevicesByClaimCodeResponse' :: ClaimDevicesByClaimCodeResponse -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
claimCode
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Int
total
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus