{-# 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.Outposts.GetOrder
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Gets information about the specified order.
module Amazonka.Outposts.GetOrder
  ( -- * Creating a Request
    GetOrder (..),
    newGetOrder,

    -- * Request Lenses
    getOrder_orderId,

    -- * Destructuring the Response
    GetOrderResponse (..),
    newGetOrderResponse,

    -- * Response Lenses
    getOrderResponse_order,
    getOrderResponse_httpStatus,
  )
where

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

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

-- |
-- Create a value of 'GetOrder' 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:
--
-- 'orderId', 'getOrder_orderId' - The ID of the order.
newGetOrder ::
  -- | 'orderId'
  Prelude.Text ->
  GetOrder
newGetOrder :: Text -> GetOrder
newGetOrder Text
pOrderId_ =
  GetOrder' {$sel:orderId:GetOrder' :: Text
orderId = Text
pOrderId_}

-- | The ID of the order.
getOrder_orderId :: Lens.Lens' GetOrder Prelude.Text
getOrder_orderId :: Lens' GetOrder Text
getOrder_orderId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetOrder' {Text
orderId :: Text
$sel:orderId:GetOrder' :: GetOrder -> Text
orderId} -> Text
orderId) (\s :: GetOrder
s@GetOrder' {} Text
a -> GetOrder
s {$sel:orderId:GetOrder' :: Text
orderId = Text
a} :: GetOrder)

instance Core.AWSRequest GetOrder where
  type AWSResponse GetOrder = GetOrderResponse
  request :: (Service -> Service) -> GetOrder -> Request GetOrder
request Service -> Service
overrides =
    forall a. ToRequest a => Service -> a -> Request a
Request.get (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy GetOrder
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetOrder)))
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 Order -> Int -> GetOrderResponse
GetOrderResponse'
            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
"Order")
            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 GetOrder where
  hashWithSalt :: Int -> GetOrder -> Int
hashWithSalt Int
_salt GetOrder' {Text
orderId :: Text
$sel:orderId:GetOrder' :: GetOrder -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
orderId

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

instance Data.ToHeaders GetOrder where
  toHeaders :: GetOrder -> 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.ToPath GetOrder where
  toPath :: GetOrder -> ByteString
toPath GetOrder' {Text
orderId :: Text
$sel:orderId:GetOrder' :: GetOrder -> Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat [ByteString
"/orders/", forall a. ToByteString a => a -> ByteString
Data.toBS Text
orderId]

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

-- | /See:/ 'newGetOrderResponse' smart constructor.
data GetOrderResponse = GetOrderResponse'
  { GetOrderResponse -> Maybe Order
order :: Prelude.Maybe Order,
    -- | The response's http status code.
    GetOrderResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (GetOrderResponse -> GetOrderResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetOrderResponse -> GetOrderResponse -> Bool
$c/= :: GetOrderResponse -> GetOrderResponse -> Bool
== :: GetOrderResponse -> GetOrderResponse -> Bool
$c== :: GetOrderResponse -> GetOrderResponse -> Bool
Prelude.Eq, ReadPrec [GetOrderResponse]
ReadPrec GetOrderResponse
Int -> ReadS GetOrderResponse
ReadS [GetOrderResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetOrderResponse]
$creadListPrec :: ReadPrec [GetOrderResponse]
readPrec :: ReadPrec GetOrderResponse
$creadPrec :: ReadPrec GetOrderResponse
readList :: ReadS [GetOrderResponse]
$creadList :: ReadS [GetOrderResponse]
readsPrec :: Int -> ReadS GetOrderResponse
$creadsPrec :: Int -> ReadS GetOrderResponse
Prelude.Read, Int -> GetOrderResponse -> ShowS
[GetOrderResponse] -> ShowS
GetOrderResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetOrderResponse] -> ShowS
$cshowList :: [GetOrderResponse] -> ShowS
show :: GetOrderResponse -> String
$cshow :: GetOrderResponse -> String
showsPrec :: Int -> GetOrderResponse -> ShowS
$cshowsPrec :: Int -> GetOrderResponse -> ShowS
Prelude.Show, forall x. Rep GetOrderResponse x -> GetOrderResponse
forall x. GetOrderResponse -> Rep GetOrderResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetOrderResponse x -> GetOrderResponse
$cfrom :: forall x. GetOrderResponse -> Rep GetOrderResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetOrderResponse' 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:
--
-- 'order', 'getOrderResponse_order' - Undocumented member.
--
-- 'httpStatus', 'getOrderResponse_httpStatus' - The response's http status code.
newGetOrderResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetOrderResponse
newGetOrderResponse :: Int -> GetOrderResponse
newGetOrderResponse Int
pHttpStatus_ =
  GetOrderResponse'
    { $sel:order:GetOrderResponse' :: Maybe Order
order = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetOrderResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Undocumented member.
getOrderResponse_order :: Lens.Lens' GetOrderResponse (Prelude.Maybe Order)
getOrderResponse_order :: Lens' GetOrderResponse (Maybe Order)
getOrderResponse_order = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetOrderResponse' {Maybe Order
order :: Maybe Order
$sel:order:GetOrderResponse' :: GetOrderResponse -> Maybe Order
order} -> Maybe Order
order) (\s :: GetOrderResponse
s@GetOrderResponse' {} Maybe Order
a -> GetOrderResponse
s {$sel:order:GetOrderResponse' :: Maybe Order
order = Maybe Order
a} :: GetOrderResponse)

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

instance Prelude.NFData GetOrderResponse where
  rnf :: GetOrderResponse -> ()
rnf GetOrderResponse' {Int
Maybe Order
httpStatus :: Int
order :: Maybe Order
$sel:httpStatus:GetOrderResponse' :: GetOrderResponse -> Int
$sel:order:GetOrderResponse' :: GetOrderResponse -> Maybe Order
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Order
order
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus