Class: Eet::Message
- Inherits:
-
Object
- Object
- Eet::Message
- Defined in:
- lib/eet/message.rb
Constant Summary collapse
- SOAP_ENV_SCHEMA =
'http://schemas.xmlsoap.org/soap/envelope/'
- WSSE_SCHEMA =
'http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd'
- WSU_SCHEMA =
'http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd'
- WSU_ID =
'artificial_id'
- BEZNY_REZIM =
0
- DATE_FORMAT =
'%FT%T%:z'
Instance Attribute Summary collapse
-
#bkp ⇒ Object
Returns the value of attribute bkp.
-
#celk_trzba ⇒ Object
Returns the value of attribute celk_trzba.
-
#cerp_zuct ⇒ Object
Returns the value of attribute cerp_zuct.
-
#cest_sluz ⇒ Object
Returns the value of attribute cest_sluz.
-
#dan1 ⇒ Object
Returns the value of attribute dan1.
-
#dan2 ⇒ Object
Returns the value of attribute dan2.
-
#dan3 ⇒ Object
Returns the value of attribute dan3.
- #dat_odesl ⇒ Object
-
#dat_trzby ⇒ Object
Returns the value of attribute dat_trzby.
-
#dic_popl ⇒ Object
Returns the value of attribute dic_popl.
-
#dic_poverujiciho ⇒ Object
Returns the value of attribute dic_poverujiciho.
-
#id_pokl ⇒ Object
Returns the value of attribute id_pokl.
-
#id_provoz ⇒ Object
Returns the value of attribute id_provoz.
-
#overeni ⇒ Object
Returns the value of attribute overeni.
-
#pkp ⇒ Object
Returns the value of attribute pkp.
-
#porad_cis ⇒ Object
Returns the value of attribute porad_cis.
-
#pouzit_zboz1 ⇒ Object
Returns the value of attribute pouzit_zboz1.
-
#pouzit_zboz2 ⇒ Object
Returns the value of attribute pouzit_zboz2.
-
#pouzit_zboz3 ⇒ Object
Returns the value of attribute pouzit_zboz3.
- #prvni_zaslani ⇒ Object
- #rezim ⇒ Object
-
#urceno_cerp_zuct ⇒ Object
Returns the value of attribute urceno_cerp_zuct.
- #uuid_zpravy ⇒ Object
-
#zakl_dan1 ⇒ Object
Returns the value of attribute zakl_dan1.
-
#zakl_dan2 ⇒ Object
Returns the value of attribute zakl_dan2.
-
#zakl_dan3 ⇒ Object
Returns the value of attribute zakl_dan3.
-
#zakl_nepodl_dph ⇒ Object
Returns the value of attribute zakl_nepodl_dph.
Instance Method Summary collapse
- #body ⇒ Object
- #data_attributes ⇒ Object
- #envelope ⇒ Object
- #head_attributes ⇒ Object
-
#initialize(attributes = {}) ⇒ Message
constructor
A new instance of Message.
- #to_xml ⇒ Object
Constructor Details
#initialize(attributes = {}) ⇒ Message
Returns a new instance of Message.
21 22 23 24 25 |
# File 'lib/eet/message.rb', line 21 def initialize(attributes = {}) attributes.each do |k, v| public_send("#{k}=", v) end end |
Instance Attribute Details
#bkp ⇒ Object
Returns the value of attribute bkp.
17 18 19 |
# File 'lib/eet/message.rb', line 17 def bkp @bkp end |
#celk_trzba ⇒ Object
Returns the value of attribute celk_trzba.
17 18 19 |
# File 'lib/eet/message.rb', line 17 def celk_trzba @celk_trzba end |
#cerp_zuct ⇒ Object
Returns the value of attribute cerp_zuct.
17 18 19 |
# File 'lib/eet/message.rb', line 17 def cerp_zuct @cerp_zuct end |
#cest_sluz ⇒ Object
Returns the value of attribute cest_sluz.
17 18 19 |
# File 'lib/eet/message.rb', line 17 def cest_sluz @cest_sluz end |
#dan1 ⇒ Object
Returns the value of attribute dan1.
17 18 19 |
# File 'lib/eet/message.rb', line 17 def dan1 @dan1 end |
#dan2 ⇒ Object
Returns the value of attribute dan2.
17 18 19 |
# File 'lib/eet/message.rb', line 17 def dan2 @dan2 end |
#dan3 ⇒ Object
Returns the value of attribute dan3.
17 18 19 |
# File 'lib/eet/message.rb', line 17 def dan3 @dan3 end |
#dat_odesl ⇒ Object
72 73 74 |
# File 'lib/eet/message.rb', line 72 def dat_odesl @dat_odesl ||= Time.now.strftime(DATE_FORMAT) end |
#dat_trzby ⇒ Object
Returns the value of attribute dat_trzby.
17 18 19 |
# File 'lib/eet/message.rb', line 17 def dat_trzby @dat_trzby end |
#dic_popl ⇒ Object
Returns the value of attribute dic_popl.
17 18 19 |
# File 'lib/eet/message.rb', line 17 def dic_popl @dic_popl end |
#dic_poverujiciho ⇒ Object
Returns the value of attribute dic_poverujiciho.
17 18 19 |
# File 'lib/eet/message.rb', line 17 def dic_poverujiciho @dic_poverujiciho end |
#id_pokl ⇒ Object
Returns the value of attribute id_pokl.
17 18 19 |
# File 'lib/eet/message.rb', line 17 def id_pokl @id_pokl end |
#id_provoz ⇒ Object
Returns the value of attribute id_provoz.
17 18 19 |
# File 'lib/eet/message.rb', line 17 def id_provoz @id_provoz end |
#overeni ⇒ Object
Returns the value of attribute overeni.
17 18 19 |
# File 'lib/eet/message.rb', line 17 def overeni @overeni end |
#pkp ⇒ Object
Returns the value of attribute pkp.
17 18 19 |
# File 'lib/eet/message.rb', line 17 def pkp @pkp end |
#porad_cis ⇒ Object
Returns the value of attribute porad_cis.
17 18 19 |
# File 'lib/eet/message.rb', line 17 def porad_cis @porad_cis end |
#pouzit_zboz1 ⇒ Object
Returns the value of attribute pouzit_zboz1.
17 18 19 |
# File 'lib/eet/message.rb', line 17 def pouzit_zboz1 @pouzit_zboz1 end |
#pouzit_zboz2 ⇒ Object
Returns the value of attribute pouzit_zboz2.
17 18 19 |
# File 'lib/eet/message.rb', line 17 def pouzit_zboz2 @pouzit_zboz2 end |
#pouzit_zboz3 ⇒ Object
Returns the value of attribute pouzit_zboz3.
17 18 19 |
# File 'lib/eet/message.rb', line 17 def pouzit_zboz3 @pouzit_zboz3 end |
#prvni_zaslani ⇒ Object
76 77 78 |
# File 'lib/eet/message.rb', line 76 def prvni_zaslani @prvni_zaslani.nil? ? true : @prvni_zaslani end |
#rezim ⇒ Object
80 81 82 |
# File 'lib/eet/message.rb', line 80 def rezim @rezim ||= BEZNY_REZIM end |
#urceno_cerp_zuct ⇒ Object
Returns the value of attribute urceno_cerp_zuct.
17 18 19 |
# File 'lib/eet/message.rb', line 17 def urceno_cerp_zuct @urceno_cerp_zuct end |
#uuid_zpravy ⇒ Object
68 69 70 |
# File 'lib/eet/message.rb', line 68 def uuid_zpravy @uuid_zpravy ||= SecureRandom.uuid end |
#zakl_dan1 ⇒ Object
Returns the value of attribute zakl_dan1.
17 18 19 |
# File 'lib/eet/message.rb', line 17 def zakl_dan1 @zakl_dan1 end |
#zakl_dan2 ⇒ Object
Returns the value of attribute zakl_dan2.
17 18 19 |
# File 'lib/eet/message.rb', line 17 def zakl_dan2 @zakl_dan2 end |
#zakl_dan3 ⇒ Object
Returns the value of attribute zakl_dan3.
17 18 19 |
# File 'lib/eet/message.rb', line 17 def zakl_dan3 @zakl_dan3 end |
#zakl_nepodl_dph ⇒ Object
Returns the value of attribute zakl_nepodl_dph.
17 18 19 |
# File 'lib/eet/message.rb', line 17 def zakl_nepodl_dph @zakl_nepodl_dph end |
Instance Method Details
#body ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/eet/message.rb', line 27 def body Nokogiri::XML::Builder.new('encoding' => 'UTF-8') do |xml| xml.Trzba(xmlns: 'http://fs.mfcr.cz/eet/schema/v3') do xml.Hlavicka(head_attributes) xml.Data(data_attributes) xml.KontrolniKody do xml.pkp(cipher: 'RSA2048', digest: 'SHA256', encoding: 'base64') do xml.text(pkp) end xml.bkp(digest: 'SHA1', encoding: 'base16') do xml.text(bkp) end end end end.doc end |
#data_attributes ⇒ Object
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 |
# File 'lib/eet/message.rb', line 96 def data_attributes { dic_popl: dic_popl, dic_poverujiciho: dic_poverujiciho, id_provoz: id_provoz, id_pokl: id_pokl, porad_cis: porad_cis, dat_trzby: dat_trzby, celk_trzba: celk_trzba, zakl_nepodl_dph: zakl_nepodl_dph, zakl_dan1: zakl_dan1, dan1: dan1, zakl_dan2: zakl_dan2, dan2: dan2, zakl_dan3: zakl_dan3, dan3: dan3, cest_sluz: cest_sluz, pouzit_zboz1: pouzit_zboz1, pouzit_zboz2: pouzit_zboz2, pouzit_zboz3: pouzit_zboz3, urceno_cerp_zuct: urceno_cerp_zuct, cerp_zuct: cerp_zuct, rezim: rezim, }.reject { |_, v| v.nil? } end |
#envelope ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/eet/message.rb', line 47 def envelope Nokogiri::XML::Builder.new('encoding' => 'UTF-8') do |xml| xml['soap'].Envelope('xmlns:soap' => "http://schemas.xmlsoap.org/soap/envelope/") do xml['SOAP-ENV'].Header('xmlns:SOAP-ENV' => SOAP_ENV_SCHEMA) do xml['wsse'].Security('xmlns:wsse' => WSSE_SCHEMA, 'xmlns:wsu' => WSU_SCHEMA, 'soap:mustUnderstand' => '1') end xml['soap'].Body('xmlns:wsu' => WSU_SCHEMA, 'wsu:Id' => WSU_ID) do end end end.doc end |
#head_attributes ⇒ Object
88 89 90 91 92 93 94 |
# File 'lib/eet/message.rb', line 88 def head_attributes { uuid_zpravy: uuid_zpravy, dat_odesl: dat_odesl, prvni_zaslani: prvni_zaslani, overeni: overeni }.reject { |_, v| v.nil? } end |
#to_xml ⇒ Object
60 61 62 63 64 65 66 |
# File 'lib/eet/message.rb', line 60 def to_xml msg = envelope.dup body = msg.at_xpath('//soap:Body') body.add_child(self.body.root) msg end |