Sha256: c2f951b5f8e6ec09ca23bba3be15b8dfc1214699b0c0d9100cfe4a8fb9ad2c02

Contents?: true

Size: 1.14 KB

Versions: 15

Compression:

Stored size: 1.14 KB

Contents

# coding: utf-8
# 客户端

module RockFintech
  class Client

    attr_accessor :config

    def initialize(options_arg)
      options = Utils.symbolize_keys(options_arg)
      @config = {
        uri: options[:url],
        rft_token: options[:rft_token],
        rft_org: options[:rft_org],
        rft_key: options[:rft_key],
        rft_secret: options[:rft_secret],
        private_key: OpenSSL::PKey::RSA.new(options[:private_key]),
        public_key: OpenSSL::PKey::RSA.new(options[:public_key]),
      }

      # 自动 include api 下的模块
      recursive_include_api('RockFintech::Api')

      # 自动 include form 下的模块
      recursive_include_api('RockFintech::Form')
    end

    def verify_data?(data)
      Sign.verify(data, @config)
    end

    private

    def recursive_include_api(module_chain)
      modules = eval("#{module_chain}.constants").each{ |constant| eval("#{module_chain}::#{constant}").class.kind_of?(Module) }

      if modules.empty?
        self.class.send(:include, eval(module_chain))
      else
        modules.each{ |constant| recursive_include_api("#{module_chain}::#{constant}") }
      end
    end

  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
rock_fintech-0.19.0 lib/rock_fintech/client.rb
rock_fintech-0.18.1 lib/rock_fintech/client.rb
rock_fintech-0.17.0 lib/rock_fintech/client.rb
rock_fintech-0.16.0 lib/rock_fintech/client.rb
rock_fintech-0.15.0 lib/rock_fintech/client.rb
rock_fintech-0.14.0 lib/rock_fintech/client.rb
rock_fintech-0.13.0 lib/rock_fintech/client.rb
rock_fintech-0.12.0 lib/rock_fintech/client.rb
rock_fintech-0.11.0 lib/rock_fintech/client.rb
rock_fintech-0.10.0 lib/rock_fintech/client.rb
rock_fintech-0.9.0 lib/rock_fintech/client.rb
rock_fintech-0.8.0 lib/rock_fintech/client.rb
rock_fintech-0.7.0 lib/rock_fintech/client.rb
rock_fintech-0.6.0 lib/rock_fintech/client.rb
rock_fintech-0.5.0 lib/rock_fintech/client.rb