Class: RealEx::Client
- Inherits:
-
Object
- Object
- RealEx::Client
- Defined in:
- lib/real_ex/client.rb
Class Method Summary collapse
- .build_hash(hash_string_items) ⇒ Object
- .build_xml(type, &block) ⇒ Object
- .call(url, xml) ⇒ Object
- .parse(response) ⇒ Object
- .timestamp ⇒ Object
Class Method Details
.build_hash(hash_string_items) ⇒ Object
9 10 11 12 |
# File 'lib/real_ex/client.rb', line 9 def build_hash(hash_string_items) first_hash = Digest::SHA1.hexdigest(hash_string_items.join('.')) Digest::SHA1.hexdigest("#{first_hash}.#{RealEx::Config.shared_secret}") end |
.build_xml(type, &block) ⇒ Object
14 15 16 17 18 19 |
# File 'lib/real_ex/client.rb', line 14 def build_xml(type, &block) xml = Builder::XmlMarkup.new(:indent => 2) xml.instruct! xml.request(:type => type, :timestamp => ) { |r| block.call(r) } xml.target! end |
.call(url, xml) ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/real_ex/client.rb', line 21 def call(url,xml) h = Net::HTTP.new('epage.payandshop.com', 443) h.use_ssl = true response = h.request_post(url, xml) result = Nokogiri.XML(response.body) result end |
.parse(response) ⇒ Object
29 30 31 32 |
# File 'lib/real_ex/client.rb', line 29 def parse(response) status = (response/:result).inner_html raise RealExError, "#{(response/:message).inner_html} (#{status})" unless status == "00" end |
.timestamp ⇒ Object
5 6 7 |
# File 'lib/real_ex/client.rb', line 5 def Time.now.strftime('%Y%m%d%H%M%S') end |