{-# 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 #-}
module Amazonka.Textract.AnalyzeExpense
(
AnalyzeExpense (..),
newAnalyzeExpense,
analyzeExpense_document,
AnalyzeExpenseResponse (..),
newAnalyzeExpenseResponse,
analyzeExpenseResponse_documentMetadata,
analyzeExpenseResponse_expenseDocuments,
analyzeExpenseResponse_httpStatus,
)
where
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
import Amazonka.Textract.Types
data AnalyzeExpense = AnalyzeExpense'
{ AnalyzeExpense -> Document
document :: Document
}
deriving (AnalyzeExpense -> AnalyzeExpense -> Bool
(AnalyzeExpense -> AnalyzeExpense -> Bool)
-> (AnalyzeExpense -> AnalyzeExpense -> Bool) -> Eq AnalyzeExpense
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AnalyzeExpense -> AnalyzeExpense -> Bool
$c/= :: AnalyzeExpense -> AnalyzeExpense -> Bool
== :: AnalyzeExpense -> AnalyzeExpense -> Bool
$c== :: AnalyzeExpense -> AnalyzeExpense -> Bool
Prelude.Eq, ReadPrec [AnalyzeExpense]
ReadPrec AnalyzeExpense
Int -> ReadS AnalyzeExpense
ReadS [AnalyzeExpense]
(Int -> ReadS AnalyzeExpense)
-> ReadS [AnalyzeExpense]
-> ReadPrec AnalyzeExpense
-> ReadPrec [AnalyzeExpense]
-> Read AnalyzeExpense
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AnalyzeExpense]
$creadListPrec :: ReadPrec [AnalyzeExpense]
readPrec :: ReadPrec AnalyzeExpense
$creadPrec :: ReadPrec AnalyzeExpense
readList :: ReadS [AnalyzeExpense]
$creadList :: ReadS [AnalyzeExpense]
readsPrec :: Int -> ReadS AnalyzeExpense
$creadsPrec :: Int -> ReadS AnalyzeExpense
Prelude.Read, Int -> AnalyzeExpense -> ShowS
[AnalyzeExpense] -> ShowS
AnalyzeExpense -> String
(Int -> AnalyzeExpense -> ShowS)
-> (AnalyzeExpense -> String)
-> ([AnalyzeExpense] -> ShowS)
-> Show AnalyzeExpense
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AnalyzeExpense] -> ShowS
$cshowList :: [AnalyzeExpense] -> ShowS
show :: AnalyzeExpense -> String
$cshow :: AnalyzeExpense -> String
showsPrec :: Int -> AnalyzeExpense -> ShowS
$cshowsPrec :: Int -> AnalyzeExpense -> ShowS
Prelude.Show, (forall x. AnalyzeExpense -> Rep AnalyzeExpense x)
-> (forall x. Rep AnalyzeExpense x -> AnalyzeExpense)
-> Generic AnalyzeExpense
forall x. Rep AnalyzeExpense x -> AnalyzeExpense
forall x. AnalyzeExpense -> Rep AnalyzeExpense x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AnalyzeExpense x -> AnalyzeExpense
$cfrom :: forall x. AnalyzeExpense -> Rep AnalyzeExpense x
Prelude.Generic)
newAnalyzeExpense ::
Document ->
AnalyzeExpense
newAnalyzeExpense :: Document -> AnalyzeExpense
newAnalyzeExpense Document
pDocument_ =
AnalyzeExpense' :: Document -> AnalyzeExpense
AnalyzeExpense' {$sel:document:AnalyzeExpense' :: Document
document = Document
pDocument_}
analyzeExpense_document :: Lens.Lens' AnalyzeExpense Document
analyzeExpense_document :: (Document -> f Document) -> AnalyzeExpense -> f AnalyzeExpense
analyzeExpense_document = (AnalyzeExpense -> Document)
-> (AnalyzeExpense -> Document -> AnalyzeExpense)
-> Lens AnalyzeExpense AnalyzeExpense Document Document
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AnalyzeExpense' {Document
document :: Document
$sel:document:AnalyzeExpense' :: AnalyzeExpense -> Document
document} -> Document
document) (\s :: AnalyzeExpense
s@AnalyzeExpense' {} Document
a -> AnalyzeExpense
s {$sel:document:AnalyzeExpense' :: Document
document = Document
a} :: AnalyzeExpense)
instance Core.AWSRequest AnalyzeExpense where
type
AWSResponse AnalyzeExpense =
AnalyzeExpenseResponse
request :: AnalyzeExpense -> Request AnalyzeExpense
request = Service -> AnalyzeExpense -> Request AnalyzeExpense
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
response :: Logger
-> Service
-> Proxy AnalyzeExpense
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse AnalyzeExpense)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse AnalyzeExpense))
-> Logger
-> Service
-> Proxy AnalyzeExpense
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse AnalyzeExpense)))
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 DocumentMetadata
-> Maybe [ExpenseDocument] -> Int -> AnalyzeExpenseResponse
AnalyzeExpenseResponse'
(Maybe DocumentMetadata
-> Maybe [ExpenseDocument] -> Int -> AnalyzeExpenseResponse)
-> Either String (Maybe DocumentMetadata)
-> Either
String (Maybe [ExpenseDocument] -> Int -> AnalyzeExpenseResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Key -> Either String (Maybe DocumentMetadata)
forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Core..?> Key
"DocumentMetadata")
Either
String (Maybe [ExpenseDocument] -> Int -> AnalyzeExpenseResponse)
-> Either String (Maybe [ExpenseDocument])
-> Either String (Int -> AnalyzeExpenseResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( Object
x Object -> Key -> Either String (Maybe (Maybe [ExpenseDocument]))
forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Core..?> Key
"ExpenseDocuments"
Either String (Maybe (Maybe [ExpenseDocument]))
-> Maybe [ExpenseDocument]
-> Either String (Maybe [ExpenseDocument])
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ Maybe [ExpenseDocument]
forall a. Monoid a => a
Prelude.mempty
)
Either String (Int -> AnalyzeExpenseResponse)
-> Either String Int -> Either String AnalyzeExpenseResponse
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 AnalyzeExpense
instance Prelude.NFData AnalyzeExpense
instance Core.ToHeaders AnalyzeExpense where
toHeaders :: AnalyzeExpense -> ResponseHeaders
toHeaders =
ResponseHeaders -> AnalyzeExpense -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
[ HeaderName
"X-Amz-Target"
HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# (ByteString
"Textract.AnalyzeExpense" :: Prelude.ByteString),
HeaderName
"Content-Type"
HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"application/x-amz-json-1.1" ::
Prelude.ByteString
)
]
)
instance Core.ToJSON AnalyzeExpense where
toJSON :: AnalyzeExpense -> Value
toJSON AnalyzeExpense' {Document
document :: Document
$sel:document:AnalyzeExpense' :: AnalyzeExpense -> Document
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Key
"Document" Key -> Document -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Core..= Document
document)]
)
instance Core.ToPath AnalyzeExpense where
toPath :: AnalyzeExpense -> ByteString
toPath = ByteString -> AnalyzeExpense -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"
instance Core.ToQuery AnalyzeExpense where
toQuery :: AnalyzeExpense -> QueryString
toQuery = QueryString -> AnalyzeExpense -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data AnalyzeExpenseResponse = AnalyzeExpenseResponse'
{ AnalyzeExpenseResponse -> Maybe DocumentMetadata
documentMetadata :: Prelude.Maybe DocumentMetadata,
AnalyzeExpenseResponse -> Maybe [ExpenseDocument]
expenseDocuments :: Prelude.Maybe [ExpenseDocument],
AnalyzeExpenseResponse -> Int
httpStatus :: Prelude.Int
}
deriving (AnalyzeExpenseResponse -> AnalyzeExpenseResponse -> Bool
(AnalyzeExpenseResponse -> AnalyzeExpenseResponse -> Bool)
-> (AnalyzeExpenseResponse -> AnalyzeExpenseResponse -> Bool)
-> Eq AnalyzeExpenseResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AnalyzeExpenseResponse -> AnalyzeExpenseResponse -> Bool
$c/= :: AnalyzeExpenseResponse -> AnalyzeExpenseResponse -> Bool
== :: AnalyzeExpenseResponse -> AnalyzeExpenseResponse -> Bool
$c== :: AnalyzeExpenseResponse -> AnalyzeExpenseResponse -> Bool
Prelude.Eq, ReadPrec [AnalyzeExpenseResponse]
ReadPrec AnalyzeExpenseResponse
Int -> ReadS AnalyzeExpenseResponse
ReadS [AnalyzeExpenseResponse]
(Int -> ReadS AnalyzeExpenseResponse)
-> ReadS [AnalyzeExpenseResponse]
-> ReadPrec AnalyzeExpenseResponse
-> ReadPrec [AnalyzeExpenseResponse]
-> Read AnalyzeExpenseResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AnalyzeExpenseResponse]
$creadListPrec :: ReadPrec [AnalyzeExpenseResponse]
readPrec :: ReadPrec AnalyzeExpenseResponse
$creadPrec :: ReadPrec AnalyzeExpenseResponse
readList :: ReadS [AnalyzeExpenseResponse]
$creadList :: ReadS [AnalyzeExpenseResponse]
readsPrec :: Int -> ReadS AnalyzeExpenseResponse
$creadsPrec :: Int -> ReadS AnalyzeExpenseResponse
Prelude.Read, Int -> AnalyzeExpenseResponse -> ShowS
[AnalyzeExpenseResponse] -> ShowS
AnalyzeExpenseResponse -> String
(Int -> AnalyzeExpenseResponse -> ShowS)
-> (AnalyzeExpenseResponse -> String)
-> ([AnalyzeExpenseResponse] -> ShowS)
-> Show AnalyzeExpenseResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AnalyzeExpenseResponse] -> ShowS
$cshowList :: [AnalyzeExpenseResponse] -> ShowS
show :: AnalyzeExpenseResponse -> String
$cshow :: AnalyzeExpenseResponse -> String
showsPrec :: Int -> AnalyzeExpenseResponse -> ShowS
$cshowsPrec :: Int -> AnalyzeExpenseResponse -> ShowS
Prelude.Show, (forall x. AnalyzeExpenseResponse -> Rep AnalyzeExpenseResponse x)
-> (forall x.
Rep AnalyzeExpenseResponse x -> AnalyzeExpenseResponse)
-> Generic AnalyzeExpenseResponse
forall x. Rep AnalyzeExpenseResponse x -> AnalyzeExpenseResponse
forall x. AnalyzeExpenseResponse -> Rep AnalyzeExpenseResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AnalyzeExpenseResponse x -> AnalyzeExpenseResponse
$cfrom :: forall x. AnalyzeExpenseResponse -> Rep AnalyzeExpenseResponse x
Prelude.Generic)
newAnalyzeExpenseResponse ::
Prelude.Int ->
AnalyzeExpenseResponse
newAnalyzeExpenseResponse :: Int -> AnalyzeExpenseResponse
newAnalyzeExpenseResponse Int
pHttpStatus_ =
AnalyzeExpenseResponse' :: Maybe DocumentMetadata
-> Maybe [ExpenseDocument] -> Int -> AnalyzeExpenseResponse
AnalyzeExpenseResponse'
{ $sel:documentMetadata:AnalyzeExpenseResponse' :: Maybe DocumentMetadata
documentMetadata =
Maybe DocumentMetadata
forall a. Maybe a
Prelude.Nothing,
$sel:expenseDocuments:AnalyzeExpenseResponse' :: Maybe [ExpenseDocument]
expenseDocuments = Maybe [ExpenseDocument]
forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:AnalyzeExpenseResponse' :: Int
httpStatus = Int
pHttpStatus_
}
analyzeExpenseResponse_documentMetadata :: Lens.Lens' AnalyzeExpenseResponse (Prelude.Maybe DocumentMetadata)
analyzeExpenseResponse_documentMetadata :: (Maybe DocumentMetadata -> f (Maybe DocumentMetadata))
-> AnalyzeExpenseResponse -> f AnalyzeExpenseResponse
analyzeExpenseResponse_documentMetadata = (AnalyzeExpenseResponse -> Maybe DocumentMetadata)
-> (AnalyzeExpenseResponse
-> Maybe DocumentMetadata -> AnalyzeExpenseResponse)
-> Lens
AnalyzeExpenseResponse
AnalyzeExpenseResponse
(Maybe DocumentMetadata)
(Maybe DocumentMetadata)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AnalyzeExpenseResponse' {Maybe DocumentMetadata
documentMetadata :: Maybe DocumentMetadata
$sel:documentMetadata:AnalyzeExpenseResponse' :: AnalyzeExpenseResponse -> Maybe DocumentMetadata
documentMetadata} -> Maybe DocumentMetadata
documentMetadata) (\s :: AnalyzeExpenseResponse
s@AnalyzeExpenseResponse' {} Maybe DocumentMetadata
a -> AnalyzeExpenseResponse
s {$sel:documentMetadata:AnalyzeExpenseResponse' :: Maybe DocumentMetadata
documentMetadata = Maybe DocumentMetadata
a} :: AnalyzeExpenseResponse)
analyzeExpenseResponse_expenseDocuments :: Lens.Lens' AnalyzeExpenseResponse (Prelude.Maybe [ExpenseDocument])
analyzeExpenseResponse_expenseDocuments :: (Maybe [ExpenseDocument] -> f (Maybe [ExpenseDocument]))
-> AnalyzeExpenseResponse -> f AnalyzeExpenseResponse
analyzeExpenseResponse_expenseDocuments = (AnalyzeExpenseResponse -> Maybe [ExpenseDocument])
-> (AnalyzeExpenseResponse
-> Maybe [ExpenseDocument] -> AnalyzeExpenseResponse)
-> Lens
AnalyzeExpenseResponse
AnalyzeExpenseResponse
(Maybe [ExpenseDocument])
(Maybe [ExpenseDocument])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AnalyzeExpenseResponse' {Maybe [ExpenseDocument]
expenseDocuments :: Maybe [ExpenseDocument]
$sel:expenseDocuments:AnalyzeExpenseResponse' :: AnalyzeExpenseResponse -> Maybe [ExpenseDocument]
expenseDocuments} -> Maybe [ExpenseDocument]
expenseDocuments) (\s :: AnalyzeExpenseResponse
s@AnalyzeExpenseResponse' {} Maybe [ExpenseDocument]
a -> AnalyzeExpenseResponse
s {$sel:expenseDocuments:AnalyzeExpenseResponse' :: Maybe [ExpenseDocument]
expenseDocuments = Maybe [ExpenseDocument]
a} :: AnalyzeExpenseResponse) ((Maybe [ExpenseDocument] -> f (Maybe [ExpenseDocument]))
-> AnalyzeExpenseResponse -> f AnalyzeExpenseResponse)
-> ((Maybe [ExpenseDocument] -> f (Maybe [ExpenseDocument]))
-> Maybe [ExpenseDocument] -> f (Maybe [ExpenseDocument]))
-> (Maybe [ExpenseDocument] -> f (Maybe [ExpenseDocument]))
-> AnalyzeExpenseResponse
-> f AnalyzeExpenseResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
[ExpenseDocument]
[ExpenseDocument]
[ExpenseDocument]
[ExpenseDocument]
-> Iso
(Maybe [ExpenseDocument])
(Maybe [ExpenseDocument])
(Maybe [ExpenseDocument])
(Maybe [ExpenseDocument])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso
[ExpenseDocument]
[ExpenseDocument]
[ExpenseDocument]
[ExpenseDocument]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
analyzeExpenseResponse_httpStatus :: Lens.Lens' AnalyzeExpenseResponse Prelude.Int
analyzeExpenseResponse_httpStatus :: (Int -> f Int)
-> AnalyzeExpenseResponse -> f AnalyzeExpenseResponse
analyzeExpenseResponse_httpStatus = (AnalyzeExpenseResponse -> Int)
-> (AnalyzeExpenseResponse -> Int -> AnalyzeExpenseResponse)
-> Lens AnalyzeExpenseResponse AnalyzeExpenseResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AnalyzeExpenseResponse' {Int
httpStatus :: Int
$sel:httpStatus:AnalyzeExpenseResponse' :: AnalyzeExpenseResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: AnalyzeExpenseResponse
s@AnalyzeExpenseResponse' {} Int
a -> AnalyzeExpenseResponse
s {$sel:httpStatus:AnalyzeExpenseResponse' :: Int
httpStatus = Int
a} :: AnalyzeExpenseResponse)
instance Prelude.NFData AnalyzeExpenseResponse