{-# LANGUAGE ExplicitForAll #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE OverloadedStrings #-}
module StripeAPI.Operations.PostFileLinks 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
postFileLinks ::
forall m.
StripeAPI.Common.MonadHTTP m =>
PostFileLinksRequestBody ->
StripeAPI.Common.StripeT m (Network.HTTP.Client.Types.Response PostFileLinksResponse)
postFileLinks :: PostFileLinksRequestBody
-> StripeT m (Response PostFileLinksResponse)
postFileLinks PostFileLinksRequestBody
body =
(Response ByteString -> Response PostFileLinksResponse)
-> StripeT m (Response ByteString)
-> StripeT m (Response PostFileLinksResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
GHC.Base.fmap
( \Response ByteString
response_0 ->
(ByteString -> PostFileLinksResponse)
-> Response ByteString -> Response PostFileLinksResponse
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
GHC.Base.fmap
( (String -> PostFileLinksResponse)
-> (PostFileLinksResponse -> PostFileLinksResponse)
-> Either String PostFileLinksResponse
-> PostFileLinksResponse
forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
Data.Either.either String -> PostFileLinksResponse
PostFileLinksResponseError PostFileLinksResponse -> PostFileLinksResponse
forall a. a -> a
GHC.Base.id
(Either String PostFileLinksResponse -> PostFileLinksResponse)
-> (ByteString -> Either String PostFileLinksResponse)
-> ByteString
-> PostFileLinksResponse
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) ->
FileLink -> PostFileLinksResponse
PostFileLinksResponse200
(FileLink -> PostFileLinksResponse)
-> Either String FileLink -> Either String PostFileLinksResponse
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Data.Functor.<$> ( ByteString -> Either String FileLink
forall a. FromJSON a => ByteString -> Either String a
Data.Aeson.eitherDecodeStrict ByteString
body ::
Data.Either.Either
GHC.Base.String
FileLink
)
| 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 -> PostFileLinksResponse
PostFileLinksResponseDefault
(Error -> PostFileLinksResponse)
-> Either String Error -> Either String PostFileLinksResponse
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 PostFileLinksResponse
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 PostFileLinksRequestBody
-> 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/file_links") [QueryParameter]
forall a. Monoid a => a
GHC.Base.mempty (PostFileLinksRequestBody -> Maybe PostFileLinksRequestBody
forall a. a -> Maybe a
GHC.Maybe.Just PostFileLinksRequestBody
body) RequestBodyEncoding
StripeAPI.Common.RequestBodyEncodingFormData)
data PostFileLinksRequestBody = PostFileLinksRequestBody
{
PostFileLinksRequestBody -> Maybe [Text]
postFileLinksRequestBodyExpand :: (GHC.Maybe.Maybe ([Data.Text.Internal.Text])),
PostFileLinksRequestBody -> Maybe Int
postFileLinksRequestBodyExpiresAt :: (GHC.Maybe.Maybe GHC.Types.Int),
PostFileLinksRequestBody -> Text
postFileLinksRequestBodyFile :: Data.Text.Internal.Text,
PostFileLinksRequestBody
-> Maybe PostFileLinksRequestBodyMetadata'Variants
postFileLinksRequestBodyMetadata :: (GHC.Maybe.Maybe PostFileLinksRequestBodyMetadata'Variants)
}
deriving
( Int -> PostFileLinksRequestBody -> ShowS
[PostFileLinksRequestBody] -> ShowS
PostFileLinksRequestBody -> String
(Int -> PostFileLinksRequestBody -> ShowS)
-> (PostFileLinksRequestBody -> String)
-> ([PostFileLinksRequestBody] -> ShowS)
-> Show PostFileLinksRequestBody
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PostFileLinksRequestBody] -> ShowS
$cshowList :: [PostFileLinksRequestBody] -> ShowS
show :: PostFileLinksRequestBody -> String
$cshow :: PostFileLinksRequestBody -> String
showsPrec :: Int -> PostFileLinksRequestBody -> ShowS
$cshowsPrec :: Int -> PostFileLinksRequestBody -> ShowS
GHC.Show.Show,
PostFileLinksRequestBody -> PostFileLinksRequestBody -> Bool
(PostFileLinksRequestBody -> PostFileLinksRequestBody -> Bool)
-> (PostFileLinksRequestBody -> PostFileLinksRequestBody -> Bool)
-> Eq PostFileLinksRequestBody
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PostFileLinksRequestBody -> PostFileLinksRequestBody -> Bool
$c/= :: PostFileLinksRequestBody -> PostFileLinksRequestBody -> Bool
== :: PostFileLinksRequestBody -> PostFileLinksRequestBody -> Bool
$c== :: PostFileLinksRequestBody -> PostFileLinksRequestBody -> Bool
GHC.Classes.Eq
)
instance Data.Aeson.Types.ToJSON.ToJSON PostFileLinksRequestBody where
toJSON :: PostFileLinksRequestBody -> Value
toJSON PostFileLinksRequestBody
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..= PostFileLinksRequestBody -> Maybe [Text]
postFileLinksRequestBodyExpand PostFileLinksRequestBody
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"expires_at" Text -> Maybe Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PostFileLinksRequestBody -> Maybe Int
postFileLinksRequestBodyExpiresAt PostFileLinksRequestBody
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"file" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PostFileLinksRequestBody -> Text
postFileLinksRequestBodyFile PostFileLinksRequestBody
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"metadata" Text -> Maybe PostFileLinksRequestBodyMetadata'Variants -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PostFileLinksRequestBody
-> Maybe PostFileLinksRequestBodyMetadata'Variants
postFileLinksRequestBodyMetadata PostFileLinksRequestBody
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: [Pair]
forall a. Monoid a => a
GHC.Base.mempty)
toEncoding :: PostFileLinksRequestBody -> Encoding
toEncoding PostFileLinksRequestBody
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..= PostFileLinksRequestBody -> Maybe [Text]
postFileLinksRequestBodyExpand PostFileLinksRequestBody
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"expires_at" Text -> Maybe Int -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PostFileLinksRequestBody -> Maybe Int
postFileLinksRequestBodyExpiresAt PostFileLinksRequestBody
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"file" Text -> Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PostFileLinksRequestBody -> Text
postFileLinksRequestBodyFile PostFileLinksRequestBody
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> (Text
"metadata" Text -> Maybe PostFileLinksRequestBodyMetadata'Variants -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PostFileLinksRequestBody
-> Maybe PostFileLinksRequestBodyMetadata'Variants
postFileLinksRequestBodyMetadata PostFileLinksRequestBody
obj))))
instance Data.Aeson.Types.FromJSON.FromJSON PostFileLinksRequestBody where
parseJSON :: Value -> Parser PostFileLinksRequestBody
parseJSON = String
-> (Object -> Parser PostFileLinksRequestBody)
-> Value
-> Parser PostFileLinksRequestBody
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.Aeson.Types.FromJSON.withObject String
"PostFileLinksRequestBody" (\Object
obj -> ((((Maybe [Text]
-> Maybe Int
-> Text
-> Maybe PostFileLinksRequestBodyMetadata'Variants
-> PostFileLinksRequestBody)
-> Parser
(Maybe [Text]
-> Maybe Int
-> Text
-> Maybe PostFileLinksRequestBodyMetadata'Variants
-> PostFileLinksRequestBody)
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure Maybe [Text]
-> Maybe Int
-> Text
-> Maybe PostFileLinksRequestBodyMetadata'Variants
-> PostFileLinksRequestBody
PostFileLinksRequestBody Parser
(Maybe [Text]
-> Maybe Int
-> Text
-> Maybe PostFileLinksRequestBodyMetadata'Variants
-> PostFileLinksRequestBody)
-> Parser (Maybe [Text])
-> Parser
(Maybe Int
-> Text
-> Maybe PostFileLinksRequestBodyMetadata'Variants
-> PostFileLinksRequestBody)
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 Int
-> Text
-> Maybe PostFileLinksRequestBodyMetadata'Variants
-> PostFileLinksRequestBody)
-> Parser (Maybe Int)
-> Parser
(Text
-> Maybe PostFileLinksRequestBodyMetadata'Variants
-> PostFileLinksRequestBody)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Text -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Text
"expires_at")) Parser
(Text
-> Maybe PostFileLinksRequestBodyMetadata'Variants
-> PostFileLinksRequestBody)
-> Parser Text
-> Parser
(Maybe PostFileLinksRequestBodyMetadata'Variants
-> PostFileLinksRequestBody)
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
"file")) Parser
(Maybe PostFileLinksRequestBodyMetadata'Variants
-> PostFileLinksRequestBody)
-> Parser (Maybe PostFileLinksRequestBodyMetadata'Variants)
-> Parser PostFileLinksRequestBody
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object
-> Text -> Parser (Maybe PostFileLinksRequestBodyMetadata'Variants)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Text
"metadata"))
mkPostFileLinksRequestBody ::
Data.Text.Internal.Text ->
PostFileLinksRequestBody
mkPostFileLinksRequestBody :: Text -> PostFileLinksRequestBody
mkPostFileLinksRequestBody Text
postFileLinksRequestBodyFile =
PostFileLinksRequestBody :: Maybe [Text]
-> Maybe Int
-> Text
-> Maybe PostFileLinksRequestBodyMetadata'Variants
-> PostFileLinksRequestBody
PostFileLinksRequestBody
{ postFileLinksRequestBodyExpand :: Maybe [Text]
postFileLinksRequestBodyExpand = Maybe [Text]
forall a. Maybe a
GHC.Maybe.Nothing,
postFileLinksRequestBodyExpiresAt :: Maybe Int
postFileLinksRequestBodyExpiresAt = Maybe Int
forall a. Maybe a
GHC.Maybe.Nothing,
postFileLinksRequestBodyFile :: Text
postFileLinksRequestBodyFile = Text
postFileLinksRequestBodyFile,
postFileLinksRequestBodyMetadata :: Maybe PostFileLinksRequestBodyMetadata'Variants
postFileLinksRequestBodyMetadata = Maybe PostFileLinksRequestBodyMetadata'Variants
forall a. Maybe a
GHC.Maybe.Nothing
}
data PostFileLinksRequestBodyMetadata'Variants
=
PostFileLinksRequestBodyMetadata'EmptyString
| PostFileLinksRequestBodyMetadata'Object Data.Aeson.Types.Internal.Object
deriving (Int -> PostFileLinksRequestBodyMetadata'Variants -> ShowS
[PostFileLinksRequestBodyMetadata'Variants] -> ShowS
PostFileLinksRequestBodyMetadata'Variants -> String
(Int -> PostFileLinksRequestBodyMetadata'Variants -> ShowS)
-> (PostFileLinksRequestBodyMetadata'Variants -> String)
-> ([PostFileLinksRequestBodyMetadata'Variants] -> ShowS)
-> Show PostFileLinksRequestBodyMetadata'Variants
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PostFileLinksRequestBodyMetadata'Variants] -> ShowS
$cshowList :: [PostFileLinksRequestBodyMetadata'Variants] -> ShowS
show :: PostFileLinksRequestBodyMetadata'Variants -> String
$cshow :: PostFileLinksRequestBodyMetadata'Variants -> String
showsPrec :: Int -> PostFileLinksRequestBodyMetadata'Variants -> ShowS
$cshowsPrec :: Int -> PostFileLinksRequestBodyMetadata'Variants -> ShowS
GHC.Show.Show, PostFileLinksRequestBodyMetadata'Variants
-> PostFileLinksRequestBodyMetadata'Variants -> Bool
(PostFileLinksRequestBodyMetadata'Variants
-> PostFileLinksRequestBodyMetadata'Variants -> Bool)
-> (PostFileLinksRequestBodyMetadata'Variants
-> PostFileLinksRequestBodyMetadata'Variants -> Bool)
-> Eq PostFileLinksRequestBodyMetadata'Variants
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PostFileLinksRequestBodyMetadata'Variants
-> PostFileLinksRequestBodyMetadata'Variants -> Bool
$c/= :: PostFileLinksRequestBodyMetadata'Variants
-> PostFileLinksRequestBodyMetadata'Variants -> Bool
== :: PostFileLinksRequestBodyMetadata'Variants
-> PostFileLinksRequestBodyMetadata'Variants -> Bool
$c== :: PostFileLinksRequestBodyMetadata'Variants
-> PostFileLinksRequestBodyMetadata'Variants -> Bool
GHC.Classes.Eq)
instance Data.Aeson.Types.ToJSON.ToJSON PostFileLinksRequestBodyMetadata'Variants where
toJSON :: PostFileLinksRequestBodyMetadata'Variants -> Value
toJSON (PostFileLinksRequestBodyMetadata'Object Object
a) = Object -> Value
forall a. ToJSON a => a -> Value
Data.Aeson.Types.ToJSON.toJSON Object
a
toJSON (PostFileLinksRequestBodyMetadata'Variants
PostFileLinksRequestBodyMetadata'EmptyString) = Value
""
instance Data.Aeson.Types.FromJSON.FromJSON PostFileLinksRequestBodyMetadata'Variants where
parseJSON :: Value -> Parser PostFileLinksRequestBodyMetadata'Variants
parseJSON Value
val =
if
| Value
val Value -> Value -> Bool
forall a. Eq a => a -> a -> Bool
GHC.Classes.== Value
"" -> PostFileLinksRequestBodyMetadata'Variants
-> Parser PostFileLinksRequestBodyMetadata'Variants
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure PostFileLinksRequestBodyMetadata'Variants
PostFileLinksRequestBodyMetadata'EmptyString
| Bool
GHC.Base.otherwise -> case (Object -> PostFileLinksRequestBodyMetadata'Variants
PostFileLinksRequestBodyMetadata'Object (Object -> PostFileLinksRequestBodyMetadata'Variants)
-> Result Object
-> Result PostFileLinksRequestBodyMetadata'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 PostFileLinksRequestBodyMetadata'Variants
-> Result PostFileLinksRequestBodyMetadata'Variants
-> Result PostFileLinksRequestBodyMetadata'Variants
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
GHC.Base.<|> String -> Result PostFileLinksRequestBodyMetadata'Variants
forall a. String -> Result a
Data.Aeson.Types.Internal.Error String
"No variant matched" of
Data.Aeson.Types.Internal.Success PostFileLinksRequestBodyMetadata'Variants
a -> PostFileLinksRequestBodyMetadata'Variants
-> Parser PostFileLinksRequestBodyMetadata'Variants
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure PostFileLinksRequestBodyMetadata'Variants
a
Data.Aeson.Types.Internal.Error String
a -> String -> Parser PostFileLinksRequestBodyMetadata'Variants
forall (m :: * -> *) a. MonadFail m => String -> m a
Control.Monad.Fail.fail String
a
data PostFileLinksResponse
=
PostFileLinksResponseError GHC.Base.String
|
PostFileLinksResponse200 FileLink
|
PostFileLinksResponseDefault Error
deriving (Int -> PostFileLinksResponse -> ShowS
[PostFileLinksResponse] -> ShowS
PostFileLinksResponse -> String
(Int -> PostFileLinksResponse -> ShowS)
-> (PostFileLinksResponse -> String)
-> ([PostFileLinksResponse] -> ShowS)
-> Show PostFileLinksResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PostFileLinksResponse] -> ShowS
$cshowList :: [PostFileLinksResponse] -> ShowS
show :: PostFileLinksResponse -> String
$cshow :: PostFileLinksResponse -> String
showsPrec :: Int -> PostFileLinksResponse -> ShowS
$cshowsPrec :: Int -> PostFileLinksResponse -> ShowS
GHC.Show.Show, PostFileLinksResponse -> PostFileLinksResponse -> Bool
(PostFileLinksResponse -> PostFileLinksResponse -> Bool)
-> (PostFileLinksResponse -> PostFileLinksResponse -> Bool)
-> Eq PostFileLinksResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PostFileLinksResponse -> PostFileLinksResponse -> Bool
$c/= :: PostFileLinksResponse -> PostFileLinksResponse -> Bool
== :: PostFileLinksResponse -> PostFileLinksResponse -> Bool
$c== :: PostFileLinksResponse -> PostFileLinksResponse -> Bool
GHC.Classes.Eq)