From 84a86bd7bdb2e654295d191e74f49e333d2f3423 Mon Sep 17 00:00:00 2001 From: Mads Marquart Date: Thu, 25 Jul 2019 23:37:46 +0200 Subject: [PATCH] Move body of Client._payload_post to State --- fbchat/_client.py | 6 +----- fbchat/_state.py | 7 +++++++ 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/fbchat/_client.py b/fbchat/_client.py index b431aee..4f0f879 100644 --- a/fbchat/_client.py +++ b/fbchat/_client.py @@ -115,11 +115,7 @@ class Client(object): return self._state._post(url, params, files=files, as_graphql=as_graphql) def _payload_post(self, url, data, files=None): - j = self._post(url, data, files=files) - try: - return j["payload"] - except (KeyError, TypeError): - raise FBchatException("Missing payload: {}".format(j)) + return self._state._payload_post(url, data, files=files) def graphql_requests(self, *queries): """Execute GraphQL queries. diff --git a/fbchat/_state.py b/fbchat/_state.py index 56c7253..c22b826 100644 --- a/fbchat/_state.py +++ b/fbchat/_state.py @@ -240,3 +240,10 @@ class State(object): error_retries=error_retries - 1, ) raise + + def _payload_post(self, url, data, files=None): + j = self._post(url, data, files=files) + try: + return j["payload"] + except (KeyError, TypeError): + raise _exception.FBchatException("Missing payload: {}".format(j))