Common code for the add and remove endpoints.

def _add_remove(self, action, album, objects, object_type=None,
                    **kwds):
        """Common code for the add and remove endpoints."""
        # Ensure we have an iterable of objects
        if not isinstance(objects, collections.Iterable):
            objects = [objects]

        # Extract the type of the objects
        if object_type is None:
            object_type = objects[0].get_type()

        for i, obj in enumerate(objects):
            if isinstance(obj, TroveboxObject):
                # Ensure all objects are the same type
                if obj.get_type() != object_type:
                    raise ValueError("Not all objects are of type '%s'"
                                     % object_type)
                # Extract the ids of the objects
                objects[i] = obj.id

        result = self._client.post("/album/%s/%s/%s.json" %
                                   (self._extract_id(album),
                                    object_type, action),
                                   ids=objects, **kwds)["result"]

        # API currently doesn't return the updated album
        # (frontend issue #1369)
        if isinstance(result, bool): # pragma: no cover
            result = self._client.get("/album/%s/view.json" %
                                      self._extract_id(album))["result"]
        return Album(self._client, result)