{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DerivingStrategies #-}

module Hercules.API.BillingStatus
  ( BillingStatus (..),
    toText,
    fromText,
  )
where

import Data.OpenApi qualified as O3
import Data.Swagger
import Hercules.API.Prelude

data BillingStatus
  = Community -- Free plan
  | Trial
  | Active
  | Cancelled
  | External
  | Enterprise
  deriving ((forall x. BillingStatus -> Rep BillingStatus x)
-> (forall x. Rep BillingStatus x -> BillingStatus)
-> Generic BillingStatus
forall x. Rep BillingStatus x -> BillingStatus
forall x. BillingStatus -> Rep BillingStatus x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. BillingStatus -> Rep BillingStatus x
from :: forall x. BillingStatus -> Rep BillingStatus x
$cto :: forall x. Rep BillingStatus x -> BillingStatus
to :: forall x. Rep BillingStatus x -> BillingStatus
Generic, Int -> BillingStatus -> ShowS
[BillingStatus] -> ShowS
BillingStatus -> String
(Int -> BillingStatus -> ShowS)
-> (BillingStatus -> String)
-> ([BillingStatus] -> ShowS)
-> Show BillingStatus
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> BillingStatus -> ShowS
showsPrec :: Int -> BillingStatus -> ShowS
$cshow :: BillingStatus -> String
show :: BillingStatus -> String
$cshowList :: [BillingStatus] -> ShowS
showList :: [BillingStatus] -> ShowS
Show, BillingStatus -> BillingStatus -> Bool
(BillingStatus -> BillingStatus -> Bool)
-> (BillingStatus -> BillingStatus -> Bool) -> Eq BillingStatus
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: BillingStatus -> BillingStatus -> Bool
== :: BillingStatus -> BillingStatus -> Bool
$c/= :: BillingStatus -> BillingStatus -> Bool
/= :: BillingStatus -> BillingStatus -> Bool
Eq)
  deriving anyclass (BillingStatus -> ()
(BillingStatus -> ()) -> NFData BillingStatus
forall a. (a -> ()) -> NFData a
$crnf :: BillingStatus -> ()
rnf :: BillingStatus -> ()
NFData, [BillingStatus] -> Value
[BillingStatus] -> Encoding
BillingStatus -> Value
BillingStatus -> Encoding
(BillingStatus -> Value)
-> (BillingStatus -> Encoding)
-> ([BillingStatus] -> Value)
-> ([BillingStatus] -> Encoding)
-> ToJSON BillingStatus
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> ToJSON a
$ctoJSON :: BillingStatus -> Value
toJSON :: BillingStatus -> Value
$ctoEncoding :: BillingStatus -> Encoding
toEncoding :: BillingStatus -> Encoding
$ctoJSONList :: [BillingStatus] -> Value
toJSONList :: [BillingStatus] -> Value
$ctoEncodingList :: [BillingStatus] -> Encoding
toEncodingList :: [BillingStatus] -> Encoding
ToJSON, Value -> Parser [BillingStatus]
Value -> Parser BillingStatus
(Value -> Parser BillingStatus)
-> (Value -> Parser [BillingStatus]) -> FromJSON BillingStatus
forall a.
(Value -> Parser a) -> (Value -> Parser [a]) -> FromJSON a
$cparseJSON :: Value -> Parser BillingStatus
parseJSON :: Value -> Parser BillingStatus
$cparseJSONList :: Value -> Parser [BillingStatus]
parseJSONList :: Value -> Parser [BillingStatus]
FromJSON, Proxy BillingStatus -> Declare (Definitions Schema) NamedSchema
(Proxy BillingStatus -> Declare (Definitions Schema) NamedSchema)
-> ToSchema BillingStatus
forall a.
(Proxy a -> Declare (Definitions Schema) NamedSchema) -> ToSchema a
$cdeclareNamedSchema :: Proxy BillingStatus -> Declare (Definitions Schema) NamedSchema
declareNamedSchema :: Proxy BillingStatus -> Declare (Definitions Schema) NamedSchema
ToSchema, Typeable BillingStatus
Typeable BillingStatus
-> (Proxy BillingStatus
    -> Declare (Definitions Schema) NamedSchema)
-> ToSchema BillingStatus
Proxy BillingStatus -> Declare (Definitions Schema) NamedSchema
forall a.
Typeable a
-> (Proxy a -> Declare (Definitions Schema) NamedSchema)
-> ToSchema a
$cdeclareNamedSchema :: Proxy BillingStatus -> Declare (Definitions Schema) NamedSchema
declareNamedSchema :: Proxy BillingStatus -> Declare (Definitions Schema) NamedSchema
O3.ToSchema)

toText :: BillingStatus -> Text
toText :: BillingStatus -> Text
toText BillingStatus
Community = Text
"Community"
toText BillingStatus
Trial = Text
"Trial"
toText BillingStatus
Active = Text
"Active"
toText BillingStatus
Cancelled = Text
"Cancelled"
toText BillingStatus
External = Text
"External"
toText BillingStatus
Enterprise = Text
"Enterprise"

fromText :: Text -> Maybe BillingStatus
fromText :: Text -> Maybe BillingStatus
fromText Text
"Community" = BillingStatus -> Maybe BillingStatus
forall a. a -> Maybe a
Just BillingStatus
Community
fromText Text
"Cancelled" = BillingStatus -> Maybe BillingStatus
forall a. a -> Maybe a
Just BillingStatus
Cancelled
fromText Text
"Trial" = BillingStatus -> Maybe BillingStatus
forall a. a -> Maybe a
Just BillingStatus
Trial
fromText Text
"Active" = BillingStatus -> Maybe BillingStatus
forall a. a -> Maybe a
Just BillingStatus
Active
fromText Text
"External" = BillingStatus -> Maybe BillingStatus
forall a. a -> Maybe a
Just BillingStatus
External
fromText Text
"Enterprise" = BillingStatus -> Maybe BillingStatus
forall a. a -> Maybe a
Just BillingStatus
Enterprise
fromText Text
_ = Maybe BillingStatus
forall a. Maybe a
Nothing