{-# 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 postTerminalLocations
module StripeAPI.Operations.PostTerminalLocations 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/locations
--
-- \<p>Creates a new \<code>Location\<\/code> object.\<\/p>
postTerminalLocations ::
  forall m.
  StripeAPI.Common.MonadHTTP m =>
  -- | The request body to send
  PostTerminalLocationsRequestBody ->
  -- | Monadic computation which returns the result of the operation
  StripeAPI.Common.StripeT m (Network.HTTP.Client.Types.Response PostTerminalLocationsResponse)
postTerminalLocations :: PostTerminalLocationsRequestBody
-> StripeT m (Response PostTerminalLocationsResponse)
postTerminalLocations PostTerminalLocationsRequestBody
body =
  (Response ByteString -> Response PostTerminalLocationsResponse)
-> StripeT m (Response ByteString)
-> StripeT m (Response PostTerminalLocationsResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
GHC.Base.fmap
    ( \Response ByteString
response_0 ->
        (ByteString -> PostTerminalLocationsResponse)
-> Response ByteString -> Response PostTerminalLocationsResponse
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
GHC.Base.fmap
          ( (String -> PostTerminalLocationsResponse)
-> (PostTerminalLocationsResponse -> PostTerminalLocationsResponse)
-> Either String PostTerminalLocationsResponse
-> PostTerminalLocationsResponse
forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
Data.Either.either String -> PostTerminalLocationsResponse
PostTerminalLocationsResponseError PostTerminalLocationsResponse -> PostTerminalLocationsResponse
forall a. a -> a
GHC.Base.id
              (Either String PostTerminalLocationsResponse
 -> PostTerminalLocationsResponse)
-> (ByteString -> Either String PostTerminalLocationsResponse)
-> ByteString
-> PostTerminalLocationsResponse
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'location -> PostTerminalLocationsResponse
PostTerminalLocationsResponse200
                                     (Terminal'location -> PostTerminalLocationsResponse)
-> Either String Terminal'location
-> Either String PostTerminalLocationsResponse
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Data.Functor.<$> ( ByteString -> Either String Terminal'location
forall a. FromJSON a => ByteString -> Either String a
Data.Aeson.eitherDecodeStrict ByteString
body ::
                                                          Data.Either.Either
                                                            GHC.Base.String
                                                            Terminal'location
                                                      )
                                 | 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 -> PostTerminalLocationsResponse
PostTerminalLocationsResponseDefault
                                     (Error -> PostTerminalLocationsResponse)
-> Either String Error
-> Either String PostTerminalLocationsResponse
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 PostTerminalLocationsResponse
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 PostTerminalLocationsRequestBody
-> 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/locations") [QueryParameter]
forall a. Monoid a => a
GHC.Base.mempty (PostTerminalLocationsRequestBody
-> Maybe PostTerminalLocationsRequestBody
forall a. a -> Maybe a
GHC.Maybe.Just PostTerminalLocationsRequestBody
body) RequestBodyEncoding
StripeAPI.Common.RequestBodyEncodingFormData)

-- | Defines the object schema located at @paths.\/v1\/terminal\/locations.POST.requestBody.content.application\/x-www-form-urlencoded.schema@ in the specification.
data PostTerminalLocationsRequestBody = PostTerminalLocationsRequestBody
  { -- | address: The full address of the location.
    PostTerminalLocationsRequestBody
-> PostTerminalLocationsRequestBodyAddress'
postTerminalLocationsRequestBodyAddress :: PostTerminalLocationsRequestBodyAddress',
    -- | display_name: A name for the location.
    --
    -- Constraints:
    --
    -- * Maximum length of 1000
    PostTerminalLocationsRequestBody -> Text
postTerminalLocationsRequestBodyDisplayName :: Data.Text.Internal.Text,
    -- | expand: Specifies which fields in the response should be expanded.
    PostTerminalLocationsRequestBody -> Maybe [Text]
postTerminalLocationsRequestBodyExpand :: (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\`.
    PostTerminalLocationsRequestBody
-> Maybe PostTerminalLocationsRequestBodyMetadata'Variants
postTerminalLocationsRequestBodyMetadata :: (GHC.Maybe.Maybe PostTerminalLocationsRequestBodyMetadata'Variants)
  }
  deriving
    ( Int -> PostTerminalLocationsRequestBody -> ShowS
[PostTerminalLocationsRequestBody] -> ShowS
PostTerminalLocationsRequestBody -> String
(Int -> PostTerminalLocationsRequestBody -> ShowS)
-> (PostTerminalLocationsRequestBody -> String)
-> ([PostTerminalLocationsRequestBody] -> ShowS)
-> Show PostTerminalLocationsRequestBody
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PostTerminalLocationsRequestBody] -> ShowS
$cshowList :: [PostTerminalLocationsRequestBody] -> ShowS
show :: PostTerminalLocationsRequestBody -> String
$cshow :: PostTerminalLocationsRequestBody -> String
showsPrec :: Int -> PostTerminalLocationsRequestBody -> ShowS
$cshowsPrec :: Int -> PostTerminalLocationsRequestBody -> ShowS
GHC.Show.Show,
      PostTerminalLocationsRequestBody
-> PostTerminalLocationsRequestBody -> Bool
(PostTerminalLocationsRequestBody
 -> PostTerminalLocationsRequestBody -> Bool)
-> (PostTerminalLocationsRequestBody
    -> PostTerminalLocationsRequestBody -> Bool)
-> Eq PostTerminalLocationsRequestBody
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PostTerminalLocationsRequestBody
-> PostTerminalLocationsRequestBody -> Bool
$c/= :: PostTerminalLocationsRequestBody
-> PostTerminalLocationsRequestBody -> Bool
== :: PostTerminalLocationsRequestBody
-> PostTerminalLocationsRequestBody -> Bool
$c== :: PostTerminalLocationsRequestBody
-> PostTerminalLocationsRequestBody -> Bool
GHC.Classes.Eq
    )

instance Data.Aeson.Types.ToJSON.ToJSON PostTerminalLocationsRequestBody where
  toJSON :: PostTerminalLocationsRequestBody -> Value
toJSON PostTerminalLocationsRequestBody
obj = [Pair] -> Value
Data.Aeson.Types.Internal.object (Text
"address" Text -> PostTerminalLocationsRequestBodyAddress' -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PostTerminalLocationsRequestBody
-> PostTerminalLocationsRequestBodyAddress'
postTerminalLocationsRequestBodyAddress PostTerminalLocationsRequestBody
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"display_name" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PostTerminalLocationsRequestBody -> Text
postTerminalLocationsRequestBodyDisplayName PostTerminalLocationsRequestBody
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"expand" Text -> Maybe [Text] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PostTerminalLocationsRequestBody -> Maybe [Text]
postTerminalLocationsRequestBodyExpand PostTerminalLocationsRequestBody
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"metadata" Text
-> Maybe PostTerminalLocationsRequestBodyMetadata'Variants -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PostTerminalLocationsRequestBody
-> Maybe PostTerminalLocationsRequestBodyMetadata'Variants
postTerminalLocationsRequestBodyMetadata PostTerminalLocationsRequestBody
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: [Pair]
forall a. Monoid a => a
GHC.Base.mempty)
  toEncoding :: PostTerminalLocationsRequestBody -> Encoding
toEncoding PostTerminalLocationsRequestBody
obj = Series -> Encoding
Data.Aeson.Encoding.Internal.pairs ((Text
"address" Text -> PostTerminalLocationsRequestBodyAddress' -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PostTerminalLocationsRequestBody
-> PostTerminalLocationsRequestBodyAddress'
postTerminalLocationsRequestBodyAddress PostTerminalLocationsRequestBody
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"display_name" Text -> Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PostTerminalLocationsRequestBody -> Text
postTerminalLocationsRequestBodyDisplayName PostTerminalLocationsRequestBody
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"expand" Text -> Maybe [Text] -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PostTerminalLocationsRequestBody -> Maybe [Text]
postTerminalLocationsRequestBodyExpand PostTerminalLocationsRequestBody
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> (Text
"metadata" Text
-> Maybe PostTerminalLocationsRequestBodyMetadata'Variants
-> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PostTerminalLocationsRequestBody
-> Maybe PostTerminalLocationsRequestBodyMetadata'Variants
postTerminalLocationsRequestBodyMetadata PostTerminalLocationsRequestBody
obj))))

instance Data.Aeson.Types.FromJSON.FromJSON PostTerminalLocationsRequestBody where
  parseJSON :: Value -> Parser PostTerminalLocationsRequestBody
parseJSON = String
-> (Object -> Parser PostTerminalLocationsRequestBody)
-> Value
-> Parser PostTerminalLocationsRequestBody
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.Aeson.Types.FromJSON.withObject String
"PostTerminalLocationsRequestBody" (\Object
obj -> ((((PostTerminalLocationsRequestBodyAddress'
 -> Text
 -> Maybe [Text]
 -> Maybe PostTerminalLocationsRequestBodyMetadata'Variants
 -> PostTerminalLocationsRequestBody)
-> Parser
     (PostTerminalLocationsRequestBodyAddress'
      -> Text
      -> Maybe [Text]
      -> Maybe PostTerminalLocationsRequestBodyMetadata'Variants
      -> PostTerminalLocationsRequestBody)
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure PostTerminalLocationsRequestBodyAddress'
-> Text
-> Maybe [Text]
-> Maybe PostTerminalLocationsRequestBodyMetadata'Variants
-> PostTerminalLocationsRequestBody
PostTerminalLocationsRequestBody Parser
  (PostTerminalLocationsRequestBodyAddress'
   -> Text
   -> Maybe [Text]
   -> Maybe PostTerminalLocationsRequestBodyMetadata'Variants
   -> PostTerminalLocationsRequestBody)
-> Parser PostTerminalLocationsRequestBodyAddress'
-> Parser
     (Text
      -> Maybe [Text]
      -> Maybe PostTerminalLocationsRequestBodyMetadata'Variants
      -> PostTerminalLocationsRequestBody)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Text -> Parser PostTerminalLocationsRequestBodyAddress'
forall a. FromJSON a => Object -> Text -> Parser a
Data.Aeson.Types.FromJSON..: Text
"address")) Parser
  (Text
   -> Maybe [Text]
   -> Maybe PostTerminalLocationsRequestBodyMetadata'Variants
   -> PostTerminalLocationsRequestBody)
-> Parser Text
-> Parser
     (Maybe [Text]
      -> Maybe PostTerminalLocationsRequestBodyMetadata'Variants
      -> PostTerminalLocationsRequestBody)
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
"display_name")) Parser
  (Maybe [Text]
   -> Maybe PostTerminalLocationsRequestBodyMetadata'Variants
   -> PostTerminalLocationsRequestBody)
-> Parser (Maybe [Text])
-> Parser
     (Maybe PostTerminalLocationsRequestBodyMetadata'Variants
      -> PostTerminalLocationsRequestBody)
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 PostTerminalLocationsRequestBodyMetadata'Variants
   -> PostTerminalLocationsRequestBody)
-> Parser (Maybe PostTerminalLocationsRequestBodyMetadata'Variants)
-> Parser PostTerminalLocationsRequestBody
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object
-> Text
-> Parser (Maybe PostTerminalLocationsRequestBodyMetadata'Variants)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Text
"metadata"))

-- | Create a new 'PostTerminalLocationsRequestBody' with all required fields.
mkPostTerminalLocationsRequestBody ::
  -- | 'postTerminalLocationsRequestBodyAddress'
  PostTerminalLocationsRequestBodyAddress' ->
  -- | 'postTerminalLocationsRequestBodyDisplayName'
  Data.Text.Internal.Text ->
  PostTerminalLocationsRequestBody
mkPostTerminalLocationsRequestBody :: PostTerminalLocationsRequestBodyAddress'
-> Text -> PostTerminalLocationsRequestBody
mkPostTerminalLocationsRequestBody PostTerminalLocationsRequestBodyAddress'
postTerminalLocationsRequestBodyAddress Text
postTerminalLocationsRequestBodyDisplayName =
  PostTerminalLocationsRequestBody :: PostTerminalLocationsRequestBodyAddress'
-> Text
-> Maybe [Text]
-> Maybe PostTerminalLocationsRequestBodyMetadata'Variants
-> PostTerminalLocationsRequestBody
PostTerminalLocationsRequestBody
    { postTerminalLocationsRequestBodyAddress :: PostTerminalLocationsRequestBodyAddress'
postTerminalLocationsRequestBodyAddress = PostTerminalLocationsRequestBodyAddress'
postTerminalLocationsRequestBodyAddress,
      postTerminalLocationsRequestBodyDisplayName :: Text
postTerminalLocationsRequestBodyDisplayName = Text
postTerminalLocationsRequestBodyDisplayName,
      postTerminalLocationsRequestBodyExpand :: Maybe [Text]
postTerminalLocationsRequestBodyExpand = Maybe [Text]
forall a. Maybe a
GHC.Maybe.Nothing,
      postTerminalLocationsRequestBodyMetadata :: Maybe PostTerminalLocationsRequestBodyMetadata'Variants
postTerminalLocationsRequestBodyMetadata = Maybe PostTerminalLocationsRequestBodyMetadata'Variants
forall a. Maybe a
GHC.Maybe.Nothing
    }

-- | Defines the object schema located at @paths.\/v1\/terminal\/locations.POST.requestBody.content.application\/x-www-form-urlencoded.schema.properties.address@ in the specification.
--
-- The full address of the location.
data PostTerminalLocationsRequestBodyAddress' = PostTerminalLocationsRequestBodyAddress'
  { -- | city
    --
    -- Constraints:
    --
    -- * Maximum length of 5000
    PostTerminalLocationsRequestBodyAddress' -> Maybe Text
postTerminalLocationsRequestBodyAddress'City :: (GHC.Maybe.Maybe Data.Text.Internal.Text),
    -- | country
    --
    -- Constraints:
    --
    -- * Maximum length of 5000
    PostTerminalLocationsRequestBodyAddress' -> Text
postTerminalLocationsRequestBodyAddress'Country :: Data.Text.Internal.Text,
    -- | line1
    --
    -- Constraints:
    --
    -- * Maximum length of 5000
    PostTerminalLocationsRequestBodyAddress' -> Maybe Text
postTerminalLocationsRequestBodyAddress'Line1 :: (GHC.Maybe.Maybe Data.Text.Internal.Text),
    -- | line2
    --
    -- Constraints:
    --
    -- * Maximum length of 5000
    PostTerminalLocationsRequestBodyAddress' -> Maybe Text
postTerminalLocationsRequestBodyAddress'Line2 :: (GHC.Maybe.Maybe Data.Text.Internal.Text),
    -- | postal_code
    --
    -- Constraints:
    --
    -- * Maximum length of 5000
    PostTerminalLocationsRequestBodyAddress' -> Maybe Text
postTerminalLocationsRequestBodyAddress'PostalCode :: (GHC.Maybe.Maybe Data.Text.Internal.Text),
    -- | state
    --
    -- Constraints:
    --
    -- * Maximum length of 5000
    PostTerminalLocationsRequestBodyAddress' -> Maybe Text
postTerminalLocationsRequestBodyAddress'State :: (GHC.Maybe.Maybe Data.Text.Internal.Text)
  }
  deriving
    ( Int -> PostTerminalLocationsRequestBodyAddress' -> ShowS
[PostTerminalLocationsRequestBodyAddress'] -> ShowS
PostTerminalLocationsRequestBodyAddress' -> String
(Int -> PostTerminalLocationsRequestBodyAddress' -> ShowS)
-> (PostTerminalLocationsRequestBodyAddress' -> String)
-> ([PostTerminalLocationsRequestBodyAddress'] -> ShowS)
-> Show PostTerminalLocationsRequestBodyAddress'
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PostTerminalLocationsRequestBodyAddress'] -> ShowS
$cshowList :: [PostTerminalLocationsRequestBodyAddress'] -> ShowS
show :: PostTerminalLocationsRequestBodyAddress' -> String
$cshow :: PostTerminalLocationsRequestBodyAddress' -> String
showsPrec :: Int -> PostTerminalLocationsRequestBodyAddress' -> ShowS
$cshowsPrec :: Int -> PostTerminalLocationsRequestBodyAddress' -> ShowS
GHC.Show.Show,
      PostTerminalLocationsRequestBodyAddress'
-> PostTerminalLocationsRequestBodyAddress' -> Bool
(PostTerminalLocationsRequestBodyAddress'
 -> PostTerminalLocationsRequestBodyAddress' -> Bool)
-> (PostTerminalLocationsRequestBodyAddress'
    -> PostTerminalLocationsRequestBodyAddress' -> Bool)
-> Eq PostTerminalLocationsRequestBodyAddress'
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PostTerminalLocationsRequestBodyAddress'
-> PostTerminalLocationsRequestBodyAddress' -> Bool
$c/= :: PostTerminalLocationsRequestBodyAddress'
-> PostTerminalLocationsRequestBodyAddress' -> Bool
== :: PostTerminalLocationsRequestBodyAddress'
-> PostTerminalLocationsRequestBodyAddress' -> Bool
$c== :: PostTerminalLocationsRequestBodyAddress'
-> PostTerminalLocationsRequestBodyAddress' -> Bool
GHC.Classes.Eq
    )

instance Data.Aeson.Types.ToJSON.ToJSON PostTerminalLocationsRequestBodyAddress' where
  toJSON :: PostTerminalLocationsRequestBodyAddress' -> Value
toJSON PostTerminalLocationsRequestBodyAddress'
obj = [Pair] -> Value
Data.Aeson.Types.Internal.object (Text
"city" Text -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PostTerminalLocationsRequestBodyAddress' -> Maybe Text
postTerminalLocationsRequestBodyAddress'City PostTerminalLocationsRequestBodyAddress'
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"country" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PostTerminalLocationsRequestBodyAddress' -> Text
postTerminalLocationsRequestBodyAddress'Country PostTerminalLocationsRequestBodyAddress'
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"line1" Text -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PostTerminalLocationsRequestBodyAddress' -> Maybe Text
postTerminalLocationsRequestBodyAddress'Line1 PostTerminalLocationsRequestBodyAddress'
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"line2" Text -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PostTerminalLocationsRequestBodyAddress' -> Maybe Text
postTerminalLocationsRequestBodyAddress'Line2 PostTerminalLocationsRequestBodyAddress'
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"postal_code" Text -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PostTerminalLocationsRequestBodyAddress' -> Maybe Text
postTerminalLocationsRequestBodyAddress'PostalCode PostTerminalLocationsRequestBodyAddress'
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"state" Text -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PostTerminalLocationsRequestBodyAddress' -> Maybe Text
postTerminalLocationsRequestBodyAddress'State PostTerminalLocationsRequestBodyAddress'
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: [Pair]
forall a. Monoid a => a
GHC.Base.mempty)
  toEncoding :: PostTerminalLocationsRequestBodyAddress' -> Encoding
toEncoding PostTerminalLocationsRequestBodyAddress'
obj = Series -> Encoding
Data.Aeson.Encoding.Internal.pairs ((Text
"city" Text -> Maybe Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PostTerminalLocationsRequestBodyAddress' -> Maybe Text
postTerminalLocationsRequestBodyAddress'City PostTerminalLocationsRequestBodyAddress'
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"country" Text -> Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PostTerminalLocationsRequestBodyAddress' -> Text
postTerminalLocationsRequestBodyAddress'Country PostTerminalLocationsRequestBodyAddress'
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"line1" Text -> Maybe Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PostTerminalLocationsRequestBodyAddress' -> Maybe Text
postTerminalLocationsRequestBodyAddress'Line1 PostTerminalLocationsRequestBodyAddress'
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"line2" Text -> Maybe Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PostTerminalLocationsRequestBodyAddress' -> Maybe Text
postTerminalLocationsRequestBodyAddress'Line2 PostTerminalLocationsRequestBodyAddress'
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"postal_code" Text -> Maybe Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PostTerminalLocationsRequestBodyAddress' -> Maybe Text
postTerminalLocationsRequestBodyAddress'PostalCode PostTerminalLocationsRequestBodyAddress'
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> (Text
"state" Text -> Maybe Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PostTerminalLocationsRequestBodyAddress' -> Maybe Text
postTerminalLocationsRequestBodyAddress'State PostTerminalLocationsRequestBodyAddress'
obj))))))

instance Data.Aeson.Types.FromJSON.FromJSON PostTerminalLocationsRequestBodyAddress' where
  parseJSON :: Value -> Parser PostTerminalLocationsRequestBodyAddress'
parseJSON = String
-> (Object -> Parser PostTerminalLocationsRequestBodyAddress')
-> Value
-> Parser PostTerminalLocationsRequestBodyAddress'
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.Aeson.Types.FromJSON.withObject String
"PostTerminalLocationsRequestBodyAddress'" (\Object
obj -> ((((((Maybe Text
 -> Text
 -> Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> PostTerminalLocationsRequestBodyAddress')
-> Parser
     (Maybe Text
      -> Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> PostTerminalLocationsRequestBodyAddress')
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure Maybe Text
-> Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> PostTerminalLocationsRequestBodyAddress'
PostTerminalLocationsRequestBodyAddress' Parser
  (Maybe Text
   -> Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> PostTerminalLocationsRequestBodyAddress')
-> Parser (Maybe Text)
-> Parser
     (Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> PostTerminalLocationsRequestBodyAddress')
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
"city")) Parser
  (Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> PostTerminalLocationsRequestBodyAddress')
-> Parser Text
-> Parser
     (Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> PostTerminalLocationsRequestBodyAddress')
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
"country")) Parser
  (Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> PostTerminalLocationsRequestBodyAddress')
-> Parser (Maybe Text)
-> Parser
     (Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> PostTerminalLocationsRequestBodyAddress')
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
"line1")) Parser
  (Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> PostTerminalLocationsRequestBodyAddress')
-> Parser (Maybe Text)
-> Parser
     (Maybe Text
      -> Maybe Text -> PostTerminalLocationsRequestBodyAddress')
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
"line2")) Parser
  (Maybe Text
   -> Maybe Text -> PostTerminalLocationsRequestBodyAddress')
-> Parser (Maybe Text)
-> Parser (Maybe Text -> PostTerminalLocationsRequestBodyAddress')
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
"postal_code")) Parser (Maybe Text -> PostTerminalLocationsRequestBodyAddress')
-> Parser (Maybe Text)
-> Parser PostTerminalLocationsRequestBodyAddress'
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
"state"))

-- | Create a new 'PostTerminalLocationsRequestBodyAddress'' with all required fields.
mkPostTerminalLocationsRequestBodyAddress' ::
  -- | 'postTerminalLocationsRequestBodyAddress'Country'
  Data.Text.Internal.Text ->
  PostTerminalLocationsRequestBodyAddress'
mkPostTerminalLocationsRequestBodyAddress' :: Text -> PostTerminalLocationsRequestBodyAddress'
mkPostTerminalLocationsRequestBodyAddress' Text
postTerminalLocationsRequestBodyAddress'Country =
  PostTerminalLocationsRequestBodyAddress' :: Maybe Text
-> Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> PostTerminalLocationsRequestBodyAddress'
PostTerminalLocationsRequestBodyAddress'
    { postTerminalLocationsRequestBodyAddress'City :: Maybe Text
postTerminalLocationsRequestBodyAddress'City = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing,
      postTerminalLocationsRequestBodyAddress'Country :: Text
postTerminalLocationsRequestBodyAddress'Country = Text
postTerminalLocationsRequestBodyAddress'Country,
      postTerminalLocationsRequestBodyAddress'Line1 :: Maybe Text
postTerminalLocationsRequestBodyAddress'Line1 = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing,
      postTerminalLocationsRequestBodyAddress'Line2 :: Maybe Text
postTerminalLocationsRequestBodyAddress'Line2 = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing,
      postTerminalLocationsRequestBodyAddress'PostalCode :: Maybe Text
postTerminalLocationsRequestBodyAddress'PostalCode = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing,
      postTerminalLocationsRequestBodyAddress'State :: Maybe Text
postTerminalLocationsRequestBodyAddress'State = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing
    }

-- | Defines the oneOf schema located at @paths.\/v1\/terminal\/locations.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 PostTerminalLocationsRequestBodyMetadata'Variants
  = -- | Represents the JSON value @""@
    PostTerminalLocationsRequestBodyMetadata'EmptyString
  | PostTerminalLocationsRequestBodyMetadata'Object Data.Aeson.Types.Internal.Object
  deriving (Int -> PostTerminalLocationsRequestBodyMetadata'Variants -> ShowS
[PostTerminalLocationsRequestBodyMetadata'Variants] -> ShowS
PostTerminalLocationsRequestBodyMetadata'Variants -> String
(Int -> PostTerminalLocationsRequestBodyMetadata'Variants -> ShowS)
-> (PostTerminalLocationsRequestBodyMetadata'Variants -> String)
-> ([PostTerminalLocationsRequestBodyMetadata'Variants] -> ShowS)
-> Show PostTerminalLocationsRequestBodyMetadata'Variants
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PostTerminalLocationsRequestBodyMetadata'Variants] -> ShowS
$cshowList :: [PostTerminalLocationsRequestBodyMetadata'Variants] -> ShowS
show :: PostTerminalLocationsRequestBodyMetadata'Variants -> String
$cshow :: PostTerminalLocationsRequestBodyMetadata'Variants -> String
showsPrec :: Int -> PostTerminalLocationsRequestBodyMetadata'Variants -> ShowS
$cshowsPrec :: Int -> PostTerminalLocationsRequestBodyMetadata'Variants -> ShowS
GHC.Show.Show, PostTerminalLocationsRequestBodyMetadata'Variants
-> PostTerminalLocationsRequestBodyMetadata'Variants -> Bool
(PostTerminalLocationsRequestBodyMetadata'Variants
 -> PostTerminalLocationsRequestBodyMetadata'Variants -> Bool)
-> (PostTerminalLocationsRequestBodyMetadata'Variants
    -> PostTerminalLocationsRequestBodyMetadata'Variants -> Bool)
-> Eq PostTerminalLocationsRequestBodyMetadata'Variants
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PostTerminalLocationsRequestBodyMetadata'Variants
-> PostTerminalLocationsRequestBodyMetadata'Variants -> Bool
$c/= :: PostTerminalLocationsRequestBodyMetadata'Variants
-> PostTerminalLocationsRequestBodyMetadata'Variants -> Bool
== :: PostTerminalLocationsRequestBodyMetadata'Variants
-> PostTerminalLocationsRequestBodyMetadata'Variants -> Bool
$c== :: PostTerminalLocationsRequestBodyMetadata'Variants
-> PostTerminalLocationsRequestBodyMetadata'Variants -> Bool
GHC.Classes.Eq)

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

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

-- | Represents a response of the operation 'postTerminalLocations'.
--
-- 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), 'PostTerminalLocationsResponseError' is used.
data PostTerminalLocationsResponse
  = -- | Means either no matching case available or a parse error
    PostTerminalLocationsResponseError GHC.Base.String
  | -- | Successful response.
    PostTerminalLocationsResponse200 Terminal'location
  | -- | Error response.
    PostTerminalLocationsResponseDefault Error
  deriving (Int -> PostTerminalLocationsResponse -> ShowS
[PostTerminalLocationsResponse] -> ShowS
PostTerminalLocationsResponse -> String
(Int -> PostTerminalLocationsResponse -> ShowS)
-> (PostTerminalLocationsResponse -> String)
-> ([PostTerminalLocationsResponse] -> ShowS)
-> Show PostTerminalLocationsResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PostTerminalLocationsResponse] -> ShowS
$cshowList :: [PostTerminalLocationsResponse] -> ShowS
show :: PostTerminalLocationsResponse -> String
$cshow :: PostTerminalLocationsResponse -> String
showsPrec :: Int -> PostTerminalLocationsResponse -> ShowS
$cshowsPrec :: Int -> PostTerminalLocationsResponse -> ShowS
GHC.Show.Show, PostTerminalLocationsResponse
-> PostTerminalLocationsResponse -> Bool
(PostTerminalLocationsResponse
 -> PostTerminalLocationsResponse -> Bool)
-> (PostTerminalLocationsResponse
    -> PostTerminalLocationsResponse -> Bool)
-> Eq PostTerminalLocationsResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PostTerminalLocationsResponse
-> PostTerminalLocationsResponse -> Bool
$c/= :: PostTerminalLocationsResponse
-> PostTerminalLocationsResponse -> Bool
== :: PostTerminalLocationsResponse
-> PostTerminalLocationsResponse -> Bool
$c== :: PostTerminalLocationsResponse
-> PostTerminalLocationsResponse -> Bool
GHC.Classes.Eq)