#NEWLINE# def convert_to_easypost_object( response , api_key , parent = None , name = None ) : #NEWLINE# #INDENT# types = { #NEWLINE# #INDENT# 'Address' : Address , #NEWLINE# 'ScanForm' : ScanForm , #NEWLINE# 'CustomsItem' : CustomsItem , #NEWLINE# 'CustomsInfo' : CustomsInfo , #NEWLINE# 'Parcel' : Parcel , #NEWLINE# 'Shipment' : Shipment , #NEWLINE# 'Rate' : Rate , #NEWLINE# 'Refund' : Refund , #NEWLINE# 'Batch' : Batch , #NEWLINE# 'Event' : Event , #NEWLINE# 'Tracker' : Tracker , #NEWLINE# 'Pickup' : Pickup , #NEWLINE# 'Order' : Order , #NEWLINE# 'PickupRate' : PickupRate , #NEWLINE# 'PostageLabel' : PostageLabel , #NEWLINE# 'CarrierAccount' : CarrierAccount , #NEWLINE# 'User' : User , #NEWLINE# #UNINDENT# } #NEWLINE# prefixes = { #NEWLINE# #INDENT# 'adr' : Address , #NEWLINE# 'sf' : ScanForm , #NEWLINE# 'evt' : Event , #NEWLINE# 'cstitem' : CustomsItem , #NEWLINE# 'cstinfo' : CustomsInfo , #NEWLINE# 'prcl' : Parcel , #NEWLINE# 'shp' : Shipment , #NEWLINE# 'rate' : Rate , #NEWLINE# 'rfnd' : Refund , #NEWLINE# 'batch' : Batch , #NEWLINE# 'trk' : Tracker , #NEWLINE# 'order' : Order , #NEWLINE# 'pickup' : Pickup , #NEWLINE# 'pickuprate' : PickupRate , #NEWLINE# 'pl' : PostageLabel , #NEWLINE# 'ca' : CarrierAccount , #NEWLINE# 'user' : User , #NEWLINE# #UNINDENT# } #NEWLINE# if isinstance ( response , list ) : #NEWLINE# #INDENT# return [ convert_to_easypost_object ( r , api_key , parent ) for r in response ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if isinstance ( response , dict ) : #NEWLINE# #INDENT# response = response . copy ( ) #NEWLINE# cls_name = response . get ( 'object' , EasyPostObject ) #NEWLINE# cls_id = response . get ( 'id' , None ) #NEWLINE# if isinstance ( cls_name , six . string_types ) : #NEWLINE# #INDENT# cls = types . get ( cls_name , EasyPostObject ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( cls_id is not None ) : #NEWLINE# #INDENT# cls = prefixes . get ( cls_id [ 0 : cls_id . find ( '_' ) ] , EasyPostObject ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# cls = EasyPostObject #NEWLINE# #UNINDENT# #UNINDENT# return cls . construct_from ( response , api_key , parent , name ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# return response