module Flickr.Photos.Geo
( getLocation
, removeLocation
, setLocation
, batchCorrectLocation
, correctLocation
, photosForLocation
, setContext
, getPerms
, setPerms
) where
import Flickr.Monad
import Flickr.Utils
import Flickr.Types
import Flickr.Types.Import
batchCorrectLocation :: GeoLocation -> Either PlaceID WhereOnEarthID -> FM ()
batchCorrectLocation (lat,lon,acc) ei = withWritePerm $ postMethod $
flickCall_ "flickr.photos.geo.batchCorrectLocation"
(eiArg "place_id" "woe_id" ei $
mbArg "accuracy" (fmap show acc) $
[ ("latitude", lat)
, ("longitude", lon)
])
correctLocation :: PhotoID -> Either PlaceID WhereOnEarthID -> FM ()
correctLocation pid ei = withWritePerm $ postMethod $
flickCall_ "flickr.photos.geo.correctLocation"
(eiArg "place_id" "woe_id" ei $
[ ("photo_id", pid) ])
getLocation :: PhotoID -> FM GeoLocation
getLocation pid =
flickTranslate toGeoLocation $
flickrCall "flickr.photos.geo.getLocation"
[ ("photo_id", pid) ]
getPerms :: PhotoID -> FM Permissions
getPerms pid =
flickTranslate toPermissions $
flickrCall "flickr.photos.geo.getPerms"
[ ("photo_id", pid) ]
photosForLocation :: GeoLocation -> [PhotoInfo] -> FM (PhotoContext, [Photo])
photosForLocation (lat,lon,acc) extras = withReadPerm $
flickTranslate toPhotoList $
flickrCall "flickr.photo.geo.photosForLocation"
(mbArg "accuracy" (fmap show acc) $
lsArg "extras" (map show extras) $
[ ("latitude", lat)
, ("longitude", lon)
])
removeLocation :: PhotoID -> FM ()
removeLocation pid = withWritePerm $ postMethod $
flickCall_ "flickr.photos.geo.removeLocation"
[ ("photo_id", pid) ]
setContext :: PhotoID -> ContextID -> FM ()
setContext pid ctxtId = withWritePerm $ postMethod $
flickCall_ "flickr.photos.geo.setContext"
[ ("photo_id", pid)
, ("context", show ctxtId)
]
setLocation :: PhotoID -> GeoLocation -> FM ()
setLocation pid (la,lo,ac) = withWritePerm $ postMethod $
flickCall_ "flickr.photos.geo.setLocation"
(mbArg "accuracy" (fmap show ac) $
[ ("photo_id", pid)
, ("lat", la)
, ("lon", lo)
])
setPerms :: PhotoID -> Permissions -> FM ()
setPerms pid p = withWritePerm $ postMethod $
flickCall_ "flickr.photos.geo.setPerms"
[ ("photo_id", pid)
, ("is_public", showBool $ permIsPublic p)
, ("is_friend", showBool $ permIsFriend p)
, ("is_family", showBool $ permIsFamily p)
, ("is_contact", showBool (permIsFamily p || permIsFriend p))
]