Skip to content

Commit

Permalink
code formatting changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Hunter Kuffel committed Nov 2, 2022
1 parent d909b4e commit 636b7f1
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 29 deletions.
7 changes: 2 additions & 5 deletions tap_instagram/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,8 @@ def parse_response(self, response: requests.Response) -> Iterable[dict]:
yield from extract_jsonpath(self.records_jsonpath, input=response.json())

def validate_response(self, response: requests.Response) -> None:
if (
response.status_code == 400
and 'Unsupported get request' in str(
response.json().get("error", {}).get("message")
)
if response.status_code == 400 and "Unsupported get request" in str(
response.json().get("error", {}).get("message")
):
msg = (
f"{response.status_code} Client Error: "
Expand Down
40 changes: 16 additions & 24 deletions tap_instagram/streams.py
Original file line number Diff line number Diff line change
Expand Up @@ -504,12 +504,10 @@ def get_url_params(
return params

def validate_response(self, response: requests.Response) -> None:
if (
response.json().get("error", {}).get("error_user_title")
== "Media posted before business account conversion"
or
"(#10) Not enough viewers for the media to show insights"
in str(response.json().get("error", {}).get("message"))
if response.json().get("error", {}).get(
"error_user_title"
) == "Media posted before business account conversion" or "(#10) Not enough viewers for the media to show insights" in str(
response.json().get("error", {}).get("message")
):
self.logger.warning(f"Skipping: {response.json()['error']}")
return
Expand All @@ -519,12 +517,10 @@ def parse_response(self, response: requests.Response) -> Iterable[dict]:
resp_json = response.json()
# Handle the specific case where FB returns error because media was posted before business acct creation
# TODO: Refactor to raise a specific error in validate_response and handle that instead
if (
resp_json.get("error", {}).get("error_user_title")
== "Media posted before business account conversion"
or
"(#10) Not enough viewers for the media to show insights"
in str(resp_json.get("error", {}).get("message"))
if resp_json.get("error", {}).get(
"error_user_title"
) == "Media posted before business account conversion" or "(#10) Not enough viewers for the media to show insights" in str(
resp_json.get("error", {}).get("message")
):
return
for row in resp_json["data"]:
Expand Down Expand Up @@ -674,12 +670,10 @@ def get_url_params(
return params

def validate_response(self, response: requests.Response) -> None:
if (
response.json().get("error", {}).get("error_user_title")
== "Media posted before business account conversion"
or
"(#10) Not enough viewers for the media to show insights"
in str(response.json().get("error", {}).get("message"))
if response.json().get("error", {}).get(
"error_user_title"
) == "Media posted before business account conversion" or "(#10) Not enough viewers for the media to show insights" in str(
response.json().get("error", {}).get("message")
):
self.logger.warning(f"Skipping: {response.json()['error']}")
return
Expand All @@ -689,12 +683,10 @@ def parse_response(self, response: requests.Response) -> Iterable[dict]:
resp_json = response.json()
# Handle the specific case where FB returns error because media was posted before business acct creation
# TODO: Refactor to raise a specific error in validate_response and handle that instead
if (
resp_json.get("error", {}).get("error_user_title")
== "Media posted before business account conversion"
or
"(#10) Not enough viewers for the media to show insights"
in str(resp_json.get("error", {}).get("message"))
if resp_json.get("error", {}).get(
"error_user_title"
) == "Media posted before business account conversion" or "(#10) Not enough viewers for the media to show insights" in str(
resp_json.get("error", {}).get("message")
):
return
for row in resp_json["data"]:
Expand Down

0 comments on commit 636b7f1

Please sign in to comment.