| Total Complexity | 7 |
| Total Lines | 34 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | |||
| 2 | class NextCloudResponse(object): |
||
| 3 | |||
| 4 | def __init__(self, response, json_output=True, data=None): |
||
| 5 | self.raw = response |
||
| 6 | if not data: |
||
| 7 | self.data = response.json() if json_output else response.content.decode("UTF-8") |
||
| 8 | else: |
||
| 9 | self.data = data |
||
| 10 | |||
| 11 | |||
| 12 | class WebDAVResponse(NextCloudResponse): |
||
| 13 | """ Response class for WebDAV api methods """ |
||
| 14 | |||
| 15 | def __init__(self, response, data=None): |
||
| 16 | super(WebDAVResponse, self).__init__(response=response, data=data, json_output=False) |
||
| 17 | |||
| 18 | |||
| 19 | class OCSResponse(NextCloudResponse): |
||
| 20 | """ Response class for OCS api methods """ |
||
| 21 | |||
| 22 | def __init__(self, response, json_output=True, data=None): |
||
| 23 | self.raw = response |
||
| 24 | if json_output: |
||
| 25 | self.full_data = response.json() |
||
| 26 | self.meta = self.full_data['ocs']['meta'] |
||
| 27 | self.status_code = self.full_data['ocs']['meta']['statuscode'] |
||
| 28 | self.data = self.full_data['ocs']['data'] |
||
| 29 | else: |
||
| 30 | self.data = response.content.decode("UTF-8") |
||
| 31 | |||
| 32 | def __repr__(self): |
||
| 33 | return "<OCSResponse: ocs_status_code={}>".format(getattr(self, 'status_code', None)) |
||
| 34 |