module TD.Data.BusinessInfo
(BusinessInfo(..)) where
import qualified Data.Aeson as A
import qualified Data.Aeson.Types as AT
import qualified TD.Lib.Internal as I
import qualified TD.Data.BusinessLocation as BusinessLocation
import qualified TD.Data.BusinessOpeningHours as BusinessOpeningHours
import qualified TD.Data.BusinessGreetingMessageSettings as BusinessGreetingMessageSettings
import qualified TD.Data.BusinessAwayMessageSettings as BusinessAwayMessageSettings
import qualified TD.Data.BusinessStartPage as BusinessStartPage
data BusinessInfo
= BusinessInfo
{ BusinessInfo -> Maybe BusinessLocation
location :: Maybe BusinessLocation.BusinessLocation
, BusinessInfo -> Maybe BusinessOpeningHours
opening_hours :: Maybe BusinessOpeningHours.BusinessOpeningHours
, BusinessInfo -> Maybe BusinessOpeningHours
local_opening_hours :: Maybe BusinessOpeningHours.BusinessOpeningHours
, BusinessInfo -> Maybe Int
next_open_in :: Maybe Int
, BusinessInfo -> Maybe Int
next_close_in :: Maybe Int
, BusinessInfo -> Maybe BusinessGreetingMessageSettings
greeting_message_settings :: Maybe BusinessGreetingMessageSettings.BusinessGreetingMessageSettings
, BusinessInfo -> Maybe BusinessAwayMessageSettings
away_message_settings :: Maybe BusinessAwayMessageSettings.BusinessAwayMessageSettings
, BusinessInfo -> Maybe BusinessStartPage
start_page :: Maybe BusinessStartPage.BusinessStartPage
}
deriving (BusinessInfo -> BusinessInfo -> Bool
(BusinessInfo -> BusinessInfo -> Bool)
-> (BusinessInfo -> BusinessInfo -> Bool) -> Eq BusinessInfo
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: BusinessInfo -> BusinessInfo -> Bool
== :: BusinessInfo -> BusinessInfo -> Bool
$c/= :: BusinessInfo -> BusinessInfo -> Bool
/= :: BusinessInfo -> BusinessInfo -> Bool
Eq, Int -> BusinessInfo -> ShowS
[BusinessInfo] -> ShowS
BusinessInfo -> String
(Int -> BusinessInfo -> ShowS)
-> (BusinessInfo -> String)
-> ([BusinessInfo] -> ShowS)
-> Show BusinessInfo
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> BusinessInfo -> ShowS
showsPrec :: Int -> BusinessInfo -> ShowS
$cshow :: BusinessInfo -> String
show :: BusinessInfo -> String
$cshowList :: [BusinessInfo] -> ShowS
showList :: [BusinessInfo] -> ShowS
Show)
instance I.ShortShow BusinessInfo where
shortShow :: BusinessInfo -> String
shortShow BusinessInfo
{ location :: BusinessInfo -> Maybe BusinessLocation
location = Maybe BusinessLocation
location_
, opening_hours :: BusinessInfo -> Maybe BusinessOpeningHours
opening_hours = Maybe BusinessOpeningHours
opening_hours_
, local_opening_hours :: BusinessInfo -> Maybe BusinessOpeningHours
local_opening_hours = Maybe BusinessOpeningHours
local_opening_hours_
, next_open_in :: BusinessInfo -> Maybe Int
next_open_in = Maybe Int
next_open_in_
, next_close_in :: BusinessInfo -> Maybe Int
next_close_in = Maybe Int
next_close_in_
, greeting_message_settings :: BusinessInfo -> Maybe BusinessGreetingMessageSettings
greeting_message_settings = Maybe BusinessGreetingMessageSettings
greeting_message_settings_
, away_message_settings :: BusinessInfo -> Maybe BusinessAwayMessageSettings
away_message_settings = Maybe BusinessAwayMessageSettings
away_message_settings_
, start_page :: BusinessInfo -> Maybe BusinessStartPage
start_page = Maybe BusinessStartPage
start_page_
}
= String
"BusinessInfo"
String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
[ String
"location" String -> Maybe BusinessLocation -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe BusinessLocation
location_
, String
"opening_hours" String -> Maybe BusinessOpeningHours -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe BusinessOpeningHours
opening_hours_
, String
"local_opening_hours" String -> Maybe BusinessOpeningHours -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe BusinessOpeningHours
local_opening_hours_
, String
"next_open_in" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
next_open_in_
, String
"next_close_in" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
next_close_in_
, String
"greeting_message_settings" String -> Maybe BusinessGreetingMessageSettings -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe BusinessGreetingMessageSettings
greeting_message_settings_
, String
"away_message_settings" String -> Maybe BusinessAwayMessageSettings -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe BusinessAwayMessageSettings
away_message_settings_
, String
"start_page" String -> Maybe BusinessStartPage -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe BusinessStartPage
start_page_
]
instance AT.FromJSON BusinessInfo where
parseJSON :: Value -> Parser BusinessInfo
parseJSON v :: Value
v@(AT.Object Object
obj) = do
String
t <- Object
obj Object -> Key -> Parser String
forall a. FromJSON a => Object -> Key -> Parser a
A..: Key
"@type" :: AT.Parser String
case String
t of
String
"businessInfo" -> Value -> Parser BusinessInfo
parseBusinessInfo Value
v
String
_ -> Parser BusinessInfo
forall a. Monoid a => a
mempty
where
parseBusinessInfo :: A.Value -> AT.Parser BusinessInfo
parseBusinessInfo :: Value -> Parser BusinessInfo
parseBusinessInfo = String
-> (Object -> Parser BusinessInfo) -> Value -> Parser BusinessInfo
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"BusinessInfo" ((Object -> Parser BusinessInfo) -> Value -> Parser BusinessInfo)
-> (Object -> Parser BusinessInfo) -> Value -> Parser BusinessInfo
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
Maybe BusinessLocation
location_ <- Object
o Object -> Key -> Parser (Maybe BusinessLocation)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"location"
Maybe BusinessOpeningHours
opening_hours_ <- Object
o Object -> Key -> Parser (Maybe BusinessOpeningHours)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"opening_hours"
Maybe BusinessOpeningHours
local_opening_hours_ <- Object
o Object -> Key -> Parser (Maybe BusinessOpeningHours)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"local_opening_hours"
Maybe Int
next_open_in_ <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"next_open_in"
Maybe Int
next_close_in_ <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"next_close_in"
Maybe BusinessGreetingMessageSettings
greeting_message_settings_ <- Object
o Object -> Key -> Parser (Maybe BusinessGreetingMessageSettings)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"greeting_message_settings"
Maybe BusinessAwayMessageSettings
away_message_settings_ <- Object
o Object -> Key -> Parser (Maybe BusinessAwayMessageSettings)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"away_message_settings"
Maybe BusinessStartPage
start_page_ <- Object
o Object -> Key -> Parser (Maybe BusinessStartPage)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"start_page"
BusinessInfo -> Parser BusinessInfo
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (BusinessInfo -> Parser BusinessInfo)
-> BusinessInfo -> Parser BusinessInfo
forall a b. (a -> b) -> a -> b
$ BusinessInfo
{ location :: Maybe BusinessLocation
location = Maybe BusinessLocation
location_
, opening_hours :: Maybe BusinessOpeningHours
opening_hours = Maybe BusinessOpeningHours
opening_hours_
, local_opening_hours :: Maybe BusinessOpeningHours
local_opening_hours = Maybe BusinessOpeningHours
local_opening_hours_
, next_open_in :: Maybe Int
next_open_in = Maybe Int
next_open_in_
, next_close_in :: Maybe Int
next_close_in = Maybe Int
next_close_in_
, greeting_message_settings :: Maybe BusinessGreetingMessageSettings
greeting_message_settings = Maybe BusinessGreetingMessageSettings
greeting_message_settings_
, away_message_settings :: Maybe BusinessAwayMessageSettings
away_message_settings = Maybe BusinessAwayMessageSettings
away_message_settings_
, start_page :: Maybe BusinessStartPage
start_page = Maybe BusinessStartPage
start_page_
}
parseJSON Value
_ = Parser BusinessInfo
forall a. Monoid a => a
mempty