{-# 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 getCustomersSearch module StripeAPI.Operations.GetCustomersSearch 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.Foldable import qualified Data.Functor import qualified Data.Maybe 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/customers/search -- -- \

Search for customers you’ve previously created using Stripe’s \Search Query Language\<\/a>. -- Don’t use search in read-after-write flows where strict consistency is necessary. Under normal operating -- conditions, data is searchable in less than a minute. Occasionally, propagation of new or updated data can be up -- to an hour behind during outages. Search functionality is not available to merchants in India.\<\/p> getCustomersSearch :: forall m. StripeAPI.Common.MonadHTTP m => -- | Contains all available parameters of this operation (query and path parameters) GetCustomersSearchParameters -> -- | Monadic computation which returns the result of the operation StripeAPI.Common.ClientT m (Network.HTTP.Client.Types.Response GetCustomersSearchResponse) getCustomersSearch parameters = GHC.Base.fmap ( \response_0 -> GHC.Base.fmap ( Data.Either.either GetCustomersSearchResponseError GHC.Base.id GHC.Base.. ( \response body -> if | (\status_1 -> Network.HTTP.Types.Status.statusCode status_1 GHC.Classes.== 200) (Network.HTTP.Client.Types.responseStatus response) -> GetCustomersSearchResponse200 Data.Functor.<$> ( Data.Aeson.eitherDecodeStrict body :: Data.Either.Either GHC.Base.String GetCustomersSearchResponseBody200 ) | GHC.Base.const GHC.Types.True (Network.HTTP.Client.Types.responseStatus response) -> GetCustomersSearchResponseDefault Data.Functor.<$> ( Data.Aeson.eitherDecodeStrict body :: Data.Either.Either GHC.Base.String Error ) | GHC.Base.otherwise -> Data.Either.Left "Missing default response type" ) response_0 ) response_0 ) ( StripeAPI.Common.doCallWithConfigurationM (Data.Text.toUpper GHC.Base.$ Data.Text.pack "GET") (Data.Text.pack "/v1/customers/search") [ StripeAPI.Common.QueryParameter (Data.Text.pack "expand") (Data.Aeson.Types.ToJSON.toJSON Data.Functor.<$> getCustomersSearchParametersQueryExpand parameters) (Data.Text.pack "deepObject") GHC.Types.True, StripeAPI.Common.QueryParameter (Data.Text.pack "limit") (Data.Aeson.Types.ToJSON.toJSON Data.Functor.<$> getCustomersSearchParametersQueryLimit parameters) (Data.Text.pack "form") GHC.Types.True, StripeAPI.Common.QueryParameter (Data.Text.pack "page") (Data.Aeson.Types.ToJSON.toJSON Data.Functor.<$> getCustomersSearchParametersQueryPage parameters) (Data.Text.pack "form") GHC.Types.True, StripeAPI.Common.QueryParameter (Data.Text.pack "query") (GHC.Maybe.Just GHC.Base.$ Data.Aeson.Types.ToJSON.toJSON (getCustomersSearchParametersQueryQuery parameters)) (Data.Text.pack "form") GHC.Types.True ] ) -- | Defines the object schema located at @paths.\/v1\/customers\/search.GET.parameters@ in the specification. data GetCustomersSearchParameters = GetCustomersSearchParameters { -- | queryExpand: Represents the parameter named \'expand\' -- -- Specifies which fields in the response should be expanded. getCustomersSearchParametersQueryExpand :: (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. getCustomersSearchParametersQueryLimit :: (GHC.Maybe.Maybe GHC.Types.Int), -- | queryPage: Represents the parameter named \'page\' -- -- A cursor for pagination across multiple pages of results. Don\'t include this parameter on the first call. Use the next_page value returned in a previous response to request subsequent results. -- -- Constraints: -- -- * Maximum length of 5000 getCustomersSearchParametersQueryPage :: (GHC.Maybe.Maybe Data.Text.Internal.Text), -- | queryQuery: Represents the parameter named \'query\' -- -- The search query string. See [search query language](https:\/\/stripe.com\/docs\/search\#search-query-language) and the list of supported [query fields for customers](https:\/\/stripe.com\/docs\/search\#query-fields-for-customers). -- -- Constraints: -- -- * Maximum length of 5000 getCustomersSearchParametersQueryQuery :: Data.Text.Internal.Text } deriving ( GHC.Show.Show, GHC.Classes.Eq ) instance Data.Aeson.Types.ToJSON.ToJSON GetCustomersSearchParameters where toJSON obj = Data.Aeson.Types.Internal.object (Data.Foldable.concat (Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("queryExpand" Data.Aeson.Types.ToJSON..=)) (getCustomersSearchParametersQueryExpand obj) : Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("queryLimit" Data.Aeson.Types.ToJSON..=)) (getCustomersSearchParametersQueryLimit obj) : Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("queryPage" Data.Aeson.Types.ToJSON..=)) (getCustomersSearchParametersQueryPage obj) : ["queryQuery" Data.Aeson.Types.ToJSON..= getCustomersSearchParametersQueryQuery obj] : GHC.Base.mempty)) toEncoding obj = Data.Aeson.Encoding.Internal.pairs (GHC.Base.mconcat (Data.Foldable.concat (Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("queryExpand" Data.Aeson.Types.ToJSON..=)) (getCustomersSearchParametersQueryExpand obj) : Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("queryLimit" Data.Aeson.Types.ToJSON..=)) (getCustomersSearchParametersQueryLimit obj) : Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("queryPage" Data.Aeson.Types.ToJSON..=)) (getCustomersSearchParametersQueryPage obj) : ["queryQuery" Data.Aeson.Types.ToJSON..= getCustomersSearchParametersQueryQuery obj] : GHC.Base.mempty))) instance Data.Aeson.Types.FromJSON.FromJSON GetCustomersSearchParameters where parseJSON = Data.Aeson.Types.FromJSON.withObject "GetCustomersSearchParameters" (\obj -> (((GHC.Base.pure GetCustomersSearchParameters GHC.Base.<*> (obj Data.Aeson.Types.FromJSON..:! "queryExpand")) GHC.Base.<*> (obj Data.Aeson.Types.FromJSON..:! "queryLimit")) GHC.Base.<*> (obj Data.Aeson.Types.FromJSON..:! "queryPage")) GHC.Base.<*> (obj Data.Aeson.Types.FromJSON..: "queryQuery")) -- | Create a new 'GetCustomersSearchParameters' with all required fields. mkGetCustomersSearchParameters :: -- | 'getCustomersSearchParametersQueryQuery' Data.Text.Internal.Text -> GetCustomersSearchParameters mkGetCustomersSearchParameters getCustomersSearchParametersQueryQuery = GetCustomersSearchParameters { getCustomersSearchParametersQueryExpand = GHC.Maybe.Nothing, getCustomersSearchParametersQueryLimit = GHC.Maybe.Nothing, getCustomersSearchParametersQueryPage = GHC.Maybe.Nothing, getCustomersSearchParametersQueryQuery = getCustomersSearchParametersQueryQuery } -- | Represents a response of the operation 'getCustomersSearch'. -- -- 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), 'GetCustomersSearchResponseError' is used. data GetCustomersSearchResponse = -- | Means either no matching case available or a parse error GetCustomersSearchResponseError GHC.Base.String | -- | Successful response. GetCustomersSearchResponse200 GetCustomersSearchResponseBody200 | -- | Error response. GetCustomersSearchResponseDefault Error deriving (GHC.Show.Show, GHC.Classes.Eq) -- | Defines the object schema located at @paths.\/v1\/customers\/search.GET.responses.200.content.application\/json.schema@ in the specification. data GetCustomersSearchResponseBody200 = GetCustomersSearchResponseBody200 { -- | data getCustomersSearchResponseBody200Data :: ([Customer]), -- | has_more getCustomersSearchResponseBody200HasMore :: GHC.Types.Bool, -- | next_page -- -- Constraints: -- -- * Maximum length of 5000 getCustomersSearchResponseBody200NextPage :: (GHC.Maybe.Maybe (StripeAPI.Common.Nullable Data.Text.Internal.Text)), -- | total_count: The total number of objects that match the query, only accurate up to 10,000. getCustomersSearchResponseBody200TotalCount :: (GHC.Maybe.Maybe GHC.Types.Int), -- | url -- -- Constraints: -- -- * Maximum length of 5000 getCustomersSearchResponseBody200Url :: Data.Text.Internal.Text } deriving ( GHC.Show.Show, GHC.Classes.Eq ) instance Data.Aeson.Types.ToJSON.ToJSON GetCustomersSearchResponseBody200 where toJSON obj = Data.Aeson.Types.Internal.object (Data.Foldable.concat (["data" Data.Aeson.Types.ToJSON..= getCustomersSearchResponseBody200Data obj] : ["has_more" Data.Aeson.Types.ToJSON..= getCustomersSearchResponseBody200HasMore obj] : Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("next_page" Data.Aeson.Types.ToJSON..=)) (getCustomersSearchResponseBody200NextPage obj) : Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("total_count" Data.Aeson.Types.ToJSON..=)) (getCustomersSearchResponseBody200TotalCount obj) : ["url" Data.Aeson.Types.ToJSON..= getCustomersSearchResponseBody200Url obj] : ["object" Data.Aeson.Types.ToJSON..= Data.Aeson.Types.Internal.String "search_result"] : GHC.Base.mempty)) toEncoding obj = Data.Aeson.Encoding.Internal.pairs (GHC.Base.mconcat (Data.Foldable.concat (["data" Data.Aeson.Types.ToJSON..= getCustomersSearchResponseBody200Data obj] : ["has_more" Data.Aeson.Types.ToJSON..= getCustomersSearchResponseBody200HasMore obj] : Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("next_page" Data.Aeson.Types.ToJSON..=)) (getCustomersSearchResponseBody200NextPage obj) : Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("total_count" Data.Aeson.Types.ToJSON..=)) (getCustomersSearchResponseBody200TotalCount obj) : ["url" Data.Aeson.Types.ToJSON..= getCustomersSearchResponseBody200Url obj] : ["object" Data.Aeson.Types.ToJSON..= Data.Aeson.Types.Internal.String "search_result"] : GHC.Base.mempty))) instance Data.Aeson.Types.FromJSON.FromJSON GetCustomersSearchResponseBody200 where parseJSON = Data.Aeson.Types.FromJSON.withObject "GetCustomersSearchResponseBody200" (\obj -> ((((GHC.Base.pure GetCustomersSearchResponseBody200 GHC.Base.<*> (obj Data.Aeson.Types.FromJSON..: "data")) GHC.Base.<*> (obj Data.Aeson.Types.FromJSON..: "has_more")) GHC.Base.<*> (obj Data.Aeson.Types.FromJSON..:! "next_page")) GHC.Base.<*> (obj Data.Aeson.Types.FromJSON..:! "total_count")) GHC.Base.<*> (obj Data.Aeson.Types.FromJSON..: "url")) -- | Create a new 'GetCustomersSearchResponseBody200' with all required fields. mkGetCustomersSearchResponseBody200 :: -- | 'getCustomersSearchResponseBody200Data' [Customer] -> -- | 'getCustomersSearchResponseBody200HasMore' GHC.Types.Bool -> -- | 'getCustomersSearchResponseBody200Url' Data.Text.Internal.Text -> GetCustomersSearchResponseBody200 mkGetCustomersSearchResponseBody200 getCustomersSearchResponseBody200Data getCustomersSearchResponseBody200HasMore getCustomersSearchResponseBody200Url = GetCustomersSearchResponseBody200 { getCustomersSearchResponseBody200Data = getCustomersSearchResponseBody200Data, getCustomersSearchResponseBody200HasMore = getCustomersSearchResponseBody200HasMore, getCustomersSearchResponseBody200NextPage = GHC.Maybe.Nothing, getCustomersSearchResponseBody200TotalCount = GHC.Maybe.Nothing, getCustomersSearchResponseBody200Url = getCustomersSearchResponseBody200Url }