{-# 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 getReportingReportTypes
module StripeAPI.Operations.GetReportingReportTypes 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/reporting/report_types
--
-- \<p>Returns a full list of Report Types.\<\/p>
getReportingReportTypes ::
  forall m.
  StripeAPI.Common.MonadHTTP m =>
  -- | expand: Specifies which fields in the response should be expanded.
  GHC.Maybe.Maybe ([Data.Text.Internal.Text]) ->
  -- | Monadic computation which returns the result of the operation
  StripeAPI.Common.ClientT m (Network.HTTP.Client.Types.Response GetReportingReportTypesResponse)
getReportingReportTypes :: Maybe [Text]
-> ClientT m (Response GetReportingReportTypesResponse)
getReportingReportTypes Maybe [Text]
expand =
  (Response ByteString -> Response GetReportingReportTypesResponse)
-> ClientT m (Response ByteString)
-> ClientT m (Response GetReportingReportTypesResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
GHC.Base.fmap
    ( \Response ByteString
response_0 ->
        (ByteString -> GetReportingReportTypesResponse)
-> Response ByteString -> Response GetReportingReportTypesResponse
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
GHC.Base.fmap
          ( (String -> GetReportingReportTypesResponse)
-> (GetReportingReportTypesResponse
    -> GetReportingReportTypesResponse)
-> Either String GetReportingReportTypesResponse
-> GetReportingReportTypesResponse
forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
Data.Either.either String -> GetReportingReportTypesResponse
GetReportingReportTypesResponseError GetReportingReportTypesResponse -> GetReportingReportTypesResponse
forall a. a -> a
GHC.Base.id
              (Either String GetReportingReportTypesResponse
 -> GetReportingReportTypesResponse)
-> (ByteString -> Either String GetReportingReportTypesResponse)
-> ByteString
-> GetReportingReportTypesResponse
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) ->
                                   GetReportingReportTypesResponseBody200
-> GetReportingReportTypesResponse
GetReportingReportTypesResponse200
                                     (GetReportingReportTypesResponseBody200
 -> GetReportingReportTypesResponse)
-> Either String GetReportingReportTypesResponseBody200
-> Either String GetReportingReportTypesResponse
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Data.Functor.<$> ( ByteString -> Either String GetReportingReportTypesResponseBody200
forall a. FromJSON a => ByteString -> Either String a
Data.Aeson.eitherDecodeStrict ByteString
body ::
                                                          Data.Either.Either
                                                            GHC.Base.String
                                                            GetReportingReportTypesResponseBody200
                                                      )
                                 | 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 -> GetReportingReportTypesResponse
GetReportingReportTypesResponseDefault
                                     (Error -> GetReportingReportTypesResponse)
-> Either String Error
-> Either String GetReportingReportTypesResponse
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 GetReportingReportTypesResponse
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] -> ClientT m (Response ByteString)
forall (m :: * -> *).
MonadHTTP m =>
Text -> Text -> [QueryParameter] -> ClientT 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/reporting/report_types") [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.<$> Maybe [Text]
expand) (String -> Text
Data.Text.pack String
"deepObject") Bool
GHC.Types.True])

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

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

instance Data.Aeson.Types.ToJSON.ToJSON GetReportingReportTypesResponseBody200 where
  toJSON :: GetReportingReportTypesResponseBody200 -> Value
toJSON GetReportingReportTypesResponseBody200
obj = [Pair] -> Value
Data.Aeson.Types.Internal.object (Text
"data" Text -> [Reporting'reportType] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= GetReportingReportTypesResponseBody200 -> [Reporting'reportType]
getReportingReportTypesResponseBody200Data GetReportingReportTypesResponseBody200
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..= GetReportingReportTypesResponseBody200 -> Bool
getReportingReportTypesResponseBody200HasMore GetReportingReportTypesResponseBody200
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..= GetReportingReportTypesResponseBody200 -> Text
getReportingReportTypesResponseBody200Url GetReportingReportTypesResponseBody200
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 :: GetReportingReportTypesResponseBody200 -> Encoding
toEncoding GetReportingReportTypesResponseBody200
obj = Series -> Encoding
Data.Aeson.Encoding.Internal.pairs ((Text
"data" Text -> [Reporting'reportType] -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= GetReportingReportTypesResponseBody200 -> [Reporting'reportType]
getReportingReportTypesResponseBody200Data GetReportingReportTypesResponseBody200
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..= GetReportingReportTypesResponseBody200 -> Bool
getReportingReportTypesResponseBody200HasMore GetReportingReportTypesResponseBody200
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..= GetReportingReportTypesResponseBody200 -> Text
getReportingReportTypesResponseBody200Url GetReportingReportTypesResponseBody200
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 GetReportingReportTypesResponseBody200 where
  parseJSON :: Value -> Parser GetReportingReportTypesResponseBody200
parseJSON = String
-> (Object -> Parser GetReportingReportTypesResponseBody200)
-> Value
-> Parser GetReportingReportTypesResponseBody200
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.Aeson.Types.FromJSON.withObject String
"GetReportingReportTypesResponseBody200" (\Object
obj -> ((([Reporting'reportType]
 -> Bool -> Text -> GetReportingReportTypesResponseBody200)
-> Parser
     ([Reporting'reportType]
      -> Bool -> Text -> GetReportingReportTypesResponseBody200)
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure [Reporting'reportType]
-> Bool -> Text -> GetReportingReportTypesResponseBody200
GetReportingReportTypesResponseBody200 Parser
  ([Reporting'reportType]
   -> Bool -> Text -> GetReportingReportTypesResponseBody200)
-> Parser [Reporting'reportType]
-> Parser (Bool -> Text -> GetReportingReportTypesResponseBody200)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Text -> Parser [Reporting'reportType]
forall a. FromJSON a => Object -> Text -> Parser a
Data.Aeson.Types.FromJSON..: Text
"data")) Parser (Bool -> Text -> GetReportingReportTypesResponseBody200)
-> Parser Bool
-> Parser (Text -> GetReportingReportTypesResponseBody200)
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 -> GetReportingReportTypesResponseBody200)
-> Parser Text -> Parser GetReportingReportTypesResponseBody200
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 'GetReportingReportTypesResponseBody200' with all required fields.
mkGetReportingReportTypesResponseBody200 ::
  -- | 'getReportingReportTypesResponseBody200Data'
  [Reporting'reportType] ->
  -- | 'getReportingReportTypesResponseBody200HasMore'
  GHC.Types.Bool ->
  -- | 'getReportingReportTypesResponseBody200Url'
  Data.Text.Internal.Text ->
  GetReportingReportTypesResponseBody200
mkGetReportingReportTypesResponseBody200 :: [Reporting'reportType]
-> Bool -> Text -> GetReportingReportTypesResponseBody200
mkGetReportingReportTypesResponseBody200 [Reporting'reportType]
getReportingReportTypesResponseBody200Data Bool
getReportingReportTypesResponseBody200HasMore Text
getReportingReportTypesResponseBody200Url =
  GetReportingReportTypesResponseBody200 :: [Reporting'reportType]
-> Bool -> Text -> GetReportingReportTypesResponseBody200
GetReportingReportTypesResponseBody200
    { getReportingReportTypesResponseBody200Data :: [Reporting'reportType]
getReportingReportTypesResponseBody200Data = [Reporting'reportType]
getReportingReportTypesResponseBody200Data,
      getReportingReportTypesResponseBody200HasMore :: Bool
getReportingReportTypesResponseBody200HasMore = Bool
getReportingReportTypesResponseBody200HasMore,
      getReportingReportTypesResponseBody200Url :: Text
getReportingReportTypesResponseBody200Url = Text
getReportingReportTypesResponseBody200Url
    }