import SmugMug
import http


class Image(object):
    def __init__(self, title=None, caption=None, keywords=None, hidden=False,
                 altitude=None, latitude=None, longitude=None, watermarked=False,
                 is_video=False, uri=None, image_key=None, collectable=False, can_edit=False, smugmug=None):
        self.title = title
        self.caption = caption
        self.keywords = keywords
        self.hidden = hidden
        self.altitude = altitude
        self.latitude = latitude
        self.longitude = longitude
        self.watermarked = watermarked
        self.is_video = is_video
        self.uri = uri
        self.image_key = image_key
        self.collectable = collectable
        self.can_edit = can_edit

        self.original_height = 0
        self.original_width = 0
        self.original_size = 0
        self.metadata = {}
        self.comments = {}
        self.prices = {}
        self.sizes = {}
        self.album = {}
        self.owner = None
        self.size_details = {}
        self.point_of_interest = {}
        self.point_of_interest_crops = {}
        self.regions = {}

        self.smugmug = smugmug


        # Use to hold JSON response for image, possibly, as a cache?
        self.json = None

    def get_size(self, size="Original"):
        """ Convenience function to return the URL for the requested size"""
        return self.sizes[size]

    def get_largest(self):
        """ Return largest size"""
        return self.get_size()

    def download(self):
        """ Download copy of image"""
        return 0

    def refresh(self):
        """ Updates Image object with data from SmugMug """
        if self.image_key is not None:
            downloader = http.downloader.Downloader(smugmug=self.smugmug)
            downloader.refresh_by_key("Image", self.image_key)
        return 0

    def update(self):
        """ Updates the SmugMug Image with new data"""
        return 0

    def upload(self):
        """ Uploads image to SmugMug"""
        return 0

@@ -1119,16 +1119,47 @@
 ons = %7B%7D
+%0A        self.image_format = %22%22
 %0A%0A      
@@ -1280,16 +1280,1208 @@
 = None%0A%0A
+    def _unpack_json(self, json_dictionary):%0A        %22%22%22%0A        Unpack to dictionary containing the JSON response for the image.%0A        Used to update values for Image object.%0A        %22:param json_dictionary: Dictionary containing the JSON of the %22Response%22 key%0A        :return:%0A        %22%22%22%0A        image_root = json_dictionary%5B%22Image%22%5D%0A        self.title = image_root%5B%22Title%22%5D%0A        self.caption = image_root%5B%22Caption%22%5D%0A        self.watermarked = image_root%5B%22Watermarked%22%5D%0A        self.latitude = image_root%5B%22Latitude%22%5D%0A        self.longitude = image_root%5B%22Longitude%22%5D%0A        self.can_edit = image_root%5B%22CanEdit%22%5D%0A        self.hidden = image_root%5B%22Hidden%22%5D%0A        self.collectable = image_root%5B%22Collectable%22%5D%0A        self.altitude = image_root%5B%22Altitude%22%5D%0A        self.image_key = image_root%5B%22ImageKey%22%5D%0A        self.is_video = image_root%5B%22IsVideo%22%5D%0A        self.original_height = image_root%5B%22OriginalHeight%22%5D%0A        self.original_width = image_root%5B%22OriginalWidth%22%5D%0A        self.original_size = image_root%5B%22OriginalSize%22%5D%0A        self.keywords = image_root%5B%22KeywordArray%22%5D%0A        self.image_format = image_root%5B%22Format%22%5D%0A%0A        self.uri = json_dictionary%5B%22Uri%22%5D%0A        return 0%0A%0A
     def 

Add updating some Image values from JSON response