Conversation
| return response_body | ||
| else: | ||
| return response_body | ||
| return response.text |
There was a problem hiding this comment.
Since PDFs will be returned as bytes, I wonder if we should return response.content rather than response.text; thoughts?
| if response_body.get('error_type'): | ||
| raise PlaidError.from_response(response_body) | ||
|
|
||
| if is_json: |
There was a problem hiding this comment.
In the case that is_json=False but the endpoint returns an error, we're not going to enter this clause (and will end up returning the error as text). What do you think of making this check something like if is_json or response.headers['Content-Type']='application.json'?
|
@joyzheng, I ended up removing the |
Agree that the code is neater without Maybe the solution here is to explicitly expect a content type in all cases then? (either json or pdf) and throw the error if that's not met. |
| return response_body | ||
| else: | ||
| return response_body | ||
| return response.text |
| if response_body.get('error_type'): | ||
| raise PlaidError.from_response(response_body) | ||
|
|
||
| if is_json and response.headers['Content-Type'] == 'application/json': |
There was a problem hiding this comment.
@joyzheng, is this an OK compromise? I don't want to break any existing behavior, and I'm not sure if clients are using client.post anywhere.
There was a problem hiding this comment.
Yeah, this looks good -- should be an or rather than an and here, though
No description provided.