Update and improve documentation for API.create_friendship
authorHarmon <Harmon758@gmail.com>
Wed, 7 Apr 2021 18:52:43 +0000 (13:52 -0500)
committerHarmon <Harmon758@gmail.com>
Wed, 7 Apr 2021 18:52:43 +0000 (13:52 -0500)
Automatically use docstring for documentation
Improve method and documentation order
Remove id parameter from documentation

docs/api.rst
tweepy/api.py

index 90025ea6e2f67972785a2f061330916bf8865d8b..7b53af7e8ccface260de2aba94d89a3a8ae8c1d9 100644 (file)
@@ -135,6 +135,8 @@ Follow, search, and get users
 
 .. automethod:: API.get_user
 
+.. automethod:: API.create_friendship
+
 
 Direct Message Methods
 ----------------------
@@ -195,18 +197,6 @@ Direct Message Methods
 Friendship Methods
 ------------------
 
-.. method:: API.create_friendship(id/screen_name/user_id, [follow])
-
-   Create a new friendship with the specified user (aka follow).
-
-   :param id: |uid|
-   :param screen_name: |screen_name|
-   :param user_id: |user_id|
-   :param follow: Enable notifications for the target user in addition to
-                  becoming friends.
-   :rtype: :class:`User` object
-
-
 .. method:: API.destroy_friendship(id/screen_name/user_id)
 
    Destroy a friendship with the specified user (aka unfollow).
index 9a7e36ed262d4a0b409d93185d398b13c0ddfc78..4006bebe43d31d5ae63ec3a6a682b484d36fb153 100644 (file)
@@ -1676,6 +1676,27 @@ class API:
             ), **kwargs
         )
 
+    @payload('user')
+    def create_friendship(self, **kwargs):
+        """create_friendship(*, screen_name, user_id, follow)
+
+        Create a new friendship with the specified user (aka follow).
+
+        :param screen_name: |screen_name|
+        :param user_id: |user_id|
+        :param follow: Enable notifications for the target user in addition to
+                       becoming friends.
+
+        :rtype: :class:`User` object
+
+        :reference: https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/follow-search-get-users/api-reference/post-friendships-create
+        """
+        return self.request(
+            'POST', 'friendships/create', endpoint_parameters=(
+                'screen_name', 'user_id', 'follow'
+            ), **kwargs
+        )
+
     def media_upload(self, filename, *, file=None, chunked=False,
                      media_category=None, additional_owners=None, **kwargs):
         """ :reference: https://developer.twitter.com/en/docs/twitter-api/v1/media/upload-media/overview
@@ -1905,16 +1926,6 @@ class API:
             ), id=id, **kwargs
         )
 
-    @payload('user')
-    def create_friendship(self, **kwargs):
-        """ :reference: https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/follow-search-get-users/api-reference/post-friendships-create
-        """
-        return self.request(
-            'POST', 'friendships/create', endpoint_parameters=(
-                'screen_name', 'user_id', 'follow'
-            ), **kwargs
-        )
-
     @payload('user')
     def destroy_friendship(self, **kwargs):
         """ :reference: https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/follow-search-get-users/api-reference/post-friendships-destroy