# -*- coding: utf-8 -*-

"""pybooru.api_danbooru

This module contains all API calls of Danbooru for Pybooru.

Classes:
    Danbooru -- Contains all API calls.
"""

# __future__ imports
from __future__ import absolute_import

# pybooru imports
from .exceptions import PybooruAPIError


class DanbooruApi(object):
    """Contains all Danbooru API calls.

    API Versions: v2.105.0
    doc: https://danbooru.donmai.us/wiki_pages/43568
    """

    def post_list(self, **params):
        """Get a list of posts.

        Parameters:
            limit: How many posts you want to retrieve. There is a hard limit
                   of 100 posts per request.
            page: The page number.
            tags: The tags to search for. Any tag combination that works on the
                  web site will work here. This includes all the meta-tags.
            raw: When this parameter is set the tags parameter will not be
                 parsed for aliased tags, metatags or multiple tags, and will
                 instead be parsed as a single literal tag.
        """
        return self._get('posts.json', params)

    def post_show(self, id_):
        """Get a post

        Parameters:
            id_: where id_ is the post id.
        """
        return self._get('/posts/{0}.json'.format(id_))

    def post_update(self, id_, tag_string=None, rating=None, source=None,
                    parent_id=None):
        """Update a specific post.

        Parameters:
            id_: The id number of the post to update.
            tag_string: A space delimited list of tags.
            rating: The rating for the post. Can be: safe, questionable, or
                    explicit.
            source: If this is a URL, Danbooru will download the file.
            parent_id: The ID of the parent post.
        """
        params = {
            'post[tag_string]': tag_string,
            'post[rating]': rating,
            'ost[source]': source,
            'post[parent_id]': parent_id
            }
        return self._get('/posts/{0}.json'.format(id_), params, 'PUT')

    def post_revert(self, id_, version_id):
        """Function to reverts a post to a previous version (Requires login).

        Parameters:
            version_id: REQUIRED The post version id to revert to.
        """
        return self._get('/posts/{0}/revert.json'.format(id_),
                         {'version_id': version_id}, 'PUT')

@@ -1162,17 +1162,18 @@
 t a post
+.
 %0A
-
 %0A       
@@ -1437,24 +1437,41 @@
 pecific post
+ (Requires login)
 .%0A%0A        P
@@ -2226,32 +2226,67 @@
     Parameters:%0A
+            id_: REQUIRED post id.%0A
             vers
@@ -2411,16 +2411,16 @@
 t(id_),%0A
-
         
@@ -2463,16 +2463,385 @@
 ion_id%7D, 'PUT')%0A
+%0A    def post_copy_notes(self, id_, other_post_id):%0A        %22%22%22Function to copy notes (requires login).%0A%0A        Parameters:%0A            id_: Post id.%0A            other_post_id: REQUIRED The id of the post to copy notes to.%0A        %22%22%22%0A        return self._get('/posts/%7B0%7D/copy_notes.json'.format(id_),%0A                         %7B'other_post_id': other_post_id%7D, 'PUT')%0A

implement post_copy_notes()