2016-03-17 00:54:42 +03:00
|
|
|
# coding=utf-8
|
|
|
|
|
2018-03-20 20:32:43 +03:00
|
|
|
"""
|
|
|
|
Response class
|
|
|
|
"""
|
|
|
|
|
2016-03-17 00:54:42 +03:00
|
|
|
|
|
|
|
class Response(object):
|
|
|
|
"""
|
|
|
|
API response class
|
|
|
|
"""
|
|
|
|
|
|
|
|
def __init__(self, code, body):
|
2018-03-20 20:32:43 +03:00
|
|
|
self.__status_code = code
|
|
|
|
self.__response_body = body
|
2016-03-17 00:54:42 +03:00
|
|
|
|
|
|
|
def get_status_code(self):
|
|
|
|
"""
|
|
|
|
:return: integer
|
|
|
|
"""
|
2018-03-20 20:32:43 +03:00
|
|
|
return self.__status_code
|
2016-03-17 00:54:42 +03:00
|
|
|
|
|
|
|
def get_response(self):
|
|
|
|
"""
|
2018-03-20 20:32:43 +03:00
|
|
|
:return: string
|
2016-03-17 00:54:42 +03:00
|
|
|
"""
|
2018-03-20 20:32:43 +03:00
|
|
|
return self.__response_body
|
2016-03-17 00:54:42 +03:00
|
|
|
|
2018-03-20 20:32:43 +03:00
|
|
|
def is_successful(self):
|
2016-03-17 00:54:42 +03:00
|
|
|
"""
|
|
|
|
:return: boolean
|
|
|
|
"""
|
2018-03-20 20:32:43 +03:00
|
|
|
return int(self.__status_code) < 400
|
|
|
|
|
|
|
|
def get_error_msg(self):
|
|
|
|
"""
|
|
|
|
:return: string
|
|
|
|
"""
|
|
|
|
return self.__response_body['errorMsg']
|
|
|
|
|
|
|
|
def get_errors(self):
|
|
|
|
"""
|
|
|
|
:return: collection
|
|
|
|
"""
|
2020-01-08 18:49:10 +03:00
|
|
|
|
|
|
|
errors = self.__response_body.get('errors', {})
|
2018-03-20 20:32:43 +03:00
|
|
|
|
|
|
|
return errors
|