Class: Resources::AvailableFile

Inherits:
BaseResource show all
Includes:
ConfiguredAccountPrompter, ServiceDefinitionPrompter, ThirdPartyPrompter
Defined in:
lib/pvdgm-svc-client/resources/available_file.rb

Instance Attribute Summary

Attributes inherited from BaseResource

#options, #prompter

Instance Method Summary collapse

Methods included from ConfiguredAccountPrompter

#configured_account_id

Methods included from ServiceDefinitionPrompter

#service_definition_id

Methods included from ThirdPartyPrompter

#third_party_id

Methods inherited from BaseResource

#initialize

Constructor Details

This class inherits a constructor from BaseResource

Instance Method Details

#listObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/pvdgm-svc-client/resources/available_file.rb', line 8

def list
  tp_id = third_party_id
  sd_id = service_definition_id
  ca_id = 

  puts
  status = prompter.choose do | menu |
    menu.prompt = "Select the status to filter with: "
    
    menu.choice('All', 'Specify no status') { -1 }
    menu.choice('Available', 'All files that are ready to be pulled from the source') { 0 }
    menu.choice('Downloaded', 'All files that have been downloaded from the source') { 1 }
    menu.choice('Invalid', 'All files that have been marked as invalid') { 2 }
    menu.choice('Missing', 'All files that could not be found on the file system') { 3 }
    menu.choice('Uploaded', 'All files that have been uploaded to abaqis') { 4 }
    menu.choice('Upload Error', 'All files that had an error uploading to abaqis') { 5 }
    menu.choice('Deleted', 'All files that have been deleted from the file system') { 6 }
    menu.choice('Cleared', 'All files that have been cleared from the source') { 7 }
    menu.choice('Not Cleared', 'All files that have not been cleared') { 0x17 }
  end
  filter = status >= 0 ? "?status=#{status}" : ''
  result = get("services/third_parties/#{tp_id}/service_definitions/#{sd_id}/configured_accounts/#{ca_id}/available_files#{filter}")

  puts "\nAvailable files for third party: #{tp_id}, service definition: #{sd_id}"
  table = Terminal::Table.new headings: [ 'Request ID', 'File Name', 'Status', 'Downloaded At', 'CMP File Name', 'Error' ] do |t|
    result.each do | available_file |
      t << [ available_file['request_id'],
             available_file['filename'],
             available_file['status'],
             available_file['downloaded_at'],
             available_file['composite_file_name'],
             available_file['error'],
             available_file['created_at'],
             available_file['updated_at'] ]
    end
  end
  prompter.say table.to_s
  puts
end