-- This file is part of the Wire Server implementation.
--
-- Copyright (C) 2020 Wire Swiss GmbH <opensource@wire.com>
--
-- 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/>.

module Web.Scim.Schema.User.Phone where

import Data.Aeson
import Data.Text hiding (dropWhile)
import GHC.Generics (Generic)
import Web.Scim.Schema.Common

data Phone = Phone
  { Phone -> Maybe Text
typ :: Maybe Text,
    Phone -> Maybe Text
value :: Maybe Text
  }
  deriving (Int -> Phone -> ShowS
[Phone] -> ShowS
Phone -> String
(Int -> Phone -> ShowS)
-> (Phone -> String) -> ([Phone] -> ShowS) -> Show Phone
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Phone] -> ShowS
$cshowList :: [Phone] -> ShowS
show :: Phone -> String
$cshow :: Phone -> String
showsPrec :: Int -> Phone -> ShowS
$cshowsPrec :: Int -> Phone -> ShowS
Show, Phone -> Phone -> Bool
(Phone -> Phone -> Bool) -> (Phone -> Phone -> Bool) -> Eq Phone
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Phone -> Phone -> Bool
$c/= :: Phone -> Phone -> Bool
== :: Phone -> Phone -> Bool
$c== :: Phone -> Phone -> Bool
Eq, Eq Phone
Eq Phone
-> (Phone -> Phone -> Ordering)
-> (Phone -> Phone -> Bool)
-> (Phone -> Phone -> Bool)
-> (Phone -> Phone -> Bool)
-> (Phone -> Phone -> Bool)
-> (Phone -> Phone -> Phone)
-> (Phone -> Phone -> Phone)
-> Ord Phone
Phone -> Phone -> Bool
Phone -> Phone -> Ordering
Phone -> Phone -> Phone
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: Phone -> Phone -> Phone
$cmin :: Phone -> Phone -> Phone
max :: Phone -> Phone -> Phone
$cmax :: Phone -> Phone -> Phone
>= :: Phone -> Phone -> Bool
$c>= :: Phone -> Phone -> Bool
> :: Phone -> Phone -> Bool
$c> :: Phone -> Phone -> Bool
<= :: Phone -> Phone -> Bool
$c<= :: Phone -> Phone -> Bool
< :: Phone -> Phone -> Bool
$c< :: Phone -> Phone -> Bool
compare :: Phone -> Phone -> Ordering
$ccompare :: Phone -> Phone -> Ordering
$cp1Ord :: Eq Phone
Ord, (forall x. Phone -> Rep Phone x)
-> (forall x. Rep Phone x -> Phone) -> Generic Phone
forall x. Rep Phone x -> Phone
forall x. Phone -> Rep Phone x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Phone x -> Phone
$cfrom :: forall x. Phone -> Rep Phone x
Generic)

instance FromJSON Phone where
  parseJSON :: Value -> Parser Phone
parseJSON = Options -> Value -> Parser Phone
forall a.
(Generic a, GFromJSON Zero (Rep a)) =>
Options -> Value -> Parser a
genericParseJSON Options
parseOptions (Value -> Parser Phone)
-> (Value -> Value) -> Value -> Parser Phone
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Value -> Value
jsonLower

instance ToJSON Phone where
  toJSON :: Phone -> Value
toJSON = Options -> Phone -> Value
forall a.
(Generic a, GToJSON Value Zero (Rep a)) =>
Options -> a -> Value
genericToJSON Options
serializeOptions