Class: ClaimStatusTool::ClaimLetterDownloader
- Inherits:
-
Object
- Object
- ClaimStatusTool::ClaimLetterDownloader
- Defined in:
- lib/claim_letters/claim_letter_downloader.rb
Constant Summary collapse
- FILENAME =
'ClaimLetter'
Instance Method Summary collapse
-
#allowed_doctypes ⇒ Object
27: Board Of Appeals Decision Letter 184: Notification Letter (e.g. VA 20-8993, VA 21-0290, PCGL) 339: Rating Decision Letter.
- #get_letter(document_id) ⇒ Object
- #get_letters ⇒ Object
-
#initialize(user) ⇒ ClaimLetterDownloader
constructor
A new instance of ClaimLetterDownloader.
Constructor Details
#initialize(user) ⇒ ClaimLetterDownloader
Returns a new instance of ClaimLetterDownloader.
9 10 11 12 |
# File 'lib/claim_letters/claim_letter_downloader.rb', line 9 def initialize(user) @user = user @client = VBMS::Client.from_env_vars(env_name: Settings.vbms.env) unless Rails.env.development? || Rails.env.test? end |
Instance Method Details
#allowed_doctypes ⇒ Object
27: Board Of Appeals Decision Letter 184: Notification Letter (e.g. VA 20-8993, VA 21-0290, PCGL) 339: Rating Decision Letter
50 51 52 53 54 55 56 |
# File 'lib/claim_letters/claim_letter_downloader.rb', line 50 def allowed_doctypes if Flipper.enabled?(:cst_include_ddl_boa_letters, @user) %w[27 184] else %w[184] end end |
#get_letter(document_id) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/claim_letters/claim_letter_downloader.rb', line 29 def get_letter(document_id) letter_details = get_letter_details(document_id) raise Common::Exceptions::RecordNotFound, document_id if letter_details.nil? filename = filename_with_date(letter_details[:received_at]) if !Rails.env.development? && !Rails.env.test? && Settings.vsp_environment != 'development' req = VBMS::Requests::GetDocumentContent.new(document_id) res = @client.send_request(req) yield res.content, 'application/pdf', 'attachment', filename else File.open(ClaimLetterTestData::TEST_FILE_PATH, 'r') do |f| yield f.read, 'application/pdf', 'attachment', filename end end end |
#get_letters ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/claim_letters/claim_letter_downloader.rb', line 14 def get_letters res = nil if !Rails.env.development? && !Rails.env.test? req = VBMS::Requests::FindDocumentVersionReference.new(file_number) res = @client.send_request(req) else res = ClaimLetterTestData::TEST_DATA end format_letter_data(res) rescue VBMS::FilenumberDoesNotExist [] end |