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

Temp

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