This are my mappers:
I've changed the initalize if the input is nil would build and empty skeleton.
class MobileConfigMapper < HashMap::Base
transforms_output HashMap::UnderscoreKeys
def initialize(hash)
input = hash || {}
super(input)
end
properties 'EnableBookingAir',
'EnableChangeAir',
'EnableCancelAir',
'EnableBookingHotel',
'EnableChangeHotel',
'EnableCancelHotel',
'EnableBookingCar',
'EnableChangeCar',
'EnableCancelCar',
'EnableCertify',
'EnableLyft',
'EnableGoogleFlights',
'EnableHilton',
'EnableProfileAccess',
'EnableSecureLocateMe',
'EnableEULA'
end
class CompanySettingsMapper < HashMap::Base
transforms_output HashMap::UnderscoreKeys
from_child 'CompanySettings' do
from_child 'CompanyIdentity' do
property 'CompanyGuid'
end
properties 'IsCertifyEnabled', 'IsProfileEnabled'
property 'PathMobileConfig', mapper: MobileConfigMapper
end
end
hash:
{
"StatusCode": 200,
"ErrorDescription": null,
"Messages": null,
"CompanySettings": {
"CompanyIdentity": {
"CompanyGuid": "0A6005FA-161D-4290-BB7D-B21B14313807",
"PseudoCity": {
"Code": "PARTQ2447"
}
},
"IsCertifyEnabled": false,
"IsProfileEnabled": true,
"PathMobileConfig": null
}
}
I expect PathMobileConfig or it's transformation path_mobile_config to be {} but it always returns `nil``
For now I will use the block turnaround:
property 'PathMobileConfig' do |settings|
if hash = settings['PathMobileConfig']
MobileConfigMapper.call(hash)
else
{}
end
end
This are my mappers:
I've changed the initalize if the input is
nilwould build and empty skeleton.hash:
I expect
PathMobileConfigor it's transformationpath_mobile_configto be{}but it always returns `nil``For now I will use the
blockturnaround: