Sha256: 51215ae05fbb6d02ea741b16ecd71f34bcfbb6996271a3c3aeddb521409043bc
Contents?: true
Size: 1.46 KB
Versions: 1
Compression:
Stored size: 1.46 KB
Contents
require 'rest-client' require 'json' require_relative 'ebanx/version' require_relative 'ebanx/command/command' require_relative 'ebanx/command/cancel' require_relative 'ebanx/command/capture' require_relative 'ebanx/command/exchange' require_relative 'ebanx/command/print_html' require_relative 'ebanx/command/query' require_relative 'ebanx/command/refund' require_relative 'ebanx/command/refund_or_cancel' require_relative 'ebanx/command/request' module Ebanx @test_mode = false class << self attr_accessor :integration_key, :test_mode end def self.base_uri if @test_mode 'https://www.ebanx.com/test/ws/' else 'https://www.ebanx.com/pay/ws/' end end def self.run_command(method, params) klass = get_command_class method params = params[0].merge! integration_key: @integration_key command = klass.new params command.valid? request command end def self.request(command) uri = Ebanx::base_uri + command.request_action result = RestClient.send command.request_method, uri, params: command.params, content_type: command.response_type JSON.parse result end def self.method_missing(method, *args, &block) if method.to_s =~ /^do_[a-z]+/ run_command method.to_s, args else super end end def self.get_command_class(method) method = method.gsub /^do_/, '' class_name = 'Ebanx::Command::' + method.split('_').map { |w| w.capitalize }.join Object.const_get class_name end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ebanx-0.1.0 | lib/ebanx.rb |