careerbuilder / ruby-cb-api

Ruby wrapper around the CareerBuilder.com APIs
Apache License 2.0
14 stars 18 forks source link

Find errors node when nested in response #267

Closed BradHudson closed 7 years ago

BradHudson commented 7 years ago

We found a case where the errors node is nested within the response from the User Registration API. Originally we were only looking at the first level for the errors node, but this is deeper. The solution is we look at the first level for the errors node, but then look one level deeper for it. If the response is nil, we return blank as it originally did. Also did a little boyscouting in changing the old 'fail error' to the newer 'raise error'.

Staging: Uses a pregem version of the gem along with some changes I have in a C-M branch. http://m-car-ins.cbmtn.io/user/register

Response:

{"ResponseUserCreate"=>
  {"Request"=>
    {"DeveloperKey"=>"",
     "HostSite"=>"US",
     "Test"=>"False",
     "ExternalID"=>nil,
     "Email"=>"bradley.hudson@example.com",
     "Address1"=>nil,
     "Address2"=>nil,
     "Phone"=>nil,
     "LastLoginDT"=>nil,
     "Status"=>"active",
     "UserType"=>"jobseeker",
     "Gender"=>"U",
     "BirthDate"=>nil,
     "CobrandCode"=>nil,
     "WorkStatus"=>nil,
     "Ethnicity"=>nil,
     "SendEmail"=>"True",
     "City"=>nil,
     "State"=>nil,
     "PostalCode"=>nil,
     "CountryCode"=>"US",
     "FirstName"=>"Brad",
     "LastName"=>"Hudson",
     "CreatedDT"=>nil,
     "AllowNewsletterEmails"=>"True",
     "AllowEventEmails"=>"True",
     "AllowPartnerEmails"=>"True",
     "Domain"=>nil,
     "RegistrationPath"=>"RPMTN",
     "CustomValues"=>
      {"CustomValue"=>
        [{"Key"=>"SubscribeToJobRecs", "Value"=>"true"},
         {"Key"=>"SubscribeToAVN", "Value"=>"true"},
         {"Key"=>"SubscribeToRVN", "Value"=>"true"}]}},
   "Errors"=>{"Error"=>"City requires a value"},
   "TimeResponseSent"=>"12/21/2016 9:42:47 AM",
   "TimeElapsed"=>"0.0156",
   "Status"=>"Fail",
   "ResponseExternalID"=>nil}}