File Response

class moco_wrapper.util.response.FileResponse(response)

Class for handling http responses where the body is just binary content representing a file

data

Returns the binary data of the response

See also

file

file

Returns the binary data of the response

m = Moco()
offer_id = 22
target_path = "./offer.pdf"

file_response = m.Offer.pdf(offer_id)
with open(target_path, "w+b") as f:
    f.write(file_response.file)

See also

data

response

http response object

write_to_file(file_path: str)

Writes the binary response content to a file

Parameters:file_path – path of the target file
m = Moco()
offer_id = 22
target_path = "./offer.pdf"

file_response = m.Offer.pdf(offer_id)
file_response.write_to_file(target_path)