Class: Epics::GenericRequest

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/epics/generic_request.rb

Direct Known Subclasses

C52, C53, GenericUploadRequest, HAA, HAC, HIA, HKD, HPB, HPD, HTD, INI, PTK, STA

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ GenericRequest

Returns a new instance of GenericRequest.



6
7
8
# File 'lib/epics/generic_request.rb', line 6

def initialize(client)
  self.client = client
end

Instance Attribute Details

#clientObject

Returns the value of attribute client.



3
4
5
# File 'lib/epics/generic_request.rb', line 3

def client
  @client
end

#transaction_idObject

Returns the value of attribute transaction_id.



4
5
6
# File 'lib/epics/generic_request.rb', line 4

def transaction_id
  @transaction_id
end

Instance Method Details

#auth_signatureObject



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/epics/generic_request.rb', line 28

def auth_signature
  {
    "ds:SignedInfo" => {
      "ds:CanonicalizationMethod/" => {
        :@Algorithm => "http://www.w3.org/TR/2001/REC-xml-c14n-20010315"
      },
      "ds:SignatureMethod/" => {
        :@Algorithm => "http://www.w3.org/2001/04/xmldsig-more#rsa-sha256"
      },
      "ds:Reference/" => {
        :@URI => "#xpointer(//*[@authenticate='true'])",
        "ds:Transforms" => {
          "ds:Transform/" => {
            :@Algorithm => "http://www.w3.org/TR/2001/REC-xml-c14n-20010315"
          }
        },
        "ds:DigestMethod/" => {
          :@Algorithm => "http://www.w3.org/2001/04/xmlenc#sha256"
        },
        "ds:DigestValue/" => ""
      }
    },
    "ds:SignatureValue/" => ""
  }
end

#bodyObject



24
25
26
# File 'lib/epics/generic_request.rb', line 24

def body
  ""
end

#nonceObject



10
11
12
# File 'lib/epics/generic_request.rb', line 10

def nonce
  SecureRandom.hex(16)
end

#rootObject



20
21
22
# File 'lib/epics/generic_request.rb', line 20

def root
  "ebicsRequest"
end

#timestampObject



14
15
16
# File 'lib/epics/generic_request.rb', line 14

def timestamp
  Time.now.utc.iso8601
end

#to_receipt_xmlObject



85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
# File 'lib/epics/generic_request.rb', line 85

def to_receipt_xml
  Nokogiri::XML.parse(Gyoku.xml({
    root => {
      :"@xmlns:ds" => "http://www.w3.org/2000/09/xmldsig#",
      :@xmlns => "urn:org:ebics:H004",
      :@Version => "H004",
      :@Revision => "1",
      "header" => {
        :@authenticate => true,
        "static" => {
          "HostID" => host_id,
          "TransactionID" => transaction_id
        },
        "mutable" => {
          "TransactionPhase" => "Receipt"
        }
      },
      "AuthSignature" => auth_signature,
      "body" => {
        "TransferReceipt" => {
          :@authenticate => true,
          "ReceiptCode" => 0
        }
      }
    }
  }), nil, "utf-8").to_xml(save_with: Nokogiri::XML::Node::SaveOptions::AS_XML)
end

#to_transfer_xmlObject



54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/epics/generic_request.rb', line 54

def to_transfer_xml
  Nokogiri::XML.parse(Gyoku.xml({
    root => {
      :"@xmlns:ds" => "http://www.w3.org/2000/09/xmldsig#",
      :@xmlns => "urn:org:ebics:H004",
      :@Version => "H004",
      :@Revision => "1",
      "header" => {
        :@authenticate => true,
        "static" => {
          "HostID" => host_id,
          "TransactionID" => transaction_id
        },
        "mutable" => {
          "TransactionPhase" => "Transfer",
          "SegmentNumber" => {
            :@lastSegment => true,
            :content! => 1
          }
        }
      },
      "AuthSignature" => auth_signature,
      "body" => {
        "DataTransfer" => {
          "OrderData" => encrypted_order_data
        }
      }
    }
  }), nil, "utf-8").to_xml(save_with: Nokogiri::XML::Node::SaveOptions::AS_XML)
end

#to_xmlObject



113
114
115
116
117
118
119
120
121
122
123
124
125
# File 'lib/epics/generic_request.rb', line 113

def to_xml
  Nokogiri::XML.parse(Gyoku.xml(    {
    root => {
      :"@xmlns:ds" => "http://www.w3.org/2000/09/xmldsig#",
      :@xmlns => "urn:org:ebics:H004",
      :@Version => "H004",
      :@Revision => "1",
      :header => header,
      "AuthSignature" => auth_signature,
      "body" => body
    }
  }), nil, "utf-8").to_xml(save_with: Nokogiri::XML::Node::SaveOptions::AS_XML)
end