battleplace 0.1.0.1 → 0.1.0.2
raw patch · 5 files changed
+52/−38 lines, 5 filesPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
API changes (from Hackage documentation)
- BattlePlace.WebApi: MatchStatusReason_cancelled :: MatchStatusReason
- BattlePlace.WebApi: MatchStatusReason_noServer :: MatchStatusReason
- BattlePlace.WebApi: MatchStatusReason_timedOut :: MatchStatusReason
- BattlePlace.WebApi: [matchRequest_clientToken] :: MatchRequest -> !(InternalToken ClientToken)
- BattlePlace.WebApi: data MatchStatusReason
- BattlePlace.WebApi: instance Data.Aeson.Types.FromJSON.FromJSON BattlePlace.WebApi.MatchStatusReason
- BattlePlace.WebApi: instance Data.Aeson.Types.ToJSON.ToJSON BattlePlace.WebApi.MatchStatusReason
- BattlePlace.WebApi: instance GHC.Generics.Generic BattlePlace.WebApi.MatchStatusReason
- BattlePlace.WebApi.Types: ClientToken :: {-# UNPACK #-} !ProjectId -> !Client -> ClientToken
- BattlePlace.WebApi.Types: [clientToken_client] :: ClientToken -> !Client
- BattlePlace.WebApi.Types: [clientToken_projectId] :: ClientToken -> {-# UNPACK #-} !ProjectId
- BattlePlace.WebApi.Types: [matchToken_client] :: MatchToken -> !Client
- BattlePlace.WebApi.Types: [matchToken_projectId] :: MatchToken -> {-# UNPACK #-} !ProjectId
- BattlePlace.WebApi.Types: [sessionToken_client] :: SessionToken -> !Client
- BattlePlace.WebApi.Types: data ClientToken
- BattlePlace.WebApi.Types: instance Data.Aeson.Types.FromJSON.FromJSON BattlePlace.WebApi.Types.ClientToken
- BattlePlace.WebApi.Types: instance Data.Aeson.Types.ToJSON.ToJSON BattlePlace.WebApi.Types.ClientToken
- BattlePlace.WebApi.Types: instance GHC.Generics.Generic BattlePlace.WebApi.Types.ClientToken
+ BattlePlace.WebApi.Auth: ClientToken :: {-# UNPACK #-} !ProjectId -> !Client -> ClientToken
+ BattlePlace.WebApi.Auth: [clientToken_client] :: ClientToken -> !Client
+ BattlePlace.WebApi.Auth: [clientToken_projectId] :: ClientToken -> {-# UNPACK #-} !ProjectId
+ BattlePlace.WebApi.Auth: data ClientToken
+ BattlePlace.WebApi.Auth: instance Data.Aeson.Types.FromJSON.FromJSON BattlePlace.WebApi.Auth.ClientToken
+ BattlePlace.WebApi.Auth: instance Data.Aeson.Types.ToJSON.ToJSON BattlePlace.WebApi.Auth.ClientToken
+ BattlePlace.WebApi.Auth: instance GHC.Generics.Generic BattlePlace.WebApi.Auth.ClientToken
+ BattlePlace.WebApi.Types: MatchFailureReason_cancelled :: MatchFailureReason
+ BattlePlace.WebApi.Types: MatchFailureReason_noServer :: MatchFailureReason
+ BattlePlace.WebApi.Types: MatchFailureReason_timedOut :: MatchFailureReason
+ BattlePlace.WebApi.Types: data MatchFailureReason
+ BattlePlace.WebApi.Types: instance Data.Aeson.Types.FromJSON.FromJSON BattlePlace.WebApi.Types.MatchFailureReason
+ BattlePlace.WebApi.Types: instance Data.Aeson.Types.ToJSON.ToJSON BattlePlace.WebApi.Types.MatchFailureReason
+ BattlePlace.WebApi.Types: instance GHC.Generics.Generic BattlePlace.WebApi.Types.MatchFailureReason
- BattlePlace.WebApi: MatchRequest :: !(InternalToken ClientToken) -> !(Vector MatchTeamSize) -> {-# UNPACK #-} !Int -> !(Maybe MatchTag) -> !(Maybe MatchPlayerInfo) -> MatchRequest
+ BattlePlace.WebApi: MatchRequest :: !(Vector MatchTeamSize) -> {-# UNPACK #-} !Int -> !(Maybe MatchTag) -> !(Maybe MatchPlayerInfo) -> MatchRequest
- BattlePlace.WebApi: MatchStatusResponse_failed :: !MatchStatusReason -> MatchStatusResponse
+ BattlePlace.WebApi: MatchStatusResponse_failed :: !MatchFailureReason -> MatchStatusResponse
- BattlePlace.WebApi: [matchStatusResponse_reason] :: MatchStatusResponse -> !MatchStatusReason
+ BattlePlace.WebApi: [matchStatusResponse_reason] :: MatchStatusResponse -> !MatchFailureReason
- BattlePlace.WebApi: type WebApi = "v1a" :> (("client" :> (("auth" :> (ReqBody '[JSON] ClientAuthRequest :> Post '[JSON] ClientAuthResponse)) :<|> (("match" :> ((ReqBody '[JSON] MatchRequest :> Post '[JSON] MatchResponse) :<|> (Capture "matchToken" (InternalToken MatchToken) :> Get '[JSON] MatchStatusResponse))) :<|> ("session" :> (Capture "sessionToken" (InternalToken SessionToken) :> ("result" :> (ReqBody '[JSON] SessionResultRequest :> Post '[JSON] ()))))))) :<|> ("server" :> (("match" :> (ReqBody '[JSON] ServerMatchRequest :> Post '[JSON] ServerMatchResponse)) :<|> ("session" :> (Capture "serverSessionToken" (InternalToken ServerSessionToken) :> ("result" :> (ReqBody '[JSON] ServerSessionResultRequest :> Post '[JSON] ())))))))
+ BattlePlace.WebApi: type WebApi = "v1a" :> (("client" :> (("auth" :> (ReqBody '[JSON] ClientAuthRequest :> Post '[JSON] ClientAuthResponse)) :<|> (("match" :> ((AuthProtect ClientToken :> (ReqBody '[JSON] MatchRequest :> Post '[JSON] MatchResponse)) :<|> (AuthProtect ClientToken :> (Capture "matchToken" (InternalToken MatchToken) :> Get '[JSON] MatchStatusResponse)))) :<|> ("session" :> (Capture "sessionToken" (InternalToken SessionToken) :> ("result" :> (AuthProtect ClientToken :> (ReqBody '[JSON] SessionResultRequest :> Post '[JSON] ())))))))) :<|> ("server" :> (("match" :> (ReqBody '[JSON] ServerMatchRequest :> Post '[JSON] ServerMatchResponse)) :<|> ("session" :> (Capture "serverSessionToken" (InternalToken ServerSessionToken) :> ("result" :> (ReqBody '[JSON] ServerSessionResultRequest :> Post '[JSON] ())))))))
- BattlePlace.WebApi.Types: MatchToken :: {-# UNPACK #-} !ProjectId -> !Client -> MatchToken
+ BattlePlace.WebApi.Types: MatchToken :: MatchToken
- BattlePlace.WebApi.Types: SessionToken :: !SessionId -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> !Client -> SessionToken
+ BattlePlace.WebApi.Types: SessionToken :: !SessionId -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> SessionToken
Files
- BattlePlace/Util.hs +0/−1
- BattlePlace/WebApi.hs +6/−22
- BattlePlace/WebApi/Auth.hs +27/−0
- BattlePlace/WebApi/Types.hs +17/−14
- battleplace.cabal +2/−1
BattlePlace/Util.hs view
@@ -32,4 +32,3 @@ '_' -> xs _ -> dropBeforeUnderscore xs [] -> []-
BattlePlace/WebApi.hs view
@@ -13,7 +13,6 @@ , MatchRequest(..) , MatchResponse(..) , MatchStatusResponse(..)- , MatchStatusReason(..) , MatchTeam(..) , MatchPlayer(..) , MatchServer(..)@@ -34,17 +33,18 @@ import BattlePlace.Token.Types import BattlePlace.Util+import BattlePlace.WebApi.Auth import BattlePlace.WebApi.Types type WebApi = "v1a" :> ( "client" :> ( "auth" :> ReqBody '[JSON] ClientAuthRequest :> Post '[JSON] ClientAuthResponse :<|> "match" :>- ( ReqBody '[JSON] MatchRequest :> Post '[JSON] MatchResponse- :<|> Capture "matchToken" (InternalToken MatchToken) :> Get '[JSON] MatchStatusResponse+ ( AuthProtect ClientToken :> ReqBody '[JSON] MatchRequest :> Post '[JSON] MatchResponse+ :<|> AuthProtect ClientToken :> Capture "matchToken" (InternalToken MatchToken) :> Get '[JSON] MatchStatusResponse ) :<|> "session" :> Capture "sessionToken" (InternalToken SessionToken) :>- ( "result" :> ReqBody '[JSON] SessionResultRequest :> Post '[JSON] ()+ ( "result" :> AuthProtect ClientToken :> ReqBody '[JSON] SessionResultRequest :> Post '[JSON] () ) ) :<|> "server" :>@@ -82,8 +82,7 @@ toEncoding = J.genericToEncoding jsonOptions data MatchRequest = MatchRequest- { matchRequest_clientToken :: !(InternalToken ClientToken)- , matchRequest_teamSizes :: !(VU.Vector MatchTeamSize)+ { matchRequest_teamSizes :: !(VU.Vector MatchTeamSize) , matchRequest_maxMatchTime :: {-# UNPACK #-} !Int , matchRequest_matchTag :: !(Maybe MatchTag) , matchRequest_info :: !(Maybe MatchPlayerInfo)@@ -115,7 +114,7 @@ , matchStatusResponse_server :: !(Maybe MatchServer) } | MatchStatusResponse_failed- { matchStatusResponse_reason :: !MatchStatusReason+ { matchStatusResponse_reason :: !MatchFailureReason } -- | Match status was cleaned. -- Normallly this status should not be visible to clients, it's here just in case.@@ -124,21 +123,6 @@ instance J.FromJSON MatchStatusResponse where parseJSON = J.genericParseJSON jsonOptions instance J.ToJSON MatchStatusResponse where- toJSON = J.genericToJSON jsonOptions- toEncoding = J.genericToEncoding jsonOptions---- | Reason of match failure.-data MatchStatusReason- -- | Failed to make a match in a specified time.- = MatchStatusReason_timedOut- -- | Match was made, but no server is available (and use of server is mandatory).- | MatchStatusReason_noServer- -- | Matching was explicitly cancelled by user.- | MatchStatusReason_cancelled- deriving Generic-instance J.FromJSON MatchStatusReason where- parseJSON = J.genericParseJSON jsonOptions-instance J.ToJSON MatchStatusReason where toJSON = J.genericToJSON jsonOptions toEncoding = J.genericToEncoding jsonOptions
+ BattlePlace/WebApi/Auth.hs view
@@ -0,0 +1,27 @@+{-|+Module: BattlePlace.WebApi.Auth+Description: Web API authentication types.+License: MIT+-}++{-# LANGUAGE DeriveGeneric #-}++module BattlePlace.WebApi.Auth+ ( ClientToken(..)+ ) where++import qualified Data.Aeson as J+import GHC.Generics(Generic)++import BattlePlace.Util+import BattlePlace.WebApi.Types++data ClientToken = ClientToken+ { clientToken_projectId :: {-# UNPACK #-} !ProjectId+ , clientToken_client :: !Client+ } deriving Generic+instance J.FromJSON ClientToken where+ parseJSON = J.genericParseJSON jsonOptions+instance J.ToJSON ClientToken where+ toJSON = J.genericToJSON jsonOptions+ toEncoding = J.genericToEncoding jsonOptions
BattlePlace/WebApi/Types.hs view
@@ -15,13 +15,13 @@ , Client(..) , ClientType(..) , clientTypeOf- , ClientToken(..) , ProjectServerId(..) , ProjectServerToken(..) , MatchTeamSize , MatchTag(..) , MatchPlayerInfo(..) , MatchToken(..)+ , MatchFailureReason(..) , SessionToken(..) , SessionId(..) , ServerSessionToken(..)@@ -142,16 +142,6 @@ Client_steam {} -> ClientType_steam Client_test {} -> ClientType_test -data ClientToken = ClientToken- { clientToken_projectId :: {-# UNPACK #-} !ProjectId- , clientToken_client :: !Client- } deriving Generic-instance J.FromJSON ClientToken where- parseJSON = J.genericParseJSON jsonOptions-instance J.ToJSON ClientToken where- toJSON = J.genericToJSON jsonOptions- toEncoding = J.genericToEncoding jsonOptions- -- | Project's server id. newtype ProjectServerId = ProjectServerId Base64Word64 deriving (Eq, Hashable, J.FromJSON, J.FromJSONKey, J.ToJSON, J.ToJSONKey) @@ -169,8 +159,7 @@ -- | Match token. data MatchToken = MatchToken- { matchToken_projectId :: {-# UNPACK #-} !ProjectId- , matchToken_client :: !Client+ { } deriving Generic instance J.FromJSON MatchToken where parseJSON = J.genericParseJSON jsonOptions@@ -178,12 +167,26 @@ toJSON = J.genericToJSON jsonOptions toEncoding = J.genericToEncoding jsonOptions +-- | Reason of match failure.+data MatchFailureReason+ -- | Failed to make a match in a specified time.+ = MatchFailureReason_timedOut+ -- | Match was made, but no server is available (and use of server is mandatory).+ | MatchFailureReason_noServer+ -- | Matching was explicitly cancelled by user.+ | MatchFailureReason_cancelled+ deriving Generic+instance J.FromJSON MatchFailureReason where+ parseJSON = J.genericParseJSON jsonOptions+instance J.ToJSON MatchFailureReason where+ toJSON = J.genericToJSON jsonOptions+ toEncoding = J.genericToEncoding jsonOptions+ -- | Session token. data SessionToken = SessionToken { sessionToken_sessionId :: !SessionId , sessionToken_teamIndex :: {-# UNPACK #-} !Int , sessionToken_mateIndex :: {-# UNPACK #-} !Int- , sessionToken_client :: !Client } deriving Generic instance J.FromJSON SessionToken where parseJSON = J.genericParseJSON jsonOptions
battleplace.cabal view
@@ -1,5 +1,5 @@ name: battleplace-version: 0.1.0.1+version: 0.1.0.2 synopsis: Core definitions for BattlePlace.io service description: Core definitions for BattlePlace.io service license: MIT@@ -19,6 +19,7 @@ BattlePlace.Skill.Glicko.Types BattlePlace.Token.Types BattlePlace.WebApi+ BattlePlace.WebApi.Auth BattlePlace.WebApi.Types other-modules: build-depends: