{-# 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 getCheckoutSessions
module StripeAPI.Operations.GetCheckoutSessions 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

-- | > GET /v1/checkout/sessions
--
-- \<p>Returns a list of Checkout Sessions.\<\/p>
getCheckoutSessions ::
  forall m.
  StripeAPI.Common.MonadHTTP m =>
  -- | Contains all available parameters of this operation (query and path parameters)
  GetCheckoutSessionsParameters ->
  -- | Monadic computation which returns the result of the operation
  StripeAPI.Common.StripeT m (Network.HTTP.Client.Types.Response GetCheckoutSessionsResponse)
getCheckoutSessions :: GetCheckoutSessionsParameters
-> StripeT m (Response GetCheckoutSessionsResponse)
getCheckoutSessions GetCheckoutSessionsParameters
parameters =
  (Response ByteString -> Response GetCheckoutSessionsResponse)
-> StripeT m (Response ByteString)
-> StripeT m (Response GetCheckoutSessionsResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
GHC.Base.fmap
    ( \Response ByteString
response_0 ->
        (ByteString -> GetCheckoutSessionsResponse)
-> Response ByteString -> Response GetCheckoutSessionsResponse
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
GHC.Base.fmap
          ( (String -> GetCheckoutSessionsResponse)
-> (GetCheckoutSessionsResponse -> GetCheckoutSessionsResponse)
-> Either String GetCheckoutSessionsResponse
-> GetCheckoutSessionsResponse
forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
Data.Either.either String -> GetCheckoutSessionsResponse
GetCheckoutSessionsResponseError GetCheckoutSessionsResponse -> GetCheckoutSessionsResponse
forall a. a -> a
GHC.Base.id
              (Either String GetCheckoutSessionsResponse
 -> GetCheckoutSessionsResponse)
-> (ByteString -> Either String GetCheckoutSessionsResponse)
-> ByteString
-> GetCheckoutSessionsResponse
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) ->
                                   GetCheckoutSessionsResponseBody200 -> GetCheckoutSessionsResponse
GetCheckoutSessionsResponse200
                                     (GetCheckoutSessionsResponseBody200 -> GetCheckoutSessionsResponse)
-> Either String GetCheckoutSessionsResponseBody200
-> Either String GetCheckoutSessionsResponse
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Data.Functor.<$> ( ByteString -> Either String GetCheckoutSessionsResponseBody200
forall a. FromJSON a => ByteString -> Either String a
Data.Aeson.eitherDecodeStrict ByteString
body ::
                                                          Data.Either.Either
                                                            GHC.Base.String
                                                            GetCheckoutSessionsResponseBody200
                                                      )
                                 | 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 -> GetCheckoutSessionsResponse
GetCheckoutSessionsResponseDefault
                                     (Error -> GetCheckoutSessionsResponse)
-> Either String Error -> Either String GetCheckoutSessionsResponse
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 GetCheckoutSessionsResponse
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
"GET")
        (String -> Text
Data.Text.pack String
"/v1/checkout/sessions")
        [ Text -> Maybe Value -> Text -> Bool -> QueryParameter
StripeAPI.Common.QueryParameter (String -> Text
Data.Text.pack String
"ending_before") (Text -> Value
forall a. ToJSON a => a -> Value
Data.Aeson.Types.ToJSON.toJSON (Text -> Value) -> Maybe Text -> Maybe Value
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Data.Functor.<$> GetCheckoutSessionsParameters -> Maybe Text
getCheckoutSessionsParametersQueryEndingBefore GetCheckoutSessionsParameters
parameters) (String -> Text
Data.Text.pack String
"form") Bool
GHC.Types.True,
          Text -> Maybe Value -> Text -> Bool -> QueryParameter
StripeAPI.Common.QueryParameter (String -> Text
Data.Text.pack String
"expand") ([Text] -> Value
forall a. ToJSON a => a -> Value
Data.Aeson.Types.ToJSON.toJSON ([Text] -> Value) -> Maybe [Text] -> Maybe Value
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Data.Functor.<$> GetCheckoutSessionsParameters -> Maybe [Text]
getCheckoutSessionsParametersQueryExpand GetCheckoutSessionsParameters
parameters) (String -> Text
Data.Text.pack String
"deepObject") Bool
GHC.Types.True,
          Text -> Maybe Value -> Text -> Bool -> QueryParameter
StripeAPI.Common.QueryParameter (String -> Text
Data.Text.pack String
"limit") (Int -> Value
forall a. ToJSON a => a -> Value
Data.Aeson.Types.ToJSON.toJSON (Int -> Value) -> Maybe Int -> Maybe Value
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Data.Functor.<$> GetCheckoutSessionsParameters -> Maybe Int
getCheckoutSessionsParametersQueryLimit GetCheckoutSessionsParameters
parameters) (String -> Text
Data.Text.pack String
"form") Bool
GHC.Types.True,
          Text -> Maybe Value -> Text -> Bool -> QueryParameter
StripeAPI.Common.QueryParameter (String -> Text
Data.Text.pack String
"payment_intent") (Text -> Value
forall a. ToJSON a => a -> Value
Data.Aeson.Types.ToJSON.toJSON (Text -> Value) -> Maybe Text -> Maybe Value
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Data.Functor.<$> GetCheckoutSessionsParameters -> Maybe Text
getCheckoutSessionsParametersQueryPaymentIntent GetCheckoutSessionsParameters
parameters) (String -> Text
Data.Text.pack String
"form") Bool
GHC.Types.True,
          Text -> Maybe Value -> Text -> Bool -> QueryParameter
StripeAPI.Common.QueryParameter (String -> Text
Data.Text.pack String
"starting_after") (Text -> Value
forall a. ToJSON a => a -> Value
Data.Aeson.Types.ToJSON.toJSON (Text -> Value) -> Maybe Text -> Maybe Value
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Data.Functor.<$> GetCheckoutSessionsParameters -> Maybe Text
getCheckoutSessionsParametersQueryStartingAfter GetCheckoutSessionsParameters
parameters) (String -> Text
Data.Text.pack String
"form") Bool
GHC.Types.True,
          Text -> Maybe Value -> Text -> Bool -> QueryParameter
StripeAPI.Common.QueryParameter (String -> Text
Data.Text.pack String
"subscription") (Text -> Value
forall a. ToJSON a => a -> Value
Data.Aeson.Types.ToJSON.toJSON (Text -> Value) -> Maybe Text -> Maybe Value
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Data.Functor.<$> GetCheckoutSessionsParameters -> Maybe Text
getCheckoutSessionsParametersQuerySubscription GetCheckoutSessionsParameters
parameters) (String -> Text
Data.Text.pack String
"form") Bool
GHC.Types.True
        ]
    )

-- | Defines the object schema located at @paths.\/v1\/checkout\/sessions.GET.parameters@ in the specification.
data GetCheckoutSessionsParameters = GetCheckoutSessionsParameters
  { -- | queryEnding_before: Represents the parameter named \'ending_before\'
    --
    -- A cursor for use in pagination. \`ending_before\` is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, starting with \`obj_bar\`, your subsequent call can include \`ending_before=obj_bar\` in order to fetch the previous page of the list.
    --
    -- Constraints:
    --
    -- * Maximum length of 5000
    GetCheckoutSessionsParameters -> Maybe Text
getCheckoutSessionsParametersQueryEndingBefore :: (GHC.Maybe.Maybe Data.Text.Internal.Text),
    -- | queryExpand: Represents the parameter named \'expand\'
    --
    -- Specifies which fields in the response should be expanded.
    GetCheckoutSessionsParameters -> Maybe [Text]
getCheckoutSessionsParametersQueryExpand :: (GHC.Maybe.Maybe ([Data.Text.Internal.Text])),
    -- | queryLimit: Represents the parameter named \'limit\'
    --
    -- A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 10.
    GetCheckoutSessionsParameters -> Maybe Int
getCheckoutSessionsParametersQueryLimit :: (GHC.Maybe.Maybe GHC.Types.Int),
    -- | queryPayment_intent: Represents the parameter named \'payment_intent\'
    --
    -- Only return the Checkout Session for the PaymentIntent specified.
    --
    -- Constraints:
    --
    -- * Maximum length of 5000
    GetCheckoutSessionsParameters -> Maybe Text
getCheckoutSessionsParametersQueryPaymentIntent :: (GHC.Maybe.Maybe Data.Text.Internal.Text),
    -- | queryStarting_after: Represents the parameter named \'starting_after\'
    --
    -- A cursor for use in pagination. \`starting_after\` is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with \`obj_foo\`, your subsequent call can include \`starting_after=obj_foo\` in order to fetch the next page of the list.
    --
    -- Constraints:
    --
    -- * Maximum length of 5000
    GetCheckoutSessionsParameters -> Maybe Text
getCheckoutSessionsParametersQueryStartingAfter :: (GHC.Maybe.Maybe Data.Text.Internal.Text),
    -- | querySubscription: Represents the parameter named \'subscription\'
    --
    -- Only return the Checkout Session for the subscription specified.
    --
    -- Constraints:
    --
    -- * Maximum length of 5000
    GetCheckoutSessionsParameters -> Maybe Text
getCheckoutSessionsParametersQuerySubscription :: (GHC.Maybe.Maybe Data.Text.Internal.Text)
  }
  deriving
    ( Int -> GetCheckoutSessionsParameters -> ShowS
[GetCheckoutSessionsParameters] -> ShowS
GetCheckoutSessionsParameters -> String
(Int -> GetCheckoutSessionsParameters -> ShowS)
-> (GetCheckoutSessionsParameters -> String)
-> ([GetCheckoutSessionsParameters] -> ShowS)
-> Show GetCheckoutSessionsParameters
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetCheckoutSessionsParameters] -> ShowS
$cshowList :: [GetCheckoutSessionsParameters] -> ShowS
show :: GetCheckoutSessionsParameters -> String
$cshow :: GetCheckoutSessionsParameters -> String
showsPrec :: Int -> GetCheckoutSessionsParameters -> ShowS
$cshowsPrec :: Int -> GetCheckoutSessionsParameters -> ShowS
GHC.Show.Show,
      GetCheckoutSessionsParameters
-> GetCheckoutSessionsParameters -> Bool
(GetCheckoutSessionsParameters
 -> GetCheckoutSessionsParameters -> Bool)
-> (GetCheckoutSessionsParameters
    -> GetCheckoutSessionsParameters -> Bool)
-> Eq GetCheckoutSessionsParameters
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetCheckoutSessionsParameters
-> GetCheckoutSessionsParameters -> Bool
$c/= :: GetCheckoutSessionsParameters
-> GetCheckoutSessionsParameters -> Bool
== :: GetCheckoutSessionsParameters
-> GetCheckoutSessionsParameters -> Bool
$c== :: GetCheckoutSessionsParameters
-> GetCheckoutSessionsParameters -> Bool
GHC.Classes.Eq
    )

instance Data.Aeson.Types.ToJSON.ToJSON GetCheckoutSessionsParameters where
  toJSON :: GetCheckoutSessionsParameters -> Value
toJSON GetCheckoutSessionsParameters
obj = [Pair] -> Value
Data.Aeson.Types.Internal.object (Text
"queryEnding_before" Text -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= GetCheckoutSessionsParameters -> Maybe Text
getCheckoutSessionsParametersQueryEndingBefore GetCheckoutSessionsParameters
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"queryExpand" Text -> Maybe [Text] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= GetCheckoutSessionsParameters -> Maybe [Text]
getCheckoutSessionsParametersQueryExpand GetCheckoutSessionsParameters
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"queryLimit" Text -> Maybe Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= GetCheckoutSessionsParameters -> Maybe Int
getCheckoutSessionsParametersQueryLimit GetCheckoutSessionsParameters
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"queryPayment_intent" Text -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= GetCheckoutSessionsParameters -> Maybe Text
getCheckoutSessionsParametersQueryPaymentIntent GetCheckoutSessionsParameters
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"queryStarting_after" Text -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= GetCheckoutSessionsParameters -> Maybe Text
getCheckoutSessionsParametersQueryStartingAfter GetCheckoutSessionsParameters
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"querySubscription" Text -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= GetCheckoutSessionsParameters -> Maybe Text
getCheckoutSessionsParametersQuerySubscription GetCheckoutSessionsParameters
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: [Pair]
forall a. Monoid a => a
GHC.Base.mempty)
  toEncoding :: GetCheckoutSessionsParameters -> Encoding
toEncoding GetCheckoutSessionsParameters
obj = Series -> Encoding
Data.Aeson.Encoding.Internal.pairs ((Text
"queryEnding_before" Text -> Maybe Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= GetCheckoutSessionsParameters -> Maybe Text
getCheckoutSessionsParametersQueryEndingBefore GetCheckoutSessionsParameters
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"queryExpand" Text -> Maybe [Text] -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= GetCheckoutSessionsParameters -> Maybe [Text]
getCheckoutSessionsParametersQueryExpand GetCheckoutSessionsParameters
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"queryLimit" Text -> Maybe Int -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= GetCheckoutSessionsParameters -> Maybe Int
getCheckoutSessionsParametersQueryLimit GetCheckoutSessionsParameters
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"queryPayment_intent" Text -> Maybe Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= GetCheckoutSessionsParameters -> Maybe Text
getCheckoutSessionsParametersQueryPaymentIntent GetCheckoutSessionsParameters
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"queryStarting_after" Text -> Maybe Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= GetCheckoutSessionsParameters -> Maybe Text
getCheckoutSessionsParametersQueryStartingAfter GetCheckoutSessionsParameters
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> (Text
"querySubscription" Text -> Maybe Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= GetCheckoutSessionsParameters -> Maybe Text
getCheckoutSessionsParametersQuerySubscription GetCheckoutSessionsParameters
obj))))))

instance Data.Aeson.Types.FromJSON.FromJSON GetCheckoutSessionsParameters where
  parseJSON :: Value -> Parser GetCheckoutSessionsParameters
parseJSON = String
-> (Object -> Parser GetCheckoutSessionsParameters)
-> Value
-> Parser GetCheckoutSessionsParameters
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.Aeson.Types.FromJSON.withObject String
"GetCheckoutSessionsParameters" (\Object
obj -> ((((((Maybe Text
 -> Maybe [Text]
 -> Maybe Int
 -> Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> GetCheckoutSessionsParameters)
-> Parser
     (Maybe Text
      -> Maybe [Text]
      -> Maybe Int
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> GetCheckoutSessionsParameters)
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure Maybe Text
-> Maybe [Text]
-> Maybe Int
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> GetCheckoutSessionsParameters
GetCheckoutSessionsParameters Parser
  (Maybe Text
   -> Maybe [Text]
   -> Maybe Int
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> GetCheckoutSessionsParameters)
-> Parser (Maybe Text)
-> Parser
     (Maybe [Text]
      -> Maybe Int
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> GetCheckoutSessionsParameters)
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
"queryEnding_before")) Parser
  (Maybe [Text]
   -> Maybe Int
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> GetCheckoutSessionsParameters)
-> Parser (Maybe [Text])
-> Parser
     (Maybe Int
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> GetCheckoutSessionsParameters)
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
"queryExpand")) Parser
  (Maybe Int
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> GetCheckoutSessionsParameters)
-> Parser (Maybe Int)
-> Parser
     (Maybe Text
      -> Maybe Text -> Maybe Text -> GetCheckoutSessionsParameters)
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
"queryLimit")) Parser
  (Maybe Text
   -> Maybe Text -> Maybe Text -> GetCheckoutSessionsParameters)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text -> Maybe Text -> GetCheckoutSessionsParameters)
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
"queryPayment_intent")) Parser (Maybe Text -> Maybe Text -> GetCheckoutSessionsParameters)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> GetCheckoutSessionsParameters)
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
"queryStarting_after")) Parser (Maybe Text -> GetCheckoutSessionsParameters)
-> Parser (Maybe Text) -> Parser GetCheckoutSessionsParameters
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
"querySubscription"))

-- | Create a new 'GetCheckoutSessionsParameters' with all required fields.
mkGetCheckoutSessionsParameters :: GetCheckoutSessionsParameters
mkGetCheckoutSessionsParameters :: GetCheckoutSessionsParameters
mkGetCheckoutSessionsParameters =
  GetCheckoutSessionsParameters :: Maybe Text
-> Maybe [Text]
-> Maybe Int
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> GetCheckoutSessionsParameters
GetCheckoutSessionsParameters
    { getCheckoutSessionsParametersQueryEndingBefore :: Maybe Text
getCheckoutSessionsParametersQueryEndingBefore = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing,
      getCheckoutSessionsParametersQueryExpand :: Maybe [Text]
getCheckoutSessionsParametersQueryExpand = Maybe [Text]
forall a. Maybe a
GHC.Maybe.Nothing,
      getCheckoutSessionsParametersQueryLimit :: Maybe Int
getCheckoutSessionsParametersQueryLimit = Maybe Int
forall a. Maybe a
GHC.Maybe.Nothing,
      getCheckoutSessionsParametersQueryPaymentIntent :: Maybe Text
getCheckoutSessionsParametersQueryPaymentIntent = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing,
      getCheckoutSessionsParametersQueryStartingAfter :: Maybe Text
getCheckoutSessionsParametersQueryStartingAfter = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing,
      getCheckoutSessionsParametersQuerySubscription :: Maybe Text
getCheckoutSessionsParametersQuerySubscription = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing
    }

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

-- | Defines the object schema located at @paths.\/v1\/checkout\/sessions.GET.responses.200.content.application\/json.schema@ in the specification.
data GetCheckoutSessionsResponseBody200 = GetCheckoutSessionsResponseBody200
  { -- | data
    GetCheckoutSessionsResponseBody200 -> [Checkout'session]
getCheckoutSessionsResponseBody200Data :: ([Checkout'session]),
    -- | has_more: True if this list has another page of items after this one that can be fetched.
    GetCheckoutSessionsResponseBody200 -> Bool
getCheckoutSessionsResponseBody200HasMore :: GHC.Types.Bool,
    -- | url: The URL where this list can be accessed.
    --
    -- Constraints:
    --
    -- * Maximum length of 5000
    GetCheckoutSessionsResponseBody200 -> Text
getCheckoutSessionsResponseBody200Url :: Data.Text.Internal.Text
  }
  deriving
    ( Int -> GetCheckoutSessionsResponseBody200 -> ShowS
[GetCheckoutSessionsResponseBody200] -> ShowS
GetCheckoutSessionsResponseBody200 -> String
(Int -> GetCheckoutSessionsResponseBody200 -> ShowS)
-> (GetCheckoutSessionsResponseBody200 -> String)
-> ([GetCheckoutSessionsResponseBody200] -> ShowS)
-> Show GetCheckoutSessionsResponseBody200
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetCheckoutSessionsResponseBody200] -> ShowS
$cshowList :: [GetCheckoutSessionsResponseBody200] -> ShowS
show :: GetCheckoutSessionsResponseBody200 -> String
$cshow :: GetCheckoutSessionsResponseBody200 -> String
showsPrec :: Int -> GetCheckoutSessionsResponseBody200 -> ShowS
$cshowsPrec :: Int -> GetCheckoutSessionsResponseBody200 -> ShowS
GHC.Show.Show,
      GetCheckoutSessionsResponseBody200
-> GetCheckoutSessionsResponseBody200 -> Bool
(GetCheckoutSessionsResponseBody200
 -> GetCheckoutSessionsResponseBody200 -> Bool)
-> (GetCheckoutSessionsResponseBody200
    -> GetCheckoutSessionsResponseBody200 -> Bool)
-> Eq GetCheckoutSessionsResponseBody200
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetCheckoutSessionsResponseBody200
-> GetCheckoutSessionsResponseBody200 -> Bool
$c/= :: GetCheckoutSessionsResponseBody200
-> GetCheckoutSessionsResponseBody200 -> Bool
== :: GetCheckoutSessionsResponseBody200
-> GetCheckoutSessionsResponseBody200 -> Bool
$c== :: GetCheckoutSessionsResponseBody200
-> GetCheckoutSessionsResponseBody200 -> Bool
GHC.Classes.Eq
    )

instance Data.Aeson.Types.ToJSON.ToJSON GetCheckoutSessionsResponseBody200 where
  toJSON :: GetCheckoutSessionsResponseBody200 -> Value
toJSON GetCheckoutSessionsResponseBody200
obj = [Pair] -> Value
Data.Aeson.Types.Internal.object (Text
"data" Text -> [Checkout'session] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= GetCheckoutSessionsResponseBody200 -> [Checkout'session]
getCheckoutSessionsResponseBody200Data GetCheckoutSessionsResponseBody200
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"has_more" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= GetCheckoutSessionsResponseBody200 -> Bool
getCheckoutSessionsResponseBody200HasMore GetCheckoutSessionsResponseBody200
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"url" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= GetCheckoutSessionsResponseBody200 -> Text
getCheckoutSessionsResponseBody200Url GetCheckoutSessionsResponseBody200
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"object" Text -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Text -> Value
Data.Aeson.Types.Internal.String Text
"list" Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: [Pair]
forall a. Monoid a => a
GHC.Base.mempty)
  toEncoding :: GetCheckoutSessionsResponseBody200 -> Encoding
toEncoding GetCheckoutSessionsResponseBody200
obj = Series -> Encoding
Data.Aeson.Encoding.Internal.pairs ((Text
"data" Text -> [Checkout'session] -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= GetCheckoutSessionsResponseBody200 -> [Checkout'session]
getCheckoutSessionsResponseBody200Data GetCheckoutSessionsResponseBody200
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"has_more" Text -> Bool -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= GetCheckoutSessionsResponseBody200 -> Bool
getCheckoutSessionsResponseBody200HasMore GetCheckoutSessionsResponseBody200
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"url" Text -> Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= GetCheckoutSessionsResponseBody200 -> Text
getCheckoutSessionsResponseBody200Url GetCheckoutSessionsResponseBody200
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> (Text
"object" Text -> Value -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Text -> Value
Data.Aeson.Types.Internal.String Text
"list"))))

instance Data.Aeson.Types.FromJSON.FromJSON GetCheckoutSessionsResponseBody200 where
  parseJSON :: Value -> Parser GetCheckoutSessionsResponseBody200
parseJSON = String
-> (Object -> Parser GetCheckoutSessionsResponseBody200)
-> Value
-> Parser GetCheckoutSessionsResponseBody200
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.Aeson.Types.FromJSON.withObject String
"GetCheckoutSessionsResponseBody200" (\Object
obj -> ((([Checkout'session]
 -> Bool -> Text -> GetCheckoutSessionsResponseBody200)
-> Parser
     ([Checkout'session]
      -> Bool -> Text -> GetCheckoutSessionsResponseBody200)
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure [Checkout'session]
-> Bool -> Text -> GetCheckoutSessionsResponseBody200
GetCheckoutSessionsResponseBody200 Parser
  ([Checkout'session]
   -> Bool -> Text -> GetCheckoutSessionsResponseBody200)
-> Parser [Checkout'session]
-> Parser (Bool -> Text -> GetCheckoutSessionsResponseBody200)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Text -> Parser [Checkout'session]
forall a. FromJSON a => Object -> Text -> Parser a
Data.Aeson.Types.FromJSON..: Text
"data")) Parser (Bool -> Text -> GetCheckoutSessionsResponseBody200)
-> Parser Bool
-> Parser (Text -> GetCheckoutSessionsResponseBody200)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Text -> Parser Bool
forall a. FromJSON a => Object -> Text -> Parser a
Data.Aeson.Types.FromJSON..: Text
"has_more")) Parser (Text -> GetCheckoutSessionsResponseBody200)
-> Parser Text -> Parser GetCheckoutSessionsResponseBody200
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
"url"))

-- | Create a new 'GetCheckoutSessionsResponseBody200' with all required fields.
mkGetCheckoutSessionsResponseBody200 ::
  -- | 'getCheckoutSessionsResponseBody200Data'
  [Checkout'session] ->
  -- | 'getCheckoutSessionsResponseBody200HasMore'
  GHC.Types.Bool ->
  -- | 'getCheckoutSessionsResponseBody200Url'
  Data.Text.Internal.Text ->
  GetCheckoutSessionsResponseBody200
mkGetCheckoutSessionsResponseBody200 :: [Checkout'session]
-> Bool -> Text -> GetCheckoutSessionsResponseBody200
mkGetCheckoutSessionsResponseBody200 [Checkout'session]
getCheckoutSessionsResponseBody200Data Bool
getCheckoutSessionsResponseBody200HasMore Text
getCheckoutSessionsResponseBody200Url =
  GetCheckoutSessionsResponseBody200 :: [Checkout'session]
-> Bool -> Text -> GetCheckoutSessionsResponseBody200
GetCheckoutSessionsResponseBody200
    { getCheckoutSessionsResponseBody200Data :: [Checkout'session]
getCheckoutSessionsResponseBody200Data = [Checkout'session]
getCheckoutSessionsResponseBody200Data,
      getCheckoutSessionsResponseBody200HasMore :: Bool
getCheckoutSessionsResponseBody200HasMore = Bool
getCheckoutSessionsResponseBody200HasMore,
      getCheckoutSessionsResponseBody200Url :: Text
getCheckoutSessionsResponseBody200Url = Text
getCheckoutSessionsResponseBody200Url
    }