content: {-
   Copyright 2022-23, Juspay India Pvt Ltd
  
   This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License
  
   as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program
  
   is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  
   or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of
  
   the GNU Affero General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
  -}
  {-# LANGUAGE GeneralizedNewtypeDeriving #-}
  
  module Types.Common where
  
  import Data.Aeson hiding (Error)
  import Data.OpenApi
  import EulerHS.Prelude hiding (state)
  import Kernel.Types.Error.BaseError.HTTPError hiding (Error)
  import Kernel.Types.Error.BaseError.HTTPError.FromResponse
  
  type AccountId = Text
  
  type ApiKey = Text
  
  newtype Error = Error {message :: Text}
    deriving (Show, Generic)
  
  instance IsAPIError Error
  
  deriving newtype instance ToJSON Error
  
  deriving newtype instance FromJSON Error
  
  deriving newtype instance ToSchema Error
  
  instance FromResponse Error where
    fromResponse = fromJsonResponse
  
  instance IsBaseError Error where
    toMessage _ = Just "IDFY_VERIFICATION_UNAVAILABLE"
  
  instance IsHTTPError Error where
    toErrorCode _ = "CORE002"
    toHttpCode _ = E404
  
  instance IsBecknAPIError Error where
    toType _ = DOMAIN_ERROR -- only to satisfy current tests, FIXME maybe
  
  instanceExceptionWithParent 'HTTPException ''Error
  