"""
hudai.resources.tweet
"""
from ..helpers.resource import Resource


class TweetResource(Resource):
    def __init__(self, client):
        Resource.__init__(self, client, base_path='/people/tweets')
        self.resource_name = 'Tweet'

    def list(self, person_id, page=None):
        query_params = self._set_limit_offset({
            'person_id': person_id,
            'page': page
        })

        return self.http_get('/', query_params=query_params)

    def create(self, person_id, twitter_tweet_id, twitter_created_at, text):
        return self.http_post('/',
                              data={
                                  'twitter_tweet_id': twitter_tweet_id,
                                  'twitter_created_at': twitter_created_at,
                                  'person_id': person_id,
                                  'text': text
                              })

    def fetch(self, tweet_id):
        return self.http_get('/{id}', params={'id': tweet_id})

    def delete(self, tweet_id):
        return self.http_delete('/{id}', params={'id': tweet_id})
