Sha256: c88794addd3e65bcd101fb4cafa07f70d6238861048030158851e216033a19ca
Contents?: true
Size: 1.15 KB
Versions: 1
Compression:
Stored size: 1.15 KB
Contents
module MelissaData module WebSmart module ResponseProcessor def process_property(response) codes = codes(response) if has_error_codes?(codes) { errors: codes_for(codes, 'error') } else response.merge!(success: codes_for(codes, 'success')) end end def codes_for(codes, type) codes.map { |c| method("property_#{type}_codes").call[c.to_sym] }.compact end def codes(response) codes = response[:result][:code].split(",") end def has_error_codes? codes error_codes?(codes) ? false : true end def error_codes?(codes) codes.map { |c| c if property_error_codes.keys.include? c }.compact.empty? end def property_success_codes { YS01: "FIPS/APN Match found", YS02: "AddressKey Match found", YS03: "Basic information returned", YS04: "Detailed information returned" } end def property_error_codes { YE01: "No FIPS/APN or AddressKey provided", YE02: "No match found", YE03: "Invalid FIPS/APN or AddressKey provided" } end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
melissa_data-0.2.3 | lib/melissa_data/web_smart/response_processor.rb |