'Turning binary into PDF in Ruby on Rails

I'm integrating with a third party ID verification provider. Once the ID verification checks have run a report is generated, which I can access with a get request.

The response is binary text (screenshot attached), which I want to save to a PDF file.

Function:

def generate_pdf
  resources = "applicants/61f84499b7b92f00014d5c6d/summary/report?report=applicantReport"
  response = RestClient.get(request_env_url(resources), signed_header(resources, nil, 'GET', 'application/pdf'))

  puts response
end

How do I take the binary response, create a new file and add the binary into that file in a friendly and readable format?

Response



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source