# Tweepy
# Copyright 2009 Joshua Roesslein
# See LICENSE

from tweepy.error import TweepError


class Model(object):

    def __getstate__(self):
        # pickle
        pickle = {}
        for k, v in self.__dict__.items():
            if k == '_api':
                # do not pickle the api reference
                continue
            pickle[k] = v
        return pickle


class Status(Model):

    def destroy(self):
        return self._api.destroy_status(self.id)

    def retweet(self):
        return self._api.retweet(self.id)

    def retweets(self):
        return self._api.retweets(self.id)

    def favorite(self):
        return self._api.create_favorite(self.id)


class User(Model):

    def timeline(self, **kargs):
        return self._api.user_timeline(user_id=self.id, **kargs)

    def friends(self, **kargs):
        return self._api.friends(user_id=self.id, **kargs)

    def followers(self, **kargs):
        return self._api.followers(user_idself.id, **kargs)

    def follow(self):
        self._api.create_friendship(user_id=self.id)
        self.following = True

    def unfollow(self):
        self._api.destroy_friendship(user_id=self.id)
        self.following = False

    def lists_memberships(self):
        return self._api.lists_memberships(user=self.screen_name)

    def lists_subscriptions(self):
        return self._api.lists_subscriptions(user=self.screen_name)

    def lists(self):
        return self._api.lists(user=self.screen_name)

    def followers_ids(self):
        return self._api.followers_ids(user_id=self.id)


class DirectMessage(Model):

    def destroy(self):
        return self._api.destroy_direct_message(self.id)


class Friendship(Model):

    pass


class SavedSearch(Model):

    def destroy(self):
        return self._api.destroy_saved_search(self.id)


class SearchResult(Model):

    pass

class Retweet(Model):

    def destroy(self):
        return self._api.destroy_status(self.id)

class List(Model):

    def update(self, **kargs):
        return self._api.update_list(self.slug, **kargs)

    def destroy(self):
        return self._api.destroy_list(self.slug)

    def timeline(self, **kargs):
        return self._api.list_timeline(self.user.screen_name, self.slug, **kargs)

    def add_member(self, id):
        return self._api.add_list_member(self.slug, id)

    def remove_member(self, id):
        return self._api.remove_list_member(self.slug, id)

    def members(self, **kargs):
        return self._api.list_members(self.user.screen_name, self.slug, **kargs)

    def is_member(self, id):
        return self._api.is_list_member(self.user.screen_name, self.slug, id)

    def subscribe(self):
        return self._api.subscribe_list(self.user.screen_name, self.slug)

    def unsubscribe(self):
        return self._api.unsubscribe_list(self.user.screen_name, self.slug)

    def subscribers(self, **kargs):
        return self._api.list_subscribers(self.user.screen_name, self.slug, **kargs)

    def is_subscribed(self, id):
        return self._api.is_subscribed_list(self.user.screen_name, self.slug, id)

# link up default model implementations.
models = {
    'status': Status,
    'user': User,
    'direct_message': DirectMessage,
    'friendship': Friendship,
    'saved_search': SavedSearch,
    'search_result': SearchResult,
    'retweet': Retweet,
    'list': List,
}


@@ -1225,24 +1225,40 @@
 erships(self
+, *args, **kargs
 ):%0A        r
@@ -1304,32 +1304,48 @@
 self.screen_name
+, *args, **kargs
 )%0A%0A    def lists
@@ -1359,24 +1359,40 @@
 iptions(self
+, *args, **kargs
 ):%0A        r
@@ -1440,32 +1440,48 @@
 self.screen_name
+, *args, **kargs
 )%0A%0A    def lists
@@ -1481,24 +1481,40 @@
 f lists(self
+, *args, **kargs
 ):%0A        r
@@ -1556,16 +1556,32 @@
 een_name
+, *args, **kargs
 )%0A%0A    d
@@ -1597,24 +1597,40 @@
 ers_ids(self
+, *args, **kargs
 ):%0A        r
@@ -1670,24 +1670,40 @@
 r_id=self.id
+, *args, **kargs
 )%0A%0A%0Aclass Di

Allow for pagination and other parameters for some helper methods in User model.