Commit 236ebd00 authored by Sergey Gernyak's avatar Sergey Gernyak

Temp

parent b5347a80
...@@ -4,7 +4,7 @@ module BetfairApiNgRails ...@@ -4,7 +4,7 @@ module BetfairApiNgRails
module Api module Api
class Connection class Connection
def request(method, params = {}) def request(method, params = {})
provider.fetch method: Api::RequestMethod.new(method), params: hashing(params) provider.fetch method: method, params: hashing(params)
end end
include Api::ConnectionExt::Caching include Api::ConnectionExt::Caching
......
...@@ -18,7 +18,7 @@ module BetfairApiNgRails ...@@ -18,7 +18,7 @@ module BetfairApiNgRails
def prepare_api_req_json(method, params) def prepare_api_req_json(method, params)
{ {
"jsonrpc" => "2.0", "jsonrpc" => "2.0",
"method" => "#{method.json_method}/v1.0/#{method.name}", "method" => "SportsAPING/v1.0/#{method}",
"params" => params "params" => params
}.to_json }.to_json
end end
......
...@@ -5,11 +5,11 @@ module BetfairApiNgRails ...@@ -5,11 +5,11 @@ module BetfairApiNgRails
class << self class << self
include Api::Constants include Api::Constants
def provider_requester(api_url, ssoid = nil) def provider_requester(ssoid = nil)
req = create_http_requester(api_url) create_http_requester(API_URL[:betting]).tap do |req|
req.set_request_headers API_REQUEST_HEADERS req.set_request_headers API_REQUEST_HEADERS
req.set_auth_headers Api::Config.application_key, ssoid req.set_auth_headers Api::Config.application_key, ssoid
req end
end end
def session_requester def session_requester
......
...@@ -14,20 +14,19 @@ module BetfairApiNgRails ...@@ -14,20 +14,19 @@ module BetfairApiNgRails
end end
def fetch(method: "", params: {}) def fetch(method: "", params: {})
raise "Not allowed method #{method.name}" unless method.allowed? #raise "Not allowed method #{method.name}" unless method.allowed?
run_request for_method: method, params: params run_request for_method: method, params: params
end end
private private
def run_request(for_method: "", params: {}) def run_request(for_method: "", params: {})
requester = http_requester(for_method.api_url) http_requester.set_api_req_body for_method, params
requester.set_api_req_body for_method, params http_requester.do_request
requester.do_request
end end
def http_requester(api_url) def http_requester
@_http_requester ||= Api::Http::Factory.provider_requester api_url, ssoid @_http_requester ||= Api::Http::Factory.provider_requester ssoid
end end
end end
end 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