packages feed

battlenet 0.1.0.1 → 0.2.0.0

raw patch · 5 files changed

+21/−16 lines, 5 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

+ BattleNet.ApiKey: BattleNetConnectionInfo :: BattleNetApiKey -> Text -> BattleNetConnectionInfo
+ BattleNet.ApiKey: bnetApiKeyText :: BattleNetApiKey -> Text
+ BattleNet.ApiKey: data BattleNetConnectionInfo
- BattleNet.ApiKey: BattleNetApiKey :: Text -> Text -> Text -> BattleNetApiKey
+ BattleNet.ApiKey: BattleNetApiKey :: Text -> Text -> BattleNetApiKey
- BattleNet.ApiKey: bnetApiKey :: BattleNetApiKey -> Text
+ BattleNet.ApiKey: bnetApiKey :: BattleNetConnectionInfo -> BattleNetApiKey
- BattleNet.ApiKey: bnetRegion :: BattleNetApiKey -> Text
+ BattleNet.ApiKey: bnetRegion :: BattleNetConnectionInfo -> Text
- BattleNet.Plumbing: apiEndpoint :: FromJSON a => [Text] -> [(Text, Text)] -> Manager -> BattleNetApiKey -> IO a
+ BattleNet.Plumbing: apiEndpoint :: FromJSON a => [Text] -> [(Text, Text)] -> Manager -> BattleNetConnectionInfo -> IO a
- BattleNet.Plumbing: apiEndpointUrl :: [Text] -> [(Text, Text)] -> BattleNetApiKey -> Text
+ BattleNet.Plumbing: apiEndpointUrl :: [Text] -> [(Text, Text)] -> BattleNetConnectionInfo -> Text
- BattleNet.Plumbing: apiEndpointUrl' :: Text -> BattleNetApiKey -> [Text] -> [(Text, Text)] -> Text
+ BattleNet.Plumbing: apiEndpointUrl' :: Text -> BattleNetConnectionInfo -> [Text] -> [(Text, Text)] -> Text
- BattleNet.WoW: character :: Text -> Text -> Manager -> BattleNetApiKey -> IO WoWCharacterInfo
+ BattleNet.WoW: character :: Text -> Text -> Manager -> BattleNetConnectionInfo -> IO WoWCharacterInfo
- BattleNet.WoW: guildMembers :: Text -> Text -> Manager -> BattleNetApiKey -> IO [WoWGuildMemberInfo]
+ BattleNet.WoW: guildMembers :: Text -> Text -> Manager -> BattleNetConnectionInfo -> IO [WoWGuildMemberInfo]
- BattleNet.WoW: userCharacters :: Text -> Manager -> BattleNetApiKey -> IO [WoWCharacterInfo]
+ BattleNet.WoW: userCharacters :: Text -> Manager -> BattleNetConnectionInfo -> IO [WoWCharacterInfo]
- BattleNet.WoWStatic: classes :: Manager -> BattleNetApiKey -> IO [WoWClassInfo]
+ BattleNet.WoWStatic: classes :: Manager -> BattleNetConnectionInfo -> IO [WoWClassInfo]
- BattleNet.WoWStatic: talents :: Manager -> BattleNetApiKey -> IO (Map WoWClassInfoId WoWTalentInfo)
+ BattleNet.WoWStatic: talents :: Manager -> BattleNetConnectionInfo -> IO (Map WoWClassInfoId WoWTalentInfo)

Files

BattleNet/ApiKey.hs view
@@ -1,9 +1,14 @@-module BattleNet.ApiKey(BattleNetApiKey(..)) where+module BattleNet.ApiKey(BattleNetApiKey(..), BattleNetConnectionInfo(..)) where  import Data.Text  data BattleNetApiKey = BattleNetApiKey-    { bnetApiKey :: Text+    { bnetApiKeyText :: Text     , bnetApiSecret :: Text+    }+++data BattleNetConnectionInfo = BattleNetConnectionInfo+    { bnetApiKey :: BattleNetApiKey     , bnetRegion :: Text     }
BattleNet/Plumbing.hs view
@@ -12,10 +12,10 @@ import qualified  Data.Aeson as Aeson import Network.HTTP.Conduit hiding (path, queryString) -apiEndpointUrl' :: Text -> BattleNetApiKey -> [Text] -> [(Text, Text)] -> Text-apiEndpointUrl' baseDomain key parts queryString = Data.Text.concat $ mconcat+apiEndpointUrl' :: Text -> BattleNetConnectionInfo -> [Text] -> [(Text, Text)] -> Text+apiEndpointUrl' baseDomain settings parts queryString = Data.Text.concat $ mconcat         [ ["https://"-          , bnetRegion key+          , bnetRegion settings           , "."           , baseDomain           , "/"]@@ -26,12 +26,12 @@           renderedQueryStringParam (k, v) = [k, "=", v]           renderedQueryStringParams = mconcat . intersperse ["&"] . fmap renderedQueryStringParam -apiEndpointUrl :: [Text] -> [(Text, Text)] -> BattleNetApiKey -> Text-apiEndpointUrl parts queryString key = apiEndpointUrl' "api.battle.net" key parts (("apikey", bnetApiKey key) : queryString)+apiEndpointUrl :: [Text] -> [(Text, Text)] -> BattleNetConnectionInfo -> Text+apiEndpointUrl parts queryString settings = apiEndpointUrl' "api.battle.net" settings parts (("apikey", bnetApiKeyText $ bnetApiKey settings) : queryString) -apiEndpoint :: FromJSON a => [Text] -> [(Text, Text)] -> Manager -> BattleNetApiKey -> IO a-apiEndpoint parts queryString manager key = do-    path <- parseUrl $ unpack $ apiEndpointUrl parts queryString key+apiEndpoint :: FromJSON a => [Text] -> [(Text, Text)] -> Manager -> BattleNetConnectionInfo -> IO a+apiEndpoint parts queryString manager settings = do+    path <- parseUrl $ unpack $ apiEndpointUrl parts queryString settings     response <- responseBody <$> httpLbs path manager     let decoded = Aeson.decode response     return $ fromMaybe (error $ mconcat ["Invalid response from ", show path, ": ", show response]) decoded
BattleNet/WoW.hs view
@@ -64,13 +64,13 @@     parseJSON (Object v) = GuildMemberWrapper <$> v .: "members"     parseJSON _ = mzero -character :: Text -> Text -> Manager -> BattleNetApiKey -> IO WoWCharacterInfo+character :: Text -> Text -> Manager -> BattleNetConnectionInfo -> IO WoWCharacterInfo character realm name = apiEndpoint ["wow", "character", realm, name] [] -userCharacters :: Text -> Manager -> BattleNetApiKey -> IO [WoWCharacterInfo]+userCharacters :: Text -> Manager -> BattleNetConnectionInfo -> IO [WoWCharacterInfo] userCharacters accessToken manager key = unwrapChars <$> apiEndpoint ["wow", "user", "characters"] [("access_token", accessToken)] manager key     where unwrapChars (UserCharactersWrapper chars) = chars -guildMembers :: Text -> Text -> Manager -> BattleNetApiKey -> IO [WoWGuildMemberInfo]+guildMembers :: Text -> Text -> Manager -> BattleNetConnectionInfo -> IO [WoWGuildMemberInfo] guildMembers realm name manager key = unwrapMembers <$> apiEndpoint ["wow", "guild", realm, name] [("fields", "members")] manager key     where unwrapMembers (GuildMemberWrapper chars) = chars
BattleNet/WoWStatic.hs view
@@ -63,8 +63,8 @@             }     parseJSON _ = mzero -classes :: Manager -> BattleNetApiKey -> IO [WoWClassInfo]+classes :: Manager -> BattleNetConnectionInfo -> IO [WoWClassInfo] classes manager key = extractClassesInfo <$> apiEndpoint ["wow", "data", "character", "classes"] [] manager key -talents :: Manager -> BattleNetApiKey -> IO (Map WoWClassInfoId WoWTalentInfo)+talents :: Manager -> BattleNetConnectionInfo -> IO (Map WoWClassInfoId WoWTalentInfo) talents manager key = mapKeys (WoWClassInfoId . read) <$> apiEndpoint ["wow", "data", "talents"] [] manager key
battlenet.cabal view
@@ -10,7 +10,7 @@ -- PVP summary:      +-+------- breaking API changes --                   | | +----- non-breaking API additions --                   | | | +--- code changes with no API change-version:             0.1.0.1+version:             0.2.0.0  -- A short (one-line) description of the package. synopsis:            API client for Battle.Net