Class: RubyIsds::DataMessage
- Inherits:
-
Object
- Object
- RubyIsds::DataMessage
- Defined in:
- lib/ruby_isds/data_message.rb
Constant Summary collapse
- ATTRIBUTES =
%w[dmType dmOrdinal dmID dbIDSender dmSender dmSenderAddress dmSenderType dmRecipient dmRecipientAddress dmSenderOrgUnit dmSenderOrgUnitNum dbIDRecipient dmRecipientOrgUnit dmRecipientOrgUnitNum dmToHands dmAnnotation dmRecipientRefNumber dmSenderRefNumber dmRecipientIdent dmSenderIdent dmLegalTitleLaw dmLegalTitleYear dmLegalTitleSect dmLegalTitlePar dmLegalTitlePoint dmPersonalDelivery dmAllowSubstDelivery dmMessageStatus dmAttachmentSize dmDeliveryTime dmAcceptanceTime dmHash dmQTimestamp dmAttachments dmAmbiguousRecipient].freeze
Class Method Summary collapse
Instance Method Summary collapse
- #authenticate ⇒ Object
- #author ⇒ Object
- #confirm_delivery ⇒ Object
- #delivery_info ⇒ Object
- #destroy(options = {}) ⇒ Object
- #download(destination = '/tmp') ⇒ Object
- #envelope ⇒ Object
-
#initialize(params = {}) ⇒ DataMessage
constructor
A new instance of DataMessage.
- #mark_as_downloaded ⇒ Object
- #received? ⇒ Boolean
- #sent? ⇒ Boolean
- #signed ⇒ Object
- #verify ⇒ Object
Constructor Details
#initialize(params = {}) ⇒ DataMessage
Returns a new instance of DataMessage.
27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/ruby_isds/data_message.rb', line 27 def initialize(params = {}) @params = params.dup status_info = @params.delete('dmDm') @dmAttachments = @dmEvents = load_events unified_params = status_info ? status_info.merge(@params) : params unified_params.each do |key, value| raise "Not valid attribute of DataMessage #{key}" unless ATTRIBUTES.include?(key) instance_variable_set("@#{key}", parsed_value(value)) end end |
Class Method Details
.find(dmID) ⇒ Object
16 17 18 19 |
# File 'lib/ruby_isds/data_message.rb', line 16 def self.find(dmID) RubyIsds::WebServices::DmOperations::MessageDownload .call(dmID: dmID) end |
Instance Method Details
#authenticate ⇒ Object
44 45 46 47 |
# File 'lib/ruby_isds/data_message.rb', line 44 def authenticate RubyIsds::WebServices::DmOperations::AuthenticateMessage .call(dmMessage: signed.body.dmSignature) end |
#author ⇒ Object
54 55 56 57 |
# File 'lib/ruby_isds/data_message.rb', line 54 def RubyIsds::WebServices::DmInfo::GetMessageAuthor .call(dmID: dmID) end |
#confirm_delivery ⇒ Object
69 70 71 72 |
# File 'lib/ruby_isds/data_message.rb', line 69 def confirm_delivery RubyIsds::WebServices::DmInfo::ConfirmDelivery .call(dmID: dmID) end |
#delivery_info ⇒ Object
59 60 61 62 |
# File 'lib/ruby_isds/data_message.rb', line 59 def delivery_info RubyIsds::WebServices::DmInfo::GetDeliveryInfo .call(dmID: dmID) end |
#destroy(options = {}) ⇒ Object
79 80 81 82 |
# File 'lib/ruby_isds/data_message.rb', line 79 def destroy( = {}) RubyIsds::WebServices::DmInfo::EraseMessage .call(.merge(dmID: dmID)) end |
#download(destination = '/tmp') ⇒ Object
21 22 23 24 25 |
# File 'lib/ruby_isds/data_message.rb', line 21 def download(destination = '/tmp') File.open("#{destination}/#{dmID}.zfo", 'wb') do |f| f.write(Base64.decode64(signed.body.dmSignature)) end end |
#envelope ⇒ Object
64 65 66 67 |
# File 'lib/ruby_isds/data_message.rb', line 64 def envelope RubyIsds::WebServices::DmInfo::MessageEnvelopeDownload .call(dmID: dmID) end |
#mark_as_downloaded ⇒ Object
74 75 76 77 |
# File 'lib/ruby_isds/data_message.rb', line 74 def mark_as_downloaded RubyIsds::WebServices::DmInfo::MarkMessageAsDownloaded .call(dmID: dmID) end |
#received? ⇒ Boolean
88 89 90 |
# File 'lib/ruby_isds/data_message.rb', line 88 def received? dbIDSender != ::RubyIsds.configuration.data_box end |
#sent? ⇒ Boolean
84 85 86 |
# File 'lib/ruby_isds/data_message.rb', line 84 def sent? dbIDSender == ::RubyIsds.configuration.data_box end |
#signed ⇒ Object
49 50 51 52 |
# File 'lib/ruby_isds/data_message.rb', line 49 def signed RubyIsds::WebServices::DmOperations::SignedMessageDownload .call(dmID: dmID) end |
#verify ⇒ Object
39 40 41 42 |
# File 'lib/ruby_isds/data_message.rb', line 39 def verify RubyIsds::WebServices::DmInfo::VerifyMessage .call(dmID: dmID) end |