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.
29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/ruby_isds/data_message.rb', line 29 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
46 47 48 49 |
# File 'lib/ruby_isds/data_message.rb', line 46 def authenticate RubyIsds::WebServices::DmOperations::AuthenticateMessage .call(dmMessage: signed.body.dmSignature) end |
#author ⇒ Object
56 57 58 59 |
# File 'lib/ruby_isds/data_message.rb', line 56 def RubyIsds::WebServices::DmInfo::GetMessageAuthor .call(dmID: dmID) end |
#confirm_delivery ⇒ Object
71 72 73 74 |
# File 'lib/ruby_isds/data_message.rb', line 71 def confirm_delivery RubyIsds::WebServices::DmInfo::ConfirmDelivery .call(dmID: dmID) end |
#delivery_info ⇒ Object
61 62 63 64 |
# File 'lib/ruby_isds/data_message.rb', line 61 def delivery_info RubyIsds::WebServices::DmInfo::GetDeliveryInfo .call(dmID: dmID) end |
#destroy(options = {}) ⇒ Object
81 82 83 84 |
# File 'lib/ruby_isds/data_message.rb', line 81 def destroy( = {}) RubyIsds::WebServices::DmInfo::EraseMessage .call(.merge(dmID: dmID)) end |
#download(destination = '/tmp') ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/ruby_isds/data_message.rb', line 21 def download(destination = '/tmp') path = "#{destination}/#{dmID}.zfo" File.open(path, 'wb') do |f| f.write(Base64.decode64(signed.body.dmSignature)) end path end |
#envelope ⇒ Object
66 67 68 69 |
# File 'lib/ruby_isds/data_message.rb', line 66 def envelope RubyIsds::WebServices::DmInfo::MessageEnvelopeDownload .call(dmID: dmID) end |
#mark_as_downloaded ⇒ Object
76 77 78 79 |
# File 'lib/ruby_isds/data_message.rb', line 76 def mark_as_downloaded RubyIsds::WebServices::DmInfo::MarkMessageAsDownloaded .call(dmID: dmID) end |
#received? ⇒ Boolean
90 91 92 |
# File 'lib/ruby_isds/data_message.rb', line 90 def received? dbIDSender != ::RubyIsds.configuration.data_box end |
#sent? ⇒ Boolean
86 87 88 |
# File 'lib/ruby_isds/data_message.rb', line 86 def sent? dbIDSender == ::RubyIsds.configuration.data_box end |
#signed ⇒ Object
51 52 53 54 |
# File 'lib/ruby_isds/data_message.rb', line 51 def signed RubyIsds::WebServices::DmOperations::SignedMessageDownload .call(dmID: dmID) end |
#verify ⇒ Object
41 42 43 44 |
# File 'lib/ruby_isds/data_message.rb', line 41 def verify RubyIsds::WebServices::DmInfo::VerifyMessage .call(dmID: dmID) end |