Sha256: 3958d9ef3bae2ae7f309208e5d78fe1a3528d82986b7ed92563fbb483e44b35f

Contents?: true

Size: 1.69 KB

Versions: 27

Compression:

Stored size: 1.69 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, opts = {})
      send_request :get, original_signature_pdf_url(params), params, opts.merge(required_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, opts = {})
      setup_file(params)
      send_request :post, original_signature_pdf_url(params), params, opts.merge(required_params: [:enrollment_npi_id])
    end

    def self.update(params, opts = {})
      setup_file(params)
      send_request :put, original_signature_pdf_url(params), params, opts.merge(required_params: [:enrollment_npi_id])
    end

    def self.delete(params, opts = {})
      send_request :delete, original_signature_pdf_url(params), params, opts.merge(required_params: [:enrollment_npi_id])
    end

    def self.download(params, opts = {})
      enrollment_npi_id = Util.value(params, :enrollment_npi_id)
      require_param(enrollment_npi_id, 'Enrollment Npi id')
      params[:format] = 'x12'
      headers = opts.clone
      api_key = headers.delete(:api_key)
      response = Eligible.request(:get, "/enrollment_npis/#{enrollment_npi_id}/original_signature_pdf/download", api_key, params, headers)[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

27 entries across 27 versions & 1 rubygems

Version Path
eligible-3.0.0.beta28 lib/eligible/original_signature_pdf.rb
eligible-3.0.0.beta27 lib/eligible/original_signature_pdf.rb
eligible-3.0.0.beta26 lib/eligible/original_signature_pdf.rb
eligible-3.0.0.beta25 lib/eligible/original_signature_pdf.rb
eligible-3.0.0.beta24 lib/eligible/original_signature_pdf.rb
eligible-3.0.0.beta23 lib/eligible/original_signature_pdf.rb
eligible-3.0.0.beta22 lib/eligible/original_signature_pdf.rb
eligible-3.0.0.beta20 lib/eligible/original_signature_pdf.rb
eligible-3.0.0.beta19 lib/eligible/original_signature_pdf.rb
eligible-3.0.0.beta18 lib/eligible/original_signature_pdf.rb
eligible-3.0.0.beta17 lib/eligible/original_signature_pdf.rb
eligible-3.0.0.beta16 lib/eligible/original_signature_pdf.rb
eligible-3.0.0.beta15 lib/eligible/original_signature_pdf.rb
eligible-3.0.0.beta14 lib/eligible/original_signature_pdf.rb
eligible-3.0.0.beta13 lib/eligible/original_signature_pdf.rb
eligible-3.0.0.beta12 lib/eligible/original_signature_pdf.rb
eligible-3.0.0.beta11 lib/eligible/original_signature_pdf.rb
eligible-3.0.0.beta10 lib/eligible/original_signature_pdf.rb
eligible-3.0.0.beta9 lib/eligible/original_signature_pdf.rb
eligible-3.0.0.beta8 lib/eligible/original_signature_pdf.rb