Sha256: 02f102977e46a9f8008dfec52faad121cb950696af17e133b3a24e864072bd92

Contents?: true

Size: 889 Bytes

Versions: 24

Compression:

Stored size: 889 Bytes

Contents

module Eligible
  class ReceivedPdf < APIResource
    def self.received_pdf_url(params)
      enrollment_npi_id = Util.value(params, :enrollment_npi_id)
      "/enrollment_npis/#{enrollment_npi_id}/received_pdf"
    end

    def self.get(params, api_key = nil)
      send_request(:get, received_pdf_url(params), api_key, params, :enrollment_npi_id)
    end

    def self.download(params, api_key = nil)
      enrollment_npi_id = Util.value(params, :enrollment_npi_id)
      require_param(enrollment_npi_id, 'Enrollment Npi id')
      params[:format] = 'x12'
      response = Eligible.request(:get, "/enrollment_npis/#{params[:enrollment_npi_id]}/received_pdf/download", api_key, params)[0]
      filename = params[:filename] || '/tmp/received_pdf.pdf'
      file = File.new(filename, 'w')
      file.write response
      file.close
      "PDF file stored at #{filename}"
    end
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
eligible-2.7.0 lib/eligible/received_pdf.rb
eligible-2.6.3 lib/eligible/received_pdf.rb
eligible-2.6.2 lib/eligible/received_pdf.rb
eligible-2.6.1 lib/eligible/received_pdf.rb