Sha256: 3994a8f3442406d1df9da6b535ea38ea958a301fe2eebb686b57edaf4bc7ed1d

Contents?: true

Size: 1.55 KB

Versions: 3

Compression:

Stored size: 1.55 KB

Contents

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

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

    def self.setup_file(params)
      file = Util.value(params, :file)
      params[:file] = File.new(file, 'rb') if file.is_a?(String)
    end

    def self.post(params, api_key = nil)
      setup_file(params)
      send_request(:post, original_signature_pdf_url(params), api_key, params, :enrollment_npi_id)
    end

    def self.update(params, api_key = nil)
      setup_file(params)
      send_request(:put, original_signature_pdf_url(params), api_key, params, :enrollment_npi_id)
    end

    def self.delete(params, api_key = nil)
      send_request(:delete, original_signature_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/#{enrollment_npi_id}/original_signature_pdf/download", api_key, **params)[0]
      filename = params[:filename] || '/tmp/original_signature_pdf.pdf'
      file = File.new(filename, 'w')
      file.write response
      file.close
      "PDF file stored at #{filename}"
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
eligible-3.0.2 lib/eligible/original_signature_pdf.rb
eligible-3.0.1 lib/eligible/original_signature_pdf.rb
eligible-3.0.0 lib/eligible/original_signature_pdf.rb