Class: Bankserv::ReplyDocument

Inherits:
Document
  • Object
show all
Defined in:
lib/bankserv/transmission/reply_document.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Document

#input?, #mark_processed!, #output?, #records, #reply?, #set_with_dept_code, #set_with_generation_number, #sets, #to_hash

Class Method Details

.document_typeObject



10
11
12
# File 'lib/bankserv/transmission/reply_document.rb', line 10

def self.document_type
  'reply'
end

.store(string) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/bankserv/transmission/reply_document.rb', line 14

def self.store(string)
  options = Absa::H2h::Transmission::Document.hash_from_s(string, 'output')
  
  raise "Expected a document set" unless options[:type] == "document"
  
  document = Bankserv::ReplyDocument.new(type: 'output')
 
  document.set = Bankserv::Set.from_hash(options)
  document.set.document = document # whaaaaaa?
  document.save!
  document
end

Instance Method Details

#process!Object



27
28
29
30
31
32
33
# File 'lib/bankserv/transmission/reply_document.rb', line 27

def process!
  raise "Document already processed" if processed?

  self.set.process
  self.processed = true
  self.save
end

#set_user_ref!Object



5
6
7
8
# File 'lib/bankserv/transmission/reply_document.rb', line 5

def set_user_ref!
  self.user_ref = self.set.header.data[:th_for_use_of_ld_user]
  self.save!
end