Class: XRBP::Model::Parsers::Gateway

Inherits:
PluginBase show all
Defined in:
lib/xrbp/model/parsers/gateway.rb

Overview

Gateway list data parser

Instance Attribute Summary

Attributes inherited from PluginBase

#connection

Instance Method Summary collapse

Methods inherited from PluginBase

#initialize

Constructor Details

This class inherits a constructor from XRBP::PluginBase

Instance Method Details

#parse_result(res, req) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/xrbp/model/parsers/gateway.rb', line 13

def parse_result(res, req)
  gateways = []

  j = JSON.parse(res)
  j.each_key { |currency|
    j[currency].each { |currency_gateway|
      id   = currency_gateway["account"]
      name = currency_gateway["name"]
      gateway = gateways.find { |gw| gw[:id] == id }
      if gateway
        gateway[:currencies] << "#{currency}"
        gateway[:names]      << "#{name}" unless gateway[:names].include?(name)

      else
        gateways << {:id          => id,
                     :names       => [name],
                     :currencies  => [currency],
                     :start_date  => currency_gateway["start_date"]}
      end
    }
  }

  gateways
end

#parser_priorityObject



9
10
11
# File 'lib/xrbp/model/parsers/gateway.rb', line 9

def parser_priority
  0
end