Replace APIMethod.json_payload with APIMethod.execute kwarg
authorHarmon <Harmon758@gmail.com>
Fri, 29 Jan 2021 16:20:15 +0000 (10:20 -0600)
committerHarmon <Harmon758@gmail.com>
Fri, 29 Jan 2021 16:20:15 +0000 (10:20 -0600)
Replace APIMethod.json_payload with APIMethod.execute json_payload keyword-only argument

tweepy/binder.py

index 8b42d56b6fda23675647fd7d6e5df355644b3df4..07f11affd1fb966761df4e1cb5db6cda5f0eaf98 100644 (file)
@@ -32,7 +32,6 @@ class APIMethod:
         if self.require_auth and not api.auth:
             raise TweepError('Authentication required!')
 
-        self.json_payload = kwargs.pop('json_payload', None)
         self.parser = kwargs.pop('parser', api.parser)
         self.headers = kwargs.pop('headers', {})
         self.build_parameters(args, kwargs)
@@ -72,7 +71,8 @@ class APIMethod:
 
         log.debug("PARAMS: %r", self.session.params)
 
-    def execute(self, method, *, post_data=None, return_cursors=False, use_cache=True):
+    def execute(self, method, *, json_payload=None, post_data=None,
+                return_cursors=False, use_cache=True):
         self.api.cached_result = False
 
         # Build the request URL
@@ -121,7 +121,7 @@ class APIMethod:
                                             full_url,
                                             headers=self.headers,
                                             data=post_data,
-                                            json=self.json_payload,
+                                            json=json_payload,
                                             timeout=self.api.timeout,
                                             auth=auth,
                                             proxies=self.api.proxy)
@@ -184,6 +184,7 @@ class APIMethod:
 
 def bind_api(*args, **kwargs):
     http_method = kwargs.pop('method', 'GET')
+    json_payload = kwargs.pop('json_payload', None)
     post_data = kwargs.pop('post_data', None)
     return_cursors = kwargs.pop('return_cursors', False)
     use_cache = kwargs.pop('use_cache', True)
@@ -194,7 +195,7 @@ def bind_api(*args, **kwargs):
             return method
         else:
             return method.execute(
-                http_method, post_data=post_data,
+                http_method, json_payload=json_payload, post_data=post_data,
                 return_cursors=return_cursors, use_cache=use_cache
             )
     finally: