@@ -56,7 +56,11 @@ def __init__(self, dictionary=dict()):
5656 setattr (self , k , udict .get (k ,self .defaults .get (k )))
5757
5858 def to_json_object (self ):
59- return ApiOject .transform_dict_to_camelcase (self .__dict__ )
59+ dictionary = {}
60+ for attribute in self .__slots__ :
61+ if hasattr (self ,attribute ):
62+ dictionary [attribute ] = getattr (self ,attribute )
63+ return ApiOject .transform_dict_to_camelcase (dictionary )
6064
6165 @staticmethod
6266 def _to_camelcase (word ):
@@ -71,13 +75,13 @@ def _to_underscore(word):
7175 def transform_dict_to_camelcase (dictionary ):
7276 if dictionary is None :
7377 return dict ()
74- return dict ((ApiOject ._to_camelcase (k ), v ) for k , v in dictionary .iteritems () if v is not None )
78+ return dict ((ApiOject ._to_camelcase (k ), v ) for k , v in dictionary .items () if v is not None )
7579
7680 @staticmethod
7781 def transform_dict_to_underscore (dictionary ):
7882 if dictionary is None :
7983 return dict ()
80- return dict ((ApiOject ._to_underscore (k ), v ) for k , v in dictionary .iteritems () if v is not None )
84+ return dict ((ApiOject ._to_underscore (k ), v ) for k , v in dictionary .items () if v is not None )
8185
8286 @classmethod
8387 def list_to_object_list (cls , o ):
@@ -171,8 +175,9 @@ def _http(self, url, method, data=None, decoder=None):
171175 if self .token is not None :
172176 req .add_header ('Authorization' , 'Bearer {0}' .format (self .token ))
173177 elif self .username is not None :
178+ b64 = base64 .b64encode (bytes (self .username + ':' + self .password , encoding = 'utf-8' ))
174179 req .add_header ('Authorization' ,
175- 'Basic {0}' .format (base64 . b64encode ( self . username + b':' + self . password ) ))
180+ 'Basic {0}' .format (b64 ))
176181
177182 if not isinstance (data , str ):
178183 data = json .dumps (data , indent = 2 )
0 commit comments