{-# 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.Chime.GetPhoneNumberOrder
-- Copyright   : (c) 2013-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Retrieves details for the specified phone number order, such as the
-- order creation timestamp, phone numbers in E.164 format, product type,
-- and order status.
module Amazonka.Chime.GetPhoneNumberOrder
  ( -- * Creating a Request
    GetPhoneNumberOrder (..),
    newGetPhoneNumberOrder,

    -- * Request Lenses
    getPhoneNumberOrder_phoneNumberOrderId,

    -- * Destructuring the Response
    GetPhoneNumberOrderResponse (..),
    newGetPhoneNumberOrderResponse,

    -- * Response Lenses
    getPhoneNumberOrderResponse_phoneNumberOrder,
    getPhoneNumberOrderResponse_httpStatus,
  )
where

import Amazonka.Chime.Types
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newGetPhoneNumberOrder' smart constructor.
data GetPhoneNumberOrder = GetPhoneNumberOrder'
  { -- | The ID for the phone number order.
    GetPhoneNumberOrder -> Text
phoneNumberOrderId :: Prelude.Text
  }
  deriving (GetPhoneNumberOrder -> GetPhoneNumberOrder -> Bool
(GetPhoneNumberOrder -> GetPhoneNumberOrder -> Bool)
-> (GetPhoneNumberOrder -> GetPhoneNumberOrder -> Bool)
-> Eq GetPhoneNumberOrder
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetPhoneNumberOrder -> GetPhoneNumberOrder -> Bool
$c/= :: GetPhoneNumberOrder -> GetPhoneNumberOrder -> Bool
== :: GetPhoneNumberOrder -> GetPhoneNumberOrder -> Bool
$c== :: GetPhoneNumberOrder -> GetPhoneNumberOrder -> Bool
Prelude.Eq, ReadPrec [GetPhoneNumberOrder]
ReadPrec GetPhoneNumberOrder
Int -> ReadS GetPhoneNumberOrder
ReadS [GetPhoneNumberOrder]
(Int -> ReadS GetPhoneNumberOrder)
-> ReadS [GetPhoneNumberOrder]
-> ReadPrec GetPhoneNumberOrder
-> ReadPrec [GetPhoneNumberOrder]
-> Read GetPhoneNumberOrder
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetPhoneNumberOrder]
$creadListPrec :: ReadPrec [GetPhoneNumberOrder]
readPrec :: ReadPrec GetPhoneNumberOrder
$creadPrec :: ReadPrec GetPhoneNumberOrder
readList :: ReadS [GetPhoneNumberOrder]
$creadList :: ReadS [GetPhoneNumberOrder]
readsPrec :: Int -> ReadS GetPhoneNumberOrder
$creadsPrec :: Int -> ReadS GetPhoneNumberOrder
Prelude.Read, Int -> GetPhoneNumberOrder -> ShowS
[GetPhoneNumberOrder] -> ShowS
GetPhoneNumberOrder -> String
(Int -> GetPhoneNumberOrder -> ShowS)
-> (GetPhoneNumberOrder -> String)
-> ([GetPhoneNumberOrder] -> ShowS)
-> Show GetPhoneNumberOrder
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetPhoneNumberOrder] -> ShowS
$cshowList :: [GetPhoneNumberOrder] -> ShowS
show :: GetPhoneNumberOrder -> String
$cshow :: GetPhoneNumberOrder -> String
showsPrec :: Int -> GetPhoneNumberOrder -> ShowS
$cshowsPrec :: Int -> GetPhoneNumberOrder -> ShowS
Prelude.Show, (forall x. GetPhoneNumberOrder -> Rep GetPhoneNumberOrder x)
-> (forall x. Rep GetPhoneNumberOrder x -> GetPhoneNumberOrder)
-> Generic GetPhoneNumberOrder
forall x. Rep GetPhoneNumberOrder x -> GetPhoneNumberOrder
forall x. GetPhoneNumberOrder -> Rep GetPhoneNumberOrder x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetPhoneNumberOrder x -> GetPhoneNumberOrder
$cfrom :: forall x. GetPhoneNumberOrder -> Rep GetPhoneNumberOrder x
Prelude.Generic)

-- |
-- Create a value of 'GetPhoneNumberOrder' 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:
--
-- 'phoneNumberOrderId', 'getPhoneNumberOrder_phoneNumberOrderId' - The ID for the phone number order.
newGetPhoneNumberOrder ::
  -- | 'phoneNumberOrderId'
  Prelude.Text ->
  GetPhoneNumberOrder
newGetPhoneNumberOrder :: Text -> GetPhoneNumberOrder
newGetPhoneNumberOrder Text
pPhoneNumberOrderId_ =
  GetPhoneNumberOrder' :: Text -> GetPhoneNumberOrder
GetPhoneNumberOrder'
    { $sel:phoneNumberOrderId:GetPhoneNumberOrder' :: Text
phoneNumberOrderId =
        Text
pPhoneNumberOrderId_
    }

-- | The ID for the phone number order.
getPhoneNumberOrder_phoneNumberOrderId :: Lens.Lens' GetPhoneNumberOrder Prelude.Text
getPhoneNumberOrder_phoneNumberOrderId :: (Text -> f Text) -> GetPhoneNumberOrder -> f GetPhoneNumberOrder
getPhoneNumberOrder_phoneNumberOrderId = (GetPhoneNumberOrder -> Text)
-> (GetPhoneNumberOrder -> Text -> GetPhoneNumberOrder)
-> Lens GetPhoneNumberOrder GetPhoneNumberOrder Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetPhoneNumberOrder' {Text
phoneNumberOrderId :: Text
$sel:phoneNumberOrderId:GetPhoneNumberOrder' :: GetPhoneNumberOrder -> Text
phoneNumberOrderId} -> Text
phoneNumberOrderId) (\s :: GetPhoneNumberOrder
s@GetPhoneNumberOrder' {} Text
a -> GetPhoneNumberOrder
s {$sel:phoneNumberOrderId:GetPhoneNumberOrder' :: Text
phoneNumberOrderId = Text
a} :: GetPhoneNumberOrder)

instance Core.AWSRequest GetPhoneNumberOrder where
  type
    AWSResponse GetPhoneNumberOrder =
      GetPhoneNumberOrderResponse
  request :: GetPhoneNumberOrder -> Request GetPhoneNumberOrder
request = Service -> GetPhoneNumberOrder -> Request GetPhoneNumberOrder
forall a. ToRequest a => Service -> a -> Request a
Request.get Service
defaultService
  response :: Logger
-> Service
-> Proxy GetPhoneNumberOrder
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetPhoneNumberOrder)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse GetPhoneNumberOrder))
-> Logger
-> Service
-> Proxy GetPhoneNumberOrder
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetPhoneNumberOrder)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe PhoneNumberOrder -> Int -> GetPhoneNumberOrderResponse
GetPhoneNumberOrderResponse'
            (Maybe PhoneNumberOrder -> Int -> GetPhoneNumberOrderResponse)
-> Either String (Maybe PhoneNumberOrder)
-> Either String (Int -> GetPhoneNumberOrderResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe PhoneNumberOrder)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"PhoneNumberOrder")
            Either String (Int -> GetPhoneNumberOrderResponse)
-> Either String Int -> Either String GetPhoneNumberOrderResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Int -> Either String Int
forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (Int -> Int
forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable GetPhoneNumberOrder

instance Prelude.NFData GetPhoneNumberOrder

instance Core.ToHeaders GetPhoneNumberOrder where
  toHeaders :: GetPhoneNumberOrder -> ResponseHeaders
toHeaders = ResponseHeaders -> GetPhoneNumberOrder -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const ResponseHeaders
forall a. Monoid a => a
Prelude.mempty

instance Core.ToPath GetPhoneNumberOrder where
  toPath :: GetPhoneNumberOrder -> ByteString
toPath GetPhoneNumberOrder' {Text
phoneNumberOrderId :: Text
$sel:phoneNumberOrderId:GetPhoneNumberOrder' :: GetPhoneNumberOrder -> Text
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/phone-number-orders/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
phoneNumberOrderId
      ]

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

-- | /See:/ 'newGetPhoneNumberOrderResponse' smart constructor.
data GetPhoneNumberOrderResponse = GetPhoneNumberOrderResponse'
  { -- | The phone number order details.
    GetPhoneNumberOrderResponse -> Maybe PhoneNumberOrder
phoneNumberOrder :: Prelude.Maybe PhoneNumberOrder,
    -- | The response's http status code.
    GetPhoneNumberOrderResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (GetPhoneNumberOrderResponse -> GetPhoneNumberOrderResponse -> Bool
(GetPhoneNumberOrderResponse
 -> GetPhoneNumberOrderResponse -> Bool)
-> (GetPhoneNumberOrderResponse
    -> GetPhoneNumberOrderResponse -> Bool)
-> Eq GetPhoneNumberOrderResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetPhoneNumberOrderResponse -> GetPhoneNumberOrderResponse -> Bool
$c/= :: GetPhoneNumberOrderResponse -> GetPhoneNumberOrderResponse -> Bool
== :: GetPhoneNumberOrderResponse -> GetPhoneNumberOrderResponse -> Bool
$c== :: GetPhoneNumberOrderResponse -> GetPhoneNumberOrderResponse -> Bool
Prelude.Eq, Int -> GetPhoneNumberOrderResponse -> ShowS
[GetPhoneNumberOrderResponse] -> ShowS
GetPhoneNumberOrderResponse -> String
(Int -> GetPhoneNumberOrderResponse -> ShowS)
-> (GetPhoneNumberOrderResponse -> String)
-> ([GetPhoneNumberOrderResponse] -> ShowS)
-> Show GetPhoneNumberOrderResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetPhoneNumberOrderResponse] -> ShowS
$cshowList :: [GetPhoneNumberOrderResponse] -> ShowS
show :: GetPhoneNumberOrderResponse -> String
$cshow :: GetPhoneNumberOrderResponse -> String
showsPrec :: Int -> GetPhoneNumberOrderResponse -> ShowS
$cshowsPrec :: Int -> GetPhoneNumberOrderResponse -> ShowS
Prelude.Show, (forall x.
 GetPhoneNumberOrderResponse -> Rep GetPhoneNumberOrderResponse x)
-> (forall x.
    Rep GetPhoneNumberOrderResponse x -> GetPhoneNumberOrderResponse)
-> Generic GetPhoneNumberOrderResponse
forall x.
Rep GetPhoneNumberOrderResponse x -> GetPhoneNumberOrderResponse
forall x.
GetPhoneNumberOrderResponse -> Rep GetPhoneNumberOrderResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep GetPhoneNumberOrderResponse x -> GetPhoneNumberOrderResponse
$cfrom :: forall x.
GetPhoneNumberOrderResponse -> Rep GetPhoneNumberOrderResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetPhoneNumberOrderResponse' 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:
--
-- 'phoneNumberOrder', 'getPhoneNumberOrderResponse_phoneNumberOrder' - The phone number order details.
--
-- 'httpStatus', 'getPhoneNumberOrderResponse_httpStatus' - The response's http status code.
newGetPhoneNumberOrderResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetPhoneNumberOrderResponse
newGetPhoneNumberOrderResponse :: Int -> GetPhoneNumberOrderResponse
newGetPhoneNumberOrderResponse Int
pHttpStatus_ =
  GetPhoneNumberOrderResponse' :: Maybe PhoneNumberOrder -> Int -> GetPhoneNumberOrderResponse
GetPhoneNumberOrderResponse'
    { $sel:phoneNumberOrder:GetPhoneNumberOrderResponse' :: Maybe PhoneNumberOrder
phoneNumberOrder =
        Maybe PhoneNumberOrder
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetPhoneNumberOrderResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The phone number order details.
getPhoneNumberOrderResponse_phoneNumberOrder :: Lens.Lens' GetPhoneNumberOrderResponse (Prelude.Maybe PhoneNumberOrder)
getPhoneNumberOrderResponse_phoneNumberOrder :: (Maybe PhoneNumberOrder -> f (Maybe PhoneNumberOrder))
-> GetPhoneNumberOrderResponse -> f GetPhoneNumberOrderResponse
getPhoneNumberOrderResponse_phoneNumberOrder = (GetPhoneNumberOrderResponse -> Maybe PhoneNumberOrder)
-> (GetPhoneNumberOrderResponse
    -> Maybe PhoneNumberOrder -> GetPhoneNumberOrderResponse)
-> Lens
     GetPhoneNumberOrderResponse
     GetPhoneNumberOrderResponse
     (Maybe PhoneNumberOrder)
     (Maybe PhoneNumberOrder)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetPhoneNumberOrderResponse' {Maybe PhoneNumberOrder
phoneNumberOrder :: Maybe PhoneNumberOrder
$sel:phoneNumberOrder:GetPhoneNumberOrderResponse' :: GetPhoneNumberOrderResponse -> Maybe PhoneNumberOrder
phoneNumberOrder} -> Maybe PhoneNumberOrder
phoneNumberOrder) (\s :: GetPhoneNumberOrderResponse
s@GetPhoneNumberOrderResponse' {} Maybe PhoneNumberOrder
a -> GetPhoneNumberOrderResponse
s {$sel:phoneNumberOrder:GetPhoneNumberOrderResponse' :: Maybe PhoneNumberOrder
phoneNumberOrder = Maybe PhoneNumberOrder
a} :: GetPhoneNumberOrderResponse)

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

instance Prelude.NFData GetPhoneNumberOrderResponse