module TD.Query.SetBusinessLocation
  (SetBusinessLocation(..)
  ) 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

-- | Changes the business location of the current user. Requires Telegram Business subscription. Returns 'TD.Data.Ok.Ok'
data SetBusinessLocation
  = SetBusinessLocation
    { SetBusinessLocation -> Maybe BusinessLocation
location :: Maybe BusinessLocation.BusinessLocation -- ^ The new location of the business; pass null to remove the location
    }
  deriving (SetBusinessLocation -> SetBusinessLocation -> Bool
(SetBusinessLocation -> SetBusinessLocation -> Bool)
-> (SetBusinessLocation -> SetBusinessLocation -> Bool)
-> Eq SetBusinessLocation
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: SetBusinessLocation -> SetBusinessLocation -> Bool
== :: SetBusinessLocation -> SetBusinessLocation -> Bool
$c/= :: SetBusinessLocation -> SetBusinessLocation -> Bool
/= :: SetBusinessLocation -> SetBusinessLocation -> Bool
Eq, Int -> SetBusinessLocation -> ShowS
[SetBusinessLocation] -> ShowS
SetBusinessLocation -> String
(Int -> SetBusinessLocation -> ShowS)
-> (SetBusinessLocation -> String)
-> ([SetBusinessLocation] -> ShowS)
-> Show SetBusinessLocation
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> SetBusinessLocation -> ShowS
showsPrec :: Int -> SetBusinessLocation -> ShowS
$cshow :: SetBusinessLocation -> String
show :: SetBusinessLocation -> String
$cshowList :: [SetBusinessLocation] -> ShowS
showList :: [SetBusinessLocation] -> ShowS
Show)

instance I.ShortShow SetBusinessLocation where
  shortShow :: SetBusinessLocation -> String
shortShow
    SetBusinessLocation
      { location :: SetBusinessLocation -> Maybe BusinessLocation
location = Maybe BusinessLocation
location_
      }
        = String
"SetBusinessLocation"
          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_
          ]

instance AT.ToJSON SetBusinessLocation where
  toJSON :: SetBusinessLocation -> Value
toJSON
    SetBusinessLocation
      { location :: SetBusinessLocation -> Maybe BusinessLocation
location = Maybe BusinessLocation
location_
      }
        = [Pair] -> Value
A.object
          [ Key
"@type"    Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Text -> Value
AT.String Text
"setBusinessLocation"
          , Key
"location" Key -> Maybe BusinessLocation -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe BusinessLocation
location_
          ]