Commit 4ea8a570 authored by Sergey Gernyak's avatar Sergey Gernyak

Rename GoRequester to ProxyRequester

parent 5ff3501b
......@@ -114,10 +114,10 @@ module BetfairApiNgRails
module Http
autoload :Requester, 'betfair_api_ng_rails/api/http/requester'
autoload :Responser, 'betfair_api_ng_rails/api/http/responser'
autoload :Factory, 'betfair_api_ng_rails/api/http/factory'
autoload :GoRequester, 'betfair_api_ng_rails/api/http/go_requester'
autoload :Requester, 'betfair_api_ng_rails/api/http/requester'
autoload :Responser, 'betfair_api_ng_rails/api/http/responser'
autoload :Factory, 'betfair_api_ng_rails/api/http/factory'
autoload :ProxyRequester, 'betfair_api_ng_rails/api/http/proxy_requester'
end
......
module BetfairApiNgRails
module Api
class Config
class << self
attr_accessor :application_key,
:ssl_key_filepath,
:ssl_crt_filepath,
......@@ -17,23 +15,23 @@ module BetfairApiNgRails
:keep_alive_url,
:use_cache,
:cache_expire,
:go_url,
:go_enable,
:proxy_url,
:proxy_enable,
:go_localuser,
:go_filename
def formatter=(value)
@formatter = BetfairApiNgRails::Api::FormatterFactory.initialize_formatter value
@formatter = Api::FormatterFactory.initialize_formatter value
end
def load_for_environment(file_path, env)
require 'yaml'
load_config = YAML.load_file(file_path)[env]
Api::Constants::LOADABLE_CONFIG_OPTIONS.each { |opt| self.send("#{opt}=", load_config[opt.to_s]) }
Api::Constants::LOADABLE_CONFIG_OPTIONS.each do |opt|
send("#{opt}=", load_config[opt.to_s])
end
end
end
end
end
end
\ No newline at end of file
end
......@@ -30,16 +30,15 @@ module BetfairApiNgRails
private
def create_http_requester(url = "", provider = true)
if !Api::Config.go_enable
def create_http_requester(url = '', provider = true)
if !Api::Config.proxy_enable
Api::Http::Requester.new url
else
Api::Http::GoRequester.new url, provider
Api::Http::ProxyRequester.new url, provider
end
end
end
end
end
end
end
\ No newline at end of file
end
......@@ -6,11 +6,12 @@ require 'betfair_api_ng_rails/api/helper'
module BetfairApiNgRails
module Api
module Http
class GoRequester
class ProxyRequester
include BetfairApiNgRails::Api::Helper
attr_reader :http, :request, :uri
attr_reader :app_key, :session_key, :username, :password, :body, :is_provider
attr_reader :http, :request, :uri,
:app_key, :session_key, :username,
:password, :body, :is_provider
def initialize(url, provider = true, use_ssl = true)
@is_provider = provider
......@@ -18,7 +19,7 @@ module BetfairApiNgRails
def do_request
create_http
prepare_body
prepare_form_data
Api::Http::Responser.new http.request(request)
end
......@@ -28,8 +29,8 @@ module BetfairApiNgRails
end
def set_form_data(values)
@username = values["username"]
@password = values["password"]
@username = values['username']
@password = values['password']
end
def set_request_body(body)
......@@ -40,21 +41,15 @@ module BetfairApiNgRails
set_request_body prepare_api_req_json(method, params)
end
def set_crt_file(path); end
def set_crt_file(_path); end
def set_key_file(_path); end
def set_verify_mode(_value); end
def set_ssl_files(_crt_path, _key_path, _verify = OpenSSL::SSL::VERIFY_PEER); end
def set_accept_header(_value); end
def set_request_headers(_headers); end
def set_header(_name, _value); end
def set_key_file(path); end
def set_verify_mode(value); end
def set_ssl_files(crt_path, key_path, verify = OpenSSL::SSL::VERIFY_PEER); end
def set_accept_header(value); end
def set_request_headers(headers); end
def set_header(name, value); end
private
private
def create_http
@uri = URI.parse prepare_url
......@@ -67,23 +62,22 @@ module BetfairApiNgRails
end
def prepare_auth_url
"#{Api::Config.go_url}/auth/en/#{username}/#{password}/#{app_key}/#{Api::Config.go_localuser}/#{Api::Config.go_filename}"
"#{Api::Config.proxy_url}/auth/en/#{username}/#{password}/#{app_key}/#{Api::Config.go_localuser}/#{Api::Config.go_filename}"
end
def prepare_api_url
"#{Api::Config.go_url}/api"
"#{Api::Config.proxy_url}/api"
end
def prepare_body
return if !is_provider
request.body = {
appKey: app_key,
sessionToken: session_key,
body: body
}.to_json
def prepare_form_data
return unless is_provider
request.set_form_data({
app_key: app_key,
session_token: session_key,
body: body
})
end
end
end
end
end
\ No newline at end of file
end
BetfairApiNgRails.config do |config|
BetfairApiNgRails.config do |config|
config.load_for_environment "#{Rails.root}/config/betfair_api_ng_rails.yml", Rails.env
config.ssl_key_filepath = "#{Rails.root}/public/client-2048.key"
......@@ -13,9 +12,8 @@ BetfairApiNgRails.config do |config|
config.use_cache = false
config.cache_expire = 5 # in seconds
# Go layer settings
config.go_enable = false
# Proxy layer settings
config.proxy_enable = false
# Uncomment next line if you will use go layer and go_enable is set to true
#config.go_url = "http://127.0.0.1/"
end
\ No newline at end of file
# config.proxy_url = "http://127.0.0.1/"
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment