twitter-types 0.4.20140809 → 0.5.0
raw patch · 4 files changed
+156/−46 lines, 4 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ Web.Twitter.Types: ImageSizeType :: Int -> Int -> Text -> ImageSizeType
+ Web.Twitter.Types: UploadedMedia :: Integer -> Integer -> ImageSizeType -> UploadedMedia
+ Web.Twitter.Types: data ImageSizeType
+ Web.Twitter.Types: data UploadedMedia
+ Web.Twitter.Types: imageSizeTypeHeight :: ImageSizeType -> Int
+ Web.Twitter.Types: imageSizeTypeType :: ImageSizeType -> Text
+ Web.Twitter.Types: imageSizeTypeWidth :: ImageSizeType -> Int
+ Web.Twitter.Types: instance FromJSON ImageSizeType
+ Web.Twitter.Types: instance FromJSON UploadedMedia
+ Web.Twitter.Types: instance Show ImageSizeType
+ Web.Twitter.Types: instance Show UploadedMedia
+ Web.Twitter.Types: uploadedMediaId :: UploadedMedia -> Integer
+ Web.Twitter.Types: uploadedMediaImage :: UploadedMedia -> ImageSizeType
+ Web.Twitter.Types: uploadedMediaSize :: UploadedMedia -> Integer
+ Web.Twitter.Types.Lens: class AsImageSize a
+ Web.Twitter.Types.Lens: class HasCreatedAt a
+ Web.Twitter.Types.Lens: contributorId :: Lens' Contributor UserId
+ Web.Twitter.Types.Lens: contributorScreenName :: Lens' Contributor Text
+ Web.Twitter.Types.Lens: data Contributor
+ Web.Twitter.Types.Lens: data ImageSizeType
+ Web.Twitter.Types.Lens: data UploadedMedia
+ Web.Twitter.Types.Lens: height :: AsImageSize a => Lens' a Int
+ Web.Twitter.Types.Lens: imageSizeTypeHeight :: Lens' ImageSizeType Int
+ Web.Twitter.Types.Lens: imageSizeTypeType :: Lens' ImageSizeType Text
+ Web.Twitter.Types.Lens: imageSizeTypeWidth :: Lens' ImageSizeType Int
+ Web.Twitter.Types.Lens: instance AsImageSize ImageSizeType
+ Web.Twitter.Types.Lens: instance AsImageSize MediaSize
+ Web.Twitter.Types.Lens: instance HasCreatedAt DirectMessage
+ Web.Twitter.Types.Lens: instance HasCreatedAt RetweetedStatus
+ Web.Twitter.Types.Lens: instance HasCreatedAt SearchStatus
+ Web.Twitter.Types.Lens: instance HasCreatedAt Status
+ Web.Twitter.Types.Lens: instance HasCreatedAt User
+ Web.Twitter.Types.Lens: uploadedMediaId :: Lens' UploadedMedia Integer
+ Web.Twitter.Types.Lens: uploadedMediaImage :: Lens' UploadedMedia ImageSizeType
+ Web.Twitter.Types.Lens: uploadedMediaSize :: Lens' UploadedMedia Integer
+ Web.Twitter.Types.Lens: width :: AsImageSize a => Lens' a Int
- Web.Twitter.Types.Lens: created_at :: AsStatus s => Lens' s DateString
+ Web.Twitter.Types.Lens: created_at :: HasCreatedAt a => Lens' a DateString
- Web.Twitter.Types.Lens: entityBody :: Lens (Entity a_ao95) (Entity b_ao96) a_ao95 b_ao96
+ Web.Twitter.Types.Lens: entityBody :: Lens (Entity a_aoB4) (Entity b_aoB5) a_aoB4 b_aoB5
- Web.Twitter.Types.Lens: entityIndices :: Lens' (Entity a_a4Ym) EntityIndices
+ Web.Twitter.Types.Lens: entityIndices :: Lens' (Entity a_a4Yw) EntityIndices
- Web.Twitter.Types.Lens: searchResultSearchMetadata :: Lens' (SearchResult body_a4Z8) SearchMetadata
+ Web.Twitter.Types.Lens: searchResultSearchMetadata :: Lens' (SearchResult body_a4Zi) SearchMetadata
- Web.Twitter.Types.Lens: searchResultStatuses :: Lens (SearchResult a_anNI) (SearchResult b_anNJ) a_anNI b_anNJ
+ Web.Twitter.Types.Lens: searchResultStatuses :: Lens (SearchResult a_aols) (SearchResult b_aolt) a_aols b_aolt
Files
- .travis.yml +1/−0
- Web/Twitter/Types.hs +46/−0
- Web/Twitter/Types/Lens.hs +108/−45
- twitter-types.cabal +1/−1
.travis.yml view
@@ -9,6 +9,7 @@ matrix: allow_failures:+ - env: GHCVER=7.4.2 - env: GHCVER=head before_install:
Web/Twitter/Types.hs view
@@ -32,6 +32,8 @@ , Place(..) , BoundingBox(..) , Contributor(..)+ , UploadedMedia (..)+ , ImageSizeType (..) , checkError ) where@@ -80,6 +82,8 @@ js = parseJSON v parseJSON _ = mzero +-- | This type represents a Twitter tweet structure.+-- See <https://dev.twitter.com/docs/platform-objects/tweets>. data Status = Status { statusContributors :: Maybe [Contributor] , statusCoordinates :: Maybe Coordinates@@ -301,6 +305,8 @@ <*> s .: "user_id" parseJSON _ = mzero +-- | This type represents the Twitter user.+-- See <https://dev.twitter.com/docs/platform-objects/users>. data User = User { userContributorsEnabled :: Bool , userCreatedAt :: DateString@@ -410,6 +416,8 @@ <*> o .: "user" parseJSON _ = mzero +-- | Hashtag entity.+-- See <https://dev.twitter.com/docs/platform-objects/entities#obj-hashtags>. data HashTagEntity = HashTagEntity { hashTagText :: Text -- ^ The Hashtag text@@ -420,6 +428,8 @@ HashTagEntity <$> o .: "text" parseJSON _ = mzero +-- | User mention entity.+-- See <https://dev.twitter.com/docs/platform-objects/entities#obj-usermention>. data UserEntity = UserEntity { userEntityUserId :: UserId@@ -434,6 +444,8 @@ <*> o .: "screen_name" parseJSON _ = mzero +-- | URL entity.+-- See <https://dev.twitter.com/docs/platform-objects/entities#obj-url>. data URLEntity = URLEntity { ueURL :: URIString -- ^ The URL that was extracted@@ -468,6 +480,8 @@ <*> parseJSON v parseJSON _ = mzero +-- | Size entity.+-- See <https://dev.twitter.com/docs/platform-objects/entities#obj-size>. data MediaSize = MediaSize { msWidth :: Int@@ -494,6 +508,8 @@ <*> o .: "type" parseJSON _ = mzero +-- | This type represents a place, named locations with corresponding geo coordinates.+-- See <https://dev.twitter.com/docs/platform-objects/places>. data Place = Place { placeAttributes :: HashMap Text Text@@ -520,6 +536,8 @@ <*> o .: "url" parseJSON _ = mzero +-- | A bounding box of coordinates which encloses the place.+-- See <https://dev.twitter.com/docs/platform-objects/places#obj-boundingbox>. data BoundingBox = BoundingBox { boundingBoxCoordinates :: [[[Double]]]@@ -533,6 +551,7 @@ parseJSON _ = mzero -- | Entity handling.+-- See <https://dev.twitter.com/docs/platform-objects/entities>. data Entities = Entities { enHashTags :: [Entity HashTagEntity]@@ -577,3 +596,30 @@ Contributor <$> o .: "id" <*> o .: "screen_name" parseJSON _ = mzero++-- | Image size type. This type is included in the API response of \"\/1.1\/media\/upload.json\".+data ImageSizeType = ImageSizeType+ { imageSizeTypeWidth :: Int+ , imageSizeTypeHeight :: Int+ , imageSizeTypeType :: Text+ } deriving Show+instance FromJSON ImageSizeType where+ parseJSON (Object o) =+ ImageSizeType <$> o .: "w"+ <*> o .: "h"+ <*> o .: "image_type"+ parseJSON v = fail $ "unknown value: " ++ show v++-- | This type is represents the API response of \"\/1.1\/media\/upload.json\".+-- See <https://dev.twitter.com/docs/api/multiple-media-extended-entities>.+data UploadedMedia = UploadedMedia+ { uploadedMediaId :: Integer+ , uploadedMediaSize :: Integer+ , uploadedMediaImage :: ImageSizeType+ } deriving Show+instance FromJSON UploadedMedia where+ parseJSON (Object o) =+ UploadedMedia <$> o .: "media_id"+ <*> o .: "size"+ <*> o .: "image"+ parseJSON v = fail $ "unknown value: " ++ show v
Web/Twitter/Types/Lens.hs view
@@ -2,37 +2,15 @@ {-# LANGUAGE OverloadedStrings, DeriveDataTypeable, RankNTypes, CPP, FlexibleInstances #-} module Web.Twitter.Types.Lens- ( TT.DateString- , TT.UserId- , TT.Friends- , TT.URIString- , TT.UserName- , TT.StatusId- , TT.LanguageCode- , TT.StreamingAPI(..)- , TT.Status- , TT.SearchResult- , TT.SearchStatus- , TT.SearchMetadata- , TT.RetweetedStatus- , TT.DirectMessage- , TT.EventTarget(..)- , TT.Event- , TT.Delete- , TT.User- , TT.List- , TT.Entities- , TT.EntityIndices- , TT.Entity- , TT.HashTagEntity- , TT.UserEntity- , TT.URLEntity- , TT.MediaEntity- , TT.MediaSize- , TT.Coordinates- , TT.Place- , TT.BoundingBox+ (+ -- * Type classes+ AsStatus(..)+ , AsUser(..)+ , HasCreatedAt(..)+ , AsImageSize(..) + -- * 'TT.Status'+ , TT.Status , statusContributors , statusCoordinates , statusCreatedAt@@ -61,9 +39,13 @@ , statusWithheldInCountries , statusWithheldScope + -- * 'TT.SearchResult'+ , TT.SearchResult , searchResultStatuses , searchResultSearchMetadata + -- * 'TT.SearchStatus'+ , TT.SearchStatus , searchStatusCreatedAt , searchStatusId , searchStatusText@@ -71,6 +53,8 @@ , searchStatusUser , searchStatusCoordinates + -- * 'TT.SearchMetadata'+ , TT.SearchMetadata , searchMetadataMaxId , searchMetadataSinceId , searchMetadataRefreshURL@@ -81,6 +65,8 @@ , searchMetadataQuery , searchMetadataMaxIdStr + -- * 'TT.RetweetedStatus'+ , TT.RetweetedStatus , rsCreatedAt , rsId , rsText@@ -91,6 +77,8 @@ , rsRetweetedStatus , rsCoordinates + -- * 'TT.DirectMessage'+ , TT.DirectMessage , dmCreatedAt , dmSenderScreenName , dmSender@@ -102,15 +90,21 @@ , dmSenderId , dmCoordinates + -- * 'TT.Event'+ , TT.Event , evCreatedAt , evTargetObject , evEvent , evTarget , evSource + -- * 'TT.Delete'+ , TT.Delete , delId , delUserId + -- * 'TT.User'+ , TT.User , userContributorsEnabled , userCreatedAt , userDefaultProfile@@ -152,6 +146,8 @@ , userWithheldInCountries , userWithheldScope + -- * 'TT.List'+ , TT.List , listId , listName , listFullName@@ -160,16 +156,36 @@ , listMode , listUser + -- * 'TT.Entities'+ , TT.Entities+ , enHashTags+ , enUserMentions+ , enURLs+ , enMedia++ -- * 'TT.Entity'+ , TT.Entity+ , entityBody+ , entityIndices++ -- * 'TT.HashTagEntity'+ , TT.HashTagEntity , hashTagText + -- * 'TT.UserEntity'+ , TT.UserEntity , userEntityUserId , userEntityUserName , userEntityUserScreenName + -- * 'TT.URLEntity'+ , TT.URLEntity , ueURL , ueExpanded , ueDisplay + -- * 'TT.MediaEntity'+ , TT.MediaEntity , meType , meId , meSizes@@ -177,13 +193,19 @@ , meMediaURLHttps , meURL + -- * 'TT.MediaSize'+ , TT.MediaSize , msWidth , msHeight , msResize + -- * 'TT.Coordinates'+ , TT.Coordinates , coordinates , coordinatesType + -- * 'TT.Place'+ , TT.Place , placeAttributes , placeBoundingBox , placeCountry@@ -194,19 +216,39 @@ , placeType , placeURL + -- * 'TT.BoundingBox'+ , TT.BoundingBox , boundingBoxCoordinates , boundingBoxType - , enHashTags- , enUserMentions- , enURLs- , enMedia+ -- * 'TT.Contributor'+ , TT.Contributor+ , contributorId+ , contributorScreenName - , entityBody- , entityIndices+ -- * 'TT.UploadedMedia'+ , TT.UploadedMedia+ , uploadedMediaId+ , uploadedMediaSize+ , uploadedMediaImage - , AsStatus(..)- , AsUser(..)+ -- * 'TT.ImageSizeType'+ , TT.ImageSizeType+ , imageSizeTypeWidth+ , imageSizeTypeHeight+ , imageSizeTypeType++ -- * Type aliases and sum types+ , TT.DateString+ , TT.UserId+ , TT.Friends+ , TT.URIString+ , TT.UserName+ , TT.StatusId+ , TT.LanguageCode+ , TT.StreamingAPI(..)+ , TT.EventTarget(..)+ , TT.EntityIndices ) where @@ -225,6 +267,8 @@ makeLenses ''TT.Delete makeLenses ''TT.User makeLenses ''TT.List+makeLenses ''TT.Entities+makeLenses ''TT.Entity makeLenses ''TT.HashTagEntity makeLenses ''TT.UserEntity makeLenses ''TT.URLEntity@@ -233,42 +277,38 @@ makeLenses ''TT.Coordinates makeLenses ''TT.Place makeLenses ''TT.BoundingBox-makeLenses ''TT.Entities-makeLenses ''TT.Entity+makeLenses ''TT.Contributor+makeLenses ''TT.ImageSizeType+makeLenses ''TT.UploadedMedia class AsStatus s where status_id :: Lens' s TT.StatusId text :: Lens' s Text user :: Lens' s TT.User- created_at :: Lens' s TT.DateString geolocation :: Lens' s (Maybe TT.Coordinates) instance AsStatus TT.Status where status_id = statusId text = statusText user = statusUser- created_at = statusCreatedAt geolocation = statusCoordinates instance AsStatus TT.SearchStatus where status_id = searchStatusId text = searchStatusText user = searchStatusUser- created_at = searchStatusCreatedAt geolocation = searchStatusCoordinates instance AsStatus TT.RetweetedStatus where status_id = rsId text = rsText user = rsUser- created_at = rsCreatedAt geolocation = rsCoordinates instance AsStatus TT.DirectMessage where status_id = dmId text = dmText user = dmSender- created_at = dmCreatedAt geolocation = dmCoordinates class AsUser u where@@ -290,3 +330,26 @@ user_id = entityBody.userEntityUserId name = entityBody.userEntityUserName screen_name = entityBody.userEntityUserScreenName++class HasCreatedAt a where+ created_at :: Lens' a TT.DateString+instance HasCreatedAt TT.Status where+ created_at = statusCreatedAt+instance HasCreatedAt TT.SearchStatus where+ created_at = searchStatusCreatedAt+instance HasCreatedAt TT.RetweetedStatus where+ created_at = rsCreatedAt+instance HasCreatedAt TT.DirectMessage where+ created_at = dmCreatedAt+instance HasCreatedAt TT.User where+ created_at = userCreatedAt++class AsImageSize a where+ width :: Lens' a Int+ height :: Lens' a Int+instance AsImageSize TT.MediaSize where+ width = msWidth+ height = msHeight+instance AsImageSize TT.ImageSizeType where+ width = imageSizeTypeWidth+ height = imageSizeTypeHeight
twitter-types.cabal view
@@ -1,5 +1,5 @@ name: twitter-types-version: 0.4.20140809+version: 0.5.0 license: BSD3 license-file: LICENSE author: Takahiro HIMURA