{-# LANGUAGE ExplicitForAll #-}
{-# LANGUAGE MultiWayIf #-}
-- CHANGE WITH CAUTION: This is a generated code file generated by https://github.com/Haskell-OpenAPI-Code-Generator/Haskell-OpenAPI-Client-Code-Generator.
{-# LANGUAGE OverloadedStrings #-}

-- | Contains the different functions to run the operation postTerminalReaders
module StripeAPI.Operations.PostTerminalReaders where

import qualified Control.Monad.Fail
import qualified Control.Monad.Trans.Reader
import qualified Data.Aeson
import qualified Data.Aeson as Data.Aeson.Encoding.Internal
import qualified Data.Aeson as Data.Aeson.Types
import qualified Data.Aeson as Data.Aeson.Types.FromJSON
import qualified Data.Aeson as Data.Aeson.Types.Internal
import qualified Data.Aeson as Data.Aeson.Types.ToJSON
import qualified Data.ByteString.Char8
import qualified Data.ByteString.Char8 as Data.ByteString.Internal
import qualified Data.Either
import qualified Data.Functor
import qualified Data.Scientific
import qualified Data.Text
import qualified Data.Text.Internal
import qualified Data.Time.Calendar as Data.Time.Calendar.Days
import qualified Data.Time.LocalTime as Data.Time.LocalTime.Internal.ZonedTime
import qualified Data.Vector
import qualified GHC.Base
import qualified GHC.Classes
import qualified GHC.Int
import qualified GHC.Show
import qualified GHC.Types
import qualified Network.HTTP.Client
import qualified Network.HTTP.Client as Network.HTTP.Client.Request
import qualified Network.HTTP.Client as Network.HTTP.Client.Types
import qualified Network.HTTP.Simple
import qualified Network.HTTP.Types
import qualified Network.HTTP.Types as Network.HTTP.Types.Status
import qualified Network.HTTP.Types as Network.HTTP.Types.URI
import qualified StripeAPI.Common
import StripeAPI.Types
import qualified Prelude as GHC.Integer.Type
import qualified Prelude as GHC.Maybe

-- | > POST /v1/terminal/readers
--
-- \<p>Creates a new \<code>Reader\<\/code> object.\<\/p>
postTerminalReaders ::
  forall m.
  StripeAPI.Common.MonadHTTP m =>
  -- | The request body to send
  PostTerminalReadersRequestBody ->
  -- | Monadic computation which returns the result of the operation
  StripeAPI.Common.StripeT m (Network.HTTP.Client.Types.Response PostTerminalReadersResponse)
postTerminalReaders :: PostTerminalReadersRequestBody
-> StripeT m (Response PostTerminalReadersResponse)
postTerminalReaders PostTerminalReadersRequestBody
body =
  (Response ByteString -> Response PostTerminalReadersResponse)
-> StripeT m (Response ByteString)
-> StripeT m (Response PostTerminalReadersResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
GHC.Base.fmap
    ( \Response ByteString
response_0 ->
        (ByteString -> PostTerminalReadersResponse)
-> Response ByteString -> Response PostTerminalReadersResponse
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
GHC.Base.fmap
          ( (String -> PostTerminalReadersResponse)
-> (PostTerminalReadersResponse -> PostTerminalReadersResponse)
-> Either String PostTerminalReadersResponse
-> PostTerminalReadersResponse
forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
Data.Either.either String -> PostTerminalReadersResponse
PostTerminalReadersResponseError PostTerminalReadersResponse -> PostTerminalReadersResponse
forall a. a -> a
GHC.Base.id
              (Either String PostTerminalReadersResponse
 -> PostTerminalReadersResponse)
-> (ByteString -> Either String PostTerminalReadersResponse)
-> ByteString
-> PostTerminalReadersResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
GHC.Base.. ( \Response ByteString
response ByteString
body ->
                             if
                                 | (\Status
status_1 -> Status -> Int
Network.HTTP.Types.Status.statusCode Status
status_1 Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
GHC.Classes.== Int
200) (Response ByteString -> Status
forall body. Response body -> Status
Network.HTTP.Client.Types.responseStatus Response ByteString
response) ->
                                   Terminal'reader -> PostTerminalReadersResponse
PostTerminalReadersResponse200
                                     (Terminal'reader -> PostTerminalReadersResponse)
-> Either String Terminal'reader
-> Either String PostTerminalReadersResponse
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Data.Functor.<$> ( ByteString -> Either String Terminal'reader
forall a. FromJSON a => ByteString -> Either String a
Data.Aeson.eitherDecodeStrict ByteString
body ::
                                                          Data.Either.Either
                                                            GHC.Base.String
                                                            Terminal'reader
                                                      )
                                 | Bool -> Status -> Bool
forall a b. a -> b -> a
GHC.Base.const Bool
GHC.Types.True (Response ByteString -> Status
forall body. Response body -> Status
Network.HTTP.Client.Types.responseStatus Response ByteString
response) ->
                                   Error -> PostTerminalReadersResponse
PostTerminalReadersResponseDefault
                                     (Error -> PostTerminalReadersResponse)
-> Either String Error -> Either String PostTerminalReadersResponse
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Data.Functor.<$> ( ByteString -> Either String Error
forall a. FromJSON a => ByteString -> Either String a
Data.Aeson.eitherDecodeStrict ByteString
body ::
                                                          Data.Either.Either
                                                            GHC.Base.String
                                                            Error
                                                      )
                                 | Bool
GHC.Base.otherwise -> String -> Either String PostTerminalReadersResponse
forall a b. a -> Either a b
Data.Either.Left String
"Missing default response type"
                         )
                Response ByteString
response_0
          )
          Response ByteString
response_0
    )
    (Text
-> Text
-> [QueryParameter]
-> Maybe PostTerminalReadersRequestBody
-> RequestBodyEncoding
-> StripeT m (Response ByteString)
forall (m :: * -> *) body.
(MonadHTTP m, ToJSON body) =>
Text
-> Text
-> [QueryParameter]
-> Maybe body
-> RequestBodyEncoding
-> StripeT m (Response ByteString)
StripeAPI.Common.doBodyCallWithConfigurationM (Text -> Text
Data.Text.toUpper (Text -> Text) -> Text -> Text
forall a b. (a -> b) -> a -> b
GHC.Base.$ String -> Text
Data.Text.pack String
"POST") (String -> Text
Data.Text.pack String
"/v1/terminal/readers") [QueryParameter]
forall a. Monoid a => a
GHC.Base.mempty (PostTerminalReadersRequestBody
-> Maybe PostTerminalReadersRequestBody
forall a. a -> Maybe a
GHC.Maybe.Just PostTerminalReadersRequestBody
body) RequestBodyEncoding
StripeAPI.Common.RequestBodyEncodingFormData)

-- | Defines the object schema located at @paths.\/v1\/terminal\/readers.POST.requestBody.content.application\/x-www-form-urlencoded.schema@ in the specification.
data PostTerminalReadersRequestBody = PostTerminalReadersRequestBody
  { -- | expand: Specifies which fields in the response should be expanded.
    PostTerminalReadersRequestBody -> Maybe [Text]
postTerminalReadersRequestBodyExpand :: (GHC.Maybe.Maybe ([Data.Text.Internal.Text])),
    -- | label: Custom label given to the reader for easier identification. If no label is specified, the registration code will be used.
    --
    -- Constraints:
    --
    -- * Maximum length of 5000
    PostTerminalReadersRequestBody -> Maybe Text
postTerminalReadersRequestBodyLabel :: (GHC.Maybe.Maybe Data.Text.Internal.Text),
    -- | location: The location to assign the reader to. If no location is specified, the reader will be assigned to the account\'s default location.
    --
    -- Constraints:
    --
    -- * Maximum length of 5000
    PostTerminalReadersRequestBody -> Maybe Text
postTerminalReadersRequestBodyLocation :: (GHC.Maybe.Maybe Data.Text.Internal.Text),
    -- | metadata: Set of [key-value pairs](https:\/\/stripe.com\/docs\/api\/metadata) that you can attach to an object. This can be useful for storing additional information about the object in a structured format. Individual keys can be unset by posting an empty value to them. All keys can be unset by posting an empty value to \`metadata\`.
    PostTerminalReadersRequestBody
-> Maybe PostTerminalReadersRequestBodyMetadata'Variants
postTerminalReadersRequestBodyMetadata :: (GHC.Maybe.Maybe PostTerminalReadersRequestBodyMetadata'Variants),
    -- | registration_code: A code generated by the reader used for registering to an account.
    --
    -- Constraints:
    --
    -- * Maximum length of 5000
    PostTerminalReadersRequestBody -> Text
postTerminalReadersRequestBodyRegistrationCode :: Data.Text.Internal.Text
  }
  deriving
    ( Int -> PostTerminalReadersRequestBody -> ShowS
[PostTerminalReadersRequestBody] -> ShowS
PostTerminalReadersRequestBody -> String
(Int -> PostTerminalReadersRequestBody -> ShowS)
-> (PostTerminalReadersRequestBody -> String)
-> ([PostTerminalReadersRequestBody] -> ShowS)
-> Show PostTerminalReadersRequestBody
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PostTerminalReadersRequestBody] -> ShowS
$cshowList :: [PostTerminalReadersRequestBody] -> ShowS
show :: PostTerminalReadersRequestBody -> String
$cshow :: PostTerminalReadersRequestBody -> String
showsPrec :: Int -> PostTerminalReadersRequestBody -> ShowS
$cshowsPrec :: Int -> PostTerminalReadersRequestBody -> ShowS
GHC.Show.Show,
      PostTerminalReadersRequestBody
-> PostTerminalReadersRequestBody -> Bool
(PostTerminalReadersRequestBody
 -> PostTerminalReadersRequestBody -> Bool)
-> (PostTerminalReadersRequestBody
    -> PostTerminalReadersRequestBody -> Bool)
-> Eq PostTerminalReadersRequestBody
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PostTerminalReadersRequestBody
-> PostTerminalReadersRequestBody -> Bool
$c/= :: PostTerminalReadersRequestBody
-> PostTerminalReadersRequestBody -> Bool
== :: PostTerminalReadersRequestBody
-> PostTerminalReadersRequestBody -> Bool
$c== :: PostTerminalReadersRequestBody
-> PostTerminalReadersRequestBody -> Bool
GHC.Classes.Eq
    )

instance Data.Aeson.Types.ToJSON.ToJSON PostTerminalReadersRequestBody where
  toJSON :: PostTerminalReadersRequestBody -> Value
toJSON PostTerminalReadersRequestBody
obj = [Pair] -> Value
Data.Aeson.Types.Internal.object (Text
"expand" Text -> Maybe [Text] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PostTerminalReadersRequestBody -> Maybe [Text]
postTerminalReadersRequestBodyExpand PostTerminalReadersRequestBody
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"label" Text -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PostTerminalReadersRequestBody -> Maybe Text
postTerminalReadersRequestBodyLabel PostTerminalReadersRequestBody
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"location" Text -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PostTerminalReadersRequestBody -> Maybe Text
postTerminalReadersRequestBodyLocation PostTerminalReadersRequestBody
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"metadata" Text
-> Maybe PostTerminalReadersRequestBodyMetadata'Variants -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PostTerminalReadersRequestBody
-> Maybe PostTerminalReadersRequestBodyMetadata'Variants
postTerminalReadersRequestBodyMetadata PostTerminalReadersRequestBody
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"registration_code" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PostTerminalReadersRequestBody -> Text
postTerminalReadersRequestBodyRegistrationCode PostTerminalReadersRequestBody
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: [Pair]
forall a. Monoid a => a
GHC.Base.mempty)
  toEncoding :: PostTerminalReadersRequestBody -> Encoding
toEncoding PostTerminalReadersRequestBody
obj = Series -> Encoding
Data.Aeson.Encoding.Internal.pairs ((Text
"expand" Text -> Maybe [Text] -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PostTerminalReadersRequestBody -> Maybe [Text]
postTerminalReadersRequestBodyExpand PostTerminalReadersRequestBody
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"label" Text -> Maybe Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PostTerminalReadersRequestBody -> Maybe Text
postTerminalReadersRequestBodyLabel PostTerminalReadersRequestBody
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"location" Text -> Maybe Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PostTerminalReadersRequestBody -> Maybe Text
postTerminalReadersRequestBodyLocation PostTerminalReadersRequestBody
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"metadata" Text
-> Maybe PostTerminalReadersRequestBodyMetadata'Variants -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PostTerminalReadersRequestBody
-> Maybe PostTerminalReadersRequestBodyMetadata'Variants
postTerminalReadersRequestBodyMetadata PostTerminalReadersRequestBody
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> (Text
"registration_code" Text -> Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PostTerminalReadersRequestBody -> Text
postTerminalReadersRequestBodyRegistrationCode PostTerminalReadersRequestBody
obj)))))

instance Data.Aeson.Types.FromJSON.FromJSON PostTerminalReadersRequestBody where
  parseJSON :: Value -> Parser PostTerminalReadersRequestBody
parseJSON = String
-> (Object -> Parser PostTerminalReadersRequestBody)
-> Value
-> Parser PostTerminalReadersRequestBody
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.Aeson.Types.FromJSON.withObject String
"PostTerminalReadersRequestBody" (\Object
obj -> (((((Maybe [Text]
 -> Maybe Text
 -> Maybe Text
 -> Maybe PostTerminalReadersRequestBodyMetadata'Variants
 -> Text
 -> PostTerminalReadersRequestBody)
-> Parser
     (Maybe [Text]
      -> Maybe Text
      -> Maybe Text
      -> Maybe PostTerminalReadersRequestBodyMetadata'Variants
      -> Text
      -> PostTerminalReadersRequestBody)
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure Maybe [Text]
-> Maybe Text
-> Maybe Text
-> Maybe PostTerminalReadersRequestBodyMetadata'Variants
-> Text
-> PostTerminalReadersRequestBody
PostTerminalReadersRequestBody Parser
  (Maybe [Text]
   -> Maybe Text
   -> Maybe Text
   -> Maybe PostTerminalReadersRequestBodyMetadata'Variants
   -> Text
   -> PostTerminalReadersRequestBody)
-> Parser (Maybe [Text])
-> Parser
     (Maybe Text
      -> Maybe Text
      -> Maybe PostTerminalReadersRequestBodyMetadata'Variants
      -> Text
      -> PostTerminalReadersRequestBody)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Text -> Parser (Maybe [Text])
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Text
"expand")) Parser
  (Maybe Text
   -> Maybe Text
   -> Maybe PostTerminalReadersRequestBodyMetadata'Variants
   -> Text
   -> PostTerminalReadersRequestBody)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text
      -> Maybe PostTerminalReadersRequestBodyMetadata'Variants
      -> Text
      -> PostTerminalReadersRequestBody)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Text
"label")) Parser
  (Maybe Text
   -> Maybe PostTerminalReadersRequestBodyMetadata'Variants
   -> Text
   -> PostTerminalReadersRequestBody)
-> Parser (Maybe Text)
-> Parser
     (Maybe PostTerminalReadersRequestBodyMetadata'Variants
      -> Text -> PostTerminalReadersRequestBody)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Text
"location")) Parser
  (Maybe PostTerminalReadersRequestBodyMetadata'Variants
   -> Text -> PostTerminalReadersRequestBody)
-> Parser (Maybe PostTerminalReadersRequestBodyMetadata'Variants)
-> Parser (Text -> PostTerminalReadersRequestBody)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object
-> Text
-> Parser (Maybe PostTerminalReadersRequestBodyMetadata'Variants)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Text
"metadata")) Parser (Text -> PostTerminalReadersRequestBody)
-> Parser Text -> Parser PostTerminalReadersRequestBody
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Data.Aeson.Types.FromJSON..: Text
"registration_code"))

-- | Create a new 'PostTerminalReadersRequestBody' with all required fields.
mkPostTerminalReadersRequestBody ::
  -- | 'postTerminalReadersRequestBodyRegistrationCode'
  Data.Text.Internal.Text ->
  PostTerminalReadersRequestBody
mkPostTerminalReadersRequestBody :: Text -> PostTerminalReadersRequestBody
mkPostTerminalReadersRequestBody Text
postTerminalReadersRequestBodyRegistrationCode =
  PostTerminalReadersRequestBody :: Maybe [Text]
-> Maybe Text
-> Maybe Text
-> Maybe PostTerminalReadersRequestBodyMetadata'Variants
-> Text
-> PostTerminalReadersRequestBody
PostTerminalReadersRequestBody
    { postTerminalReadersRequestBodyExpand :: Maybe [Text]
postTerminalReadersRequestBodyExpand = Maybe [Text]
forall a. Maybe a
GHC.Maybe.Nothing,
      postTerminalReadersRequestBodyLabel :: Maybe Text
postTerminalReadersRequestBodyLabel = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing,
      postTerminalReadersRequestBodyLocation :: Maybe Text
postTerminalReadersRequestBodyLocation = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing,
      postTerminalReadersRequestBodyMetadata :: Maybe PostTerminalReadersRequestBodyMetadata'Variants
postTerminalReadersRequestBodyMetadata = Maybe PostTerminalReadersRequestBodyMetadata'Variants
forall a. Maybe a
GHC.Maybe.Nothing,
      postTerminalReadersRequestBodyRegistrationCode :: Text
postTerminalReadersRequestBodyRegistrationCode = Text
postTerminalReadersRequestBodyRegistrationCode
    }

-- | Defines the oneOf schema located at @paths.\/v1\/terminal\/readers.POST.requestBody.content.application\/x-www-form-urlencoded.schema.properties.metadata.anyOf@ in the specification.
--
-- Set of [key-value pairs](https:\/\/stripe.com\/docs\/api\/metadata) that you can attach to an object. This can be useful for storing additional information about the object in a structured format. Individual keys can be unset by posting an empty value to them. All keys can be unset by posting an empty value to \`metadata\`.
data PostTerminalReadersRequestBodyMetadata'Variants
  = -- | Represents the JSON value @""@
    PostTerminalReadersRequestBodyMetadata'EmptyString
  | PostTerminalReadersRequestBodyMetadata'Object Data.Aeson.Types.Internal.Object
  deriving (Int -> PostTerminalReadersRequestBodyMetadata'Variants -> ShowS
[PostTerminalReadersRequestBodyMetadata'Variants] -> ShowS
PostTerminalReadersRequestBodyMetadata'Variants -> String
(Int -> PostTerminalReadersRequestBodyMetadata'Variants -> ShowS)
-> (PostTerminalReadersRequestBodyMetadata'Variants -> String)
-> ([PostTerminalReadersRequestBodyMetadata'Variants] -> ShowS)
-> Show PostTerminalReadersRequestBodyMetadata'Variants
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PostTerminalReadersRequestBodyMetadata'Variants] -> ShowS
$cshowList :: [PostTerminalReadersRequestBodyMetadata'Variants] -> ShowS
show :: PostTerminalReadersRequestBodyMetadata'Variants -> String
$cshow :: PostTerminalReadersRequestBodyMetadata'Variants -> String
showsPrec :: Int -> PostTerminalReadersRequestBodyMetadata'Variants -> ShowS
$cshowsPrec :: Int -> PostTerminalReadersRequestBodyMetadata'Variants -> ShowS
GHC.Show.Show, PostTerminalReadersRequestBodyMetadata'Variants
-> PostTerminalReadersRequestBodyMetadata'Variants -> Bool
(PostTerminalReadersRequestBodyMetadata'Variants
 -> PostTerminalReadersRequestBodyMetadata'Variants -> Bool)
-> (PostTerminalReadersRequestBodyMetadata'Variants
    -> PostTerminalReadersRequestBodyMetadata'Variants -> Bool)
-> Eq PostTerminalReadersRequestBodyMetadata'Variants
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PostTerminalReadersRequestBodyMetadata'Variants
-> PostTerminalReadersRequestBodyMetadata'Variants -> Bool
$c/= :: PostTerminalReadersRequestBodyMetadata'Variants
-> PostTerminalReadersRequestBodyMetadata'Variants -> Bool
== :: PostTerminalReadersRequestBodyMetadata'Variants
-> PostTerminalReadersRequestBodyMetadata'Variants -> Bool
$c== :: PostTerminalReadersRequestBodyMetadata'Variants
-> PostTerminalReadersRequestBodyMetadata'Variants -> Bool
GHC.Classes.Eq)

instance Data.Aeson.Types.ToJSON.ToJSON PostTerminalReadersRequestBodyMetadata'Variants where
  toJSON :: PostTerminalReadersRequestBodyMetadata'Variants -> Value
toJSON (PostTerminalReadersRequestBodyMetadata'Object Object
a) = Object -> Value
forall a. ToJSON a => a -> Value
Data.Aeson.Types.ToJSON.toJSON Object
a
  toJSON (PostTerminalReadersRequestBodyMetadata'Variants
PostTerminalReadersRequestBodyMetadata'EmptyString) = Value
""

instance Data.Aeson.Types.FromJSON.FromJSON PostTerminalReadersRequestBodyMetadata'Variants where
  parseJSON :: Value -> Parser PostTerminalReadersRequestBodyMetadata'Variants
parseJSON Value
val =
    if
        | Value
val Value -> Value -> Bool
forall a. Eq a => a -> a -> Bool
GHC.Classes.== Value
"" -> PostTerminalReadersRequestBodyMetadata'Variants
-> Parser PostTerminalReadersRequestBodyMetadata'Variants
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure PostTerminalReadersRequestBodyMetadata'Variants
PostTerminalReadersRequestBodyMetadata'EmptyString
        | Bool
GHC.Base.otherwise -> case (Object -> PostTerminalReadersRequestBodyMetadata'Variants
PostTerminalReadersRequestBodyMetadata'Object (Object -> PostTerminalReadersRequestBodyMetadata'Variants)
-> Result Object
-> Result PostTerminalReadersRequestBodyMetadata'Variants
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Data.Functor.<$> Value -> Result Object
forall a. FromJSON a => Value -> Result a
Data.Aeson.Types.FromJSON.fromJSON Value
val) Result PostTerminalReadersRequestBodyMetadata'Variants
-> Result PostTerminalReadersRequestBodyMetadata'Variants
-> Result PostTerminalReadersRequestBodyMetadata'Variants
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
GHC.Base.<|> String -> Result PostTerminalReadersRequestBodyMetadata'Variants
forall a. String -> Result a
Data.Aeson.Types.Internal.Error String
"No variant matched" of
          Data.Aeson.Types.Internal.Success PostTerminalReadersRequestBodyMetadata'Variants
a -> PostTerminalReadersRequestBodyMetadata'Variants
-> Parser PostTerminalReadersRequestBodyMetadata'Variants
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure PostTerminalReadersRequestBodyMetadata'Variants
a
          Data.Aeson.Types.Internal.Error String
a -> String -> Parser PostTerminalReadersRequestBodyMetadata'Variants
forall (m :: * -> *) a. MonadFail m => String -> m a
Control.Monad.Fail.fail String
a

-- | Represents a response of the operation 'postTerminalReaders'.
--
-- The response constructor is chosen by the status code of the response. If no case matches (no specific case for the response code, no range case, no default case), 'PostTerminalReadersResponseError' is used.
data PostTerminalReadersResponse
  = -- | Means either no matching case available or a parse error
    PostTerminalReadersResponseError GHC.Base.String
  | -- | Successful response.
    PostTerminalReadersResponse200 Terminal'reader
  | -- | Error response.
    PostTerminalReadersResponseDefault Error
  deriving (Int -> PostTerminalReadersResponse -> ShowS
[PostTerminalReadersResponse] -> ShowS
PostTerminalReadersResponse -> String
(Int -> PostTerminalReadersResponse -> ShowS)
-> (PostTerminalReadersResponse -> String)
-> ([PostTerminalReadersResponse] -> ShowS)
-> Show PostTerminalReadersResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PostTerminalReadersResponse] -> ShowS
$cshowList :: [PostTerminalReadersResponse] -> ShowS
show :: PostTerminalReadersResponse -> String
$cshow :: PostTerminalReadersResponse -> String
showsPrec :: Int -> PostTerminalReadersResponse -> ShowS
$cshowsPrec :: Int -> PostTerminalReadersResponse -> ShowS
GHC.Show.Show, PostTerminalReadersResponse -> PostTerminalReadersResponse -> Bool
(PostTerminalReadersResponse
 -> PostTerminalReadersResponse -> Bool)
-> (PostTerminalReadersResponse
    -> PostTerminalReadersResponse -> Bool)
-> Eq PostTerminalReadersResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PostTerminalReadersResponse -> PostTerminalReadersResponse -> Bool
$c/= :: PostTerminalReadersResponse -> PostTerminalReadersResponse -> Bool
== :: PostTerminalReadersResponse -> PostTerminalReadersResponse -> Bool
$c== :: PostTerminalReadersResponse -> PostTerminalReadersResponse -> Bool
GHC.Classes.Eq)