{-# 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 deleteAccountsAccountBankAccountsId
module StripeAPI.Operations.DeleteAccountsAccountBankAccountsId 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

-- | > DELETE /v1/accounts/{account}/bank_accounts/{id}
--
-- \<p>Delete a specified external account for a given account.\<\/p>
deleteAccountsAccountBankAccountsId ::
  forall m.
  StripeAPI.Common.MonadHTTP m =>
  -- | Contains all available parameters of this operation (query and path parameters)
  DeleteAccountsAccountBankAccountsIdParameters ->
  -- | Monadic computation which returns the result of the operation
  StripeAPI.Common.StripeT m (Network.HTTP.Client.Types.Response DeleteAccountsAccountBankAccountsIdResponse)
deleteAccountsAccountBankAccountsId :: DeleteAccountsAccountBankAccountsIdParameters
-> StripeT m (Response DeleteAccountsAccountBankAccountsIdResponse)
deleteAccountsAccountBankAccountsId DeleteAccountsAccountBankAccountsIdParameters
parameters =
  (Response ByteString
 -> Response DeleteAccountsAccountBankAccountsIdResponse)
-> StripeT m (Response ByteString)
-> StripeT m (Response DeleteAccountsAccountBankAccountsIdResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
GHC.Base.fmap
    ( \Response ByteString
response_0 ->
        (ByteString -> DeleteAccountsAccountBankAccountsIdResponse)
-> Response ByteString
-> Response DeleteAccountsAccountBankAccountsIdResponse
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
GHC.Base.fmap
          ( (String -> DeleteAccountsAccountBankAccountsIdResponse)
-> (DeleteAccountsAccountBankAccountsIdResponse
    -> DeleteAccountsAccountBankAccountsIdResponse)
-> Either String DeleteAccountsAccountBankAccountsIdResponse
-> DeleteAccountsAccountBankAccountsIdResponse
forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
Data.Either.either String -> DeleteAccountsAccountBankAccountsIdResponse
DeleteAccountsAccountBankAccountsIdResponseError DeleteAccountsAccountBankAccountsIdResponse
-> DeleteAccountsAccountBankAccountsIdResponse
forall a. a -> a
GHC.Base.id
              (Either String DeleteAccountsAccountBankAccountsIdResponse
 -> DeleteAccountsAccountBankAccountsIdResponse)
-> (ByteString
    -> Either String DeleteAccountsAccountBankAccountsIdResponse)
-> ByteString
-> DeleteAccountsAccountBankAccountsIdResponse
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) ->
                                   DeletedExternalAccount
-> DeleteAccountsAccountBankAccountsIdResponse
DeleteAccountsAccountBankAccountsIdResponse200
                                     (DeletedExternalAccount
 -> DeleteAccountsAccountBankAccountsIdResponse)
-> Either String DeletedExternalAccount
-> Either String DeleteAccountsAccountBankAccountsIdResponse
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Data.Functor.<$> ( ByteString -> Either String DeletedExternalAccount
forall a. FromJSON a => ByteString -> Either String a
Data.Aeson.eitherDecodeStrict ByteString
body ::
                                                          Data.Either.Either
                                                            GHC.Base.String
                                                            DeletedExternalAccount
                                                      )
                                 | 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 -> DeleteAccountsAccountBankAccountsIdResponse
DeleteAccountsAccountBankAccountsIdResponseDefault
                                     (Error -> DeleteAccountsAccountBankAccountsIdResponse)
-> Either String Error
-> Either String DeleteAccountsAccountBankAccountsIdResponse
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 DeleteAccountsAccountBankAccountsIdResponse
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] -> StripeT m (Response ByteString)
forall (m :: * -> *).
MonadHTTP m =>
Text -> Text -> [QueryParameter] -> StripeT m (Response ByteString)
StripeAPI.Common.doCallWithConfigurationM (Text -> Text
Data.Text.toUpper (Text -> Text) -> Text -> Text
forall a b. (a -> b) -> a -> b
GHC.Base.$ String -> Text
Data.Text.pack String
"DELETE") (String -> Text
Data.Text.pack (String
"/v1/accounts/" String -> String -> String
forall a. [a] -> [a] -> [a]
GHC.Base.++ (ByteString -> String
Data.ByteString.Char8.unpack (Bool -> ByteString -> ByteString
Network.HTTP.Types.URI.urlEncode Bool
GHC.Types.True (ByteString -> ByteString) -> ByteString -> ByteString
forall a b. (a -> b) -> a -> b
GHC.Base.$ (String -> ByteString
Data.ByteString.Char8.pack (String -> ByteString) -> String -> ByteString
forall a b. (a -> b) -> a -> b
GHC.Base.$ Text -> String
forall a. StringifyModel a => a -> String
StripeAPI.Common.stringifyModel (DeleteAccountsAccountBankAccountsIdParameters -> Text
deleteAccountsAccountBankAccountsIdParametersPathAccount DeleteAccountsAccountBankAccountsIdParameters
parameters))) String -> String -> String
forall a. [a] -> [a] -> [a]
GHC.Base.++ (String
"/bank_accounts/" String -> String -> String
forall a. [a] -> [a] -> [a]
GHC.Base.++ (ByteString -> String
Data.ByteString.Char8.unpack (Bool -> ByteString -> ByteString
Network.HTTP.Types.URI.urlEncode Bool
GHC.Types.True (ByteString -> ByteString) -> ByteString -> ByteString
forall a b. (a -> b) -> a -> b
GHC.Base.$ (String -> ByteString
Data.ByteString.Char8.pack (String -> ByteString) -> String -> ByteString
forall a b. (a -> b) -> a -> b
GHC.Base.$ Text -> String
forall a. StringifyModel a => a -> String
StripeAPI.Common.stringifyModel (DeleteAccountsAccountBankAccountsIdParameters -> Text
deleteAccountsAccountBankAccountsIdParametersPathId DeleteAccountsAccountBankAccountsIdParameters
parameters))) String -> String -> String
forall a. [a] -> [a] -> [a]
GHC.Base.++ String
""))))) [QueryParameter]
forall a. Monoid a => a
GHC.Base.mempty)

-- | Defines the object schema located at @paths.\/v1\/accounts\/{account}\/bank_accounts\/{id}.DELETE.parameters@ in the specification.
data DeleteAccountsAccountBankAccountsIdParameters = DeleteAccountsAccountBankAccountsIdParameters
  { -- | pathAccount: Represents the parameter named \'account\'
    --
    -- Constraints:
    --
    -- * Maximum length of 5000
    DeleteAccountsAccountBankAccountsIdParameters -> Text
deleteAccountsAccountBankAccountsIdParametersPathAccount :: Data.Text.Internal.Text,
    -- | pathId: Represents the parameter named \'id\'
    DeleteAccountsAccountBankAccountsIdParameters -> Text
deleteAccountsAccountBankAccountsIdParametersPathId :: Data.Text.Internal.Text
  }
  deriving
    ( Int
-> DeleteAccountsAccountBankAccountsIdParameters
-> String
-> String
[DeleteAccountsAccountBankAccountsIdParameters] -> String -> String
DeleteAccountsAccountBankAccountsIdParameters -> String
(Int
 -> DeleteAccountsAccountBankAccountsIdParameters
 -> String
 -> String)
-> (DeleteAccountsAccountBankAccountsIdParameters -> String)
-> ([DeleteAccountsAccountBankAccountsIdParameters]
    -> String -> String)
-> Show DeleteAccountsAccountBankAccountsIdParameters
forall a.
(Int -> a -> String -> String)
-> (a -> String) -> ([a] -> String -> String) -> Show a
showList :: [DeleteAccountsAccountBankAccountsIdParameters] -> String -> String
$cshowList :: [DeleteAccountsAccountBankAccountsIdParameters] -> String -> String
show :: DeleteAccountsAccountBankAccountsIdParameters -> String
$cshow :: DeleteAccountsAccountBankAccountsIdParameters -> String
showsPrec :: Int
-> DeleteAccountsAccountBankAccountsIdParameters
-> String
-> String
$cshowsPrec :: Int
-> DeleteAccountsAccountBankAccountsIdParameters
-> String
-> String
GHC.Show.Show,
      DeleteAccountsAccountBankAccountsIdParameters
-> DeleteAccountsAccountBankAccountsIdParameters -> Bool
(DeleteAccountsAccountBankAccountsIdParameters
 -> DeleteAccountsAccountBankAccountsIdParameters -> Bool)
-> (DeleteAccountsAccountBankAccountsIdParameters
    -> DeleteAccountsAccountBankAccountsIdParameters -> Bool)
-> Eq DeleteAccountsAccountBankAccountsIdParameters
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteAccountsAccountBankAccountsIdParameters
-> DeleteAccountsAccountBankAccountsIdParameters -> Bool
$c/= :: DeleteAccountsAccountBankAccountsIdParameters
-> DeleteAccountsAccountBankAccountsIdParameters -> Bool
== :: DeleteAccountsAccountBankAccountsIdParameters
-> DeleteAccountsAccountBankAccountsIdParameters -> Bool
$c== :: DeleteAccountsAccountBankAccountsIdParameters
-> DeleteAccountsAccountBankAccountsIdParameters -> Bool
GHC.Classes.Eq
    )

instance Data.Aeson.Types.ToJSON.ToJSON DeleteAccountsAccountBankAccountsIdParameters where
  toJSON :: DeleteAccountsAccountBankAccountsIdParameters -> Value
toJSON DeleteAccountsAccountBankAccountsIdParameters
obj = [Pair] -> Value
Data.Aeson.Types.Internal.object (Text
"pathAccount" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= DeleteAccountsAccountBankAccountsIdParameters -> Text
deleteAccountsAccountBankAccountsIdParametersPathAccount DeleteAccountsAccountBankAccountsIdParameters
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"pathId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= DeleteAccountsAccountBankAccountsIdParameters -> Text
deleteAccountsAccountBankAccountsIdParametersPathId DeleteAccountsAccountBankAccountsIdParameters
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: [Pair]
forall a. Monoid a => a
GHC.Base.mempty)
  toEncoding :: DeleteAccountsAccountBankAccountsIdParameters -> Encoding
toEncoding DeleteAccountsAccountBankAccountsIdParameters
obj = Series -> Encoding
Data.Aeson.Encoding.Internal.pairs ((Text
"pathAccount" Text -> Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= DeleteAccountsAccountBankAccountsIdParameters -> Text
deleteAccountsAccountBankAccountsIdParametersPathAccount DeleteAccountsAccountBankAccountsIdParameters
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> (Text
"pathId" Text -> Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= DeleteAccountsAccountBankAccountsIdParameters -> Text
deleteAccountsAccountBankAccountsIdParametersPathId DeleteAccountsAccountBankAccountsIdParameters
obj))

instance Data.Aeson.Types.FromJSON.FromJSON DeleteAccountsAccountBankAccountsIdParameters where
  parseJSON :: Value -> Parser DeleteAccountsAccountBankAccountsIdParameters
parseJSON = String
-> (Object -> Parser DeleteAccountsAccountBankAccountsIdParameters)
-> Value
-> Parser DeleteAccountsAccountBankAccountsIdParameters
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.Aeson.Types.FromJSON.withObject String
"DeleteAccountsAccountBankAccountsIdParameters" (\Object
obj -> ((Text -> Text -> DeleteAccountsAccountBankAccountsIdParameters)
-> Parser
     (Text -> Text -> DeleteAccountsAccountBankAccountsIdParameters)
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure Text -> Text -> DeleteAccountsAccountBankAccountsIdParameters
DeleteAccountsAccountBankAccountsIdParameters Parser
  (Text -> Text -> DeleteAccountsAccountBankAccountsIdParameters)
-> Parser Text
-> Parser (Text -> DeleteAccountsAccountBankAccountsIdParameters)
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
"pathAccount")) Parser (Text -> DeleteAccountsAccountBankAccountsIdParameters)
-> Parser Text
-> Parser DeleteAccountsAccountBankAccountsIdParameters
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
"pathId"))

-- | Create a new 'DeleteAccountsAccountBankAccountsIdParameters' with all required fields.
mkDeleteAccountsAccountBankAccountsIdParameters ::
  -- | 'deleteAccountsAccountBankAccountsIdParametersPathAccount'
  Data.Text.Internal.Text ->
  -- | 'deleteAccountsAccountBankAccountsIdParametersPathId'
  Data.Text.Internal.Text ->
  DeleteAccountsAccountBankAccountsIdParameters
mkDeleteAccountsAccountBankAccountsIdParameters :: Text -> Text -> DeleteAccountsAccountBankAccountsIdParameters
mkDeleteAccountsAccountBankAccountsIdParameters Text
deleteAccountsAccountBankAccountsIdParametersPathAccount Text
deleteAccountsAccountBankAccountsIdParametersPathId =
  DeleteAccountsAccountBankAccountsIdParameters :: Text -> Text -> DeleteAccountsAccountBankAccountsIdParameters
DeleteAccountsAccountBankAccountsIdParameters
    { deleteAccountsAccountBankAccountsIdParametersPathAccount :: Text
deleteAccountsAccountBankAccountsIdParametersPathAccount = Text
deleteAccountsAccountBankAccountsIdParametersPathAccount,
      deleteAccountsAccountBankAccountsIdParametersPathId :: Text
deleteAccountsAccountBankAccountsIdParametersPathId = Text
deleteAccountsAccountBankAccountsIdParametersPathId
    }

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