Commit b1e135f9 authored by Sergey Gernyak's avatar Sergey Gernyak

Split account methods and betting ones

parent 10bafb13
require "betfair_api_ng_rails/version"
require "betfair_api_ng_rails/errors"
require "betfair_api_ng_rails/api/request_methods"
require "betfair_api_ng_rails/api/request_methods/all"
require "betfair_api_ng_rails/railtie" if defined?(Rails)
require 'redis'
......@@ -136,7 +136,7 @@ module BetfairApiNgRails
end
include Api::Data
extend Api::RequestMethods
extend Api::RequestMethods::All
class << self
attr_accessor :log
......
......@@ -35,4 +35,4 @@ module BetfairApiNgRails
end
end
end
\ No newline at end of file
end
require 'active_support/inflector'
require 'betfair_api_ng_rails/api/constants'
module BetfairApiNgRails
module Api
module RequestMethods
include Api::Constants
SIMPLE_LISTING_FILTERED.each do |method|
eval <<-CODE
def #{method.underscore}(filter: Api::Data::MarketFilter.new, locale: BetfairApiNgRails.config.locale)
run_request __method__, { filter: filter }, { locale: locale }
end
CODE
end
def list_market_catalogue(filter: MarketFilter.new, market_projection: [], sort: "", max_results: '1', locale: BetfairApiNgRails.config.locale)
run_request __method__, { filter: filter, market_projection: market_projection, sort: sort, max_results: max_results }, { locale: locale }
end
def list_market_book(market_ids: [], price_projection: BetfairApiNgRails::PriceProjection.new, order_projection: '', match_projection: '', currency_code: 'USD', locale: BetfairApiNgRails.config.locale)
run_request __method__, { market_ids: market_ids, price_projection: price_projection, order_projection: order_projection, match_projection: match_projection }, { currency_code: currency_code, locale: locale }
end
def place_orders(market_id: "", instructions: [], customer_ref: "")
run_request __method__, { market_id: market_id, instructions: instructions, customer_ref: customer_ref }
end
# Account API requests
private
def run_request(method, params, data = {})
BetfairApiNgRails.connection.request build_request_type(method), params.merge(data)
end
def build_request_type(name)
name.to_s.camelize(:lower)
end
end
end
end
module BetfairApiNgRails
module Api
module RequestMethods
module Account
#
# Returns the details relating your account, including your discount rate and Betfair point balance.
#
def get_account_details
end
#
# Get available to bet amount. The getAccounts service will return the UK wallet balance by default
# from either the UK or AUS Accounts API endpoint if the wallet parameter is not specified.
#
def get_account_funds
end
end
end
end
end
require 'active_support/inflector'
require 'betfair_api_ng_rails/api/constants'
require 'betfair_api_ng_rails/api/request_methods/betting'
require 'betfair_api_ng_rails/api/request_methods/account'
module BetfairApiNgRails
module Api
module RequestMethods
module All
include Api::Constants
include Api::RequestMethods::Betting
include Api::RequestMethods::Account
private
def run_request(method, params, data = {})
BetfairApiNgRails.connection.request build_request_type(method), params.merge(data)
end
def build_request_type(name)
name.to_s.camelize(:lower)
end
end
end
end
end
module BetfairApiNgRails
module Api
module RequestMethods
module Betting
include Api::Constants
SIMPLE_LISTING_FILTERED.each do |method|
eval <<-CODE
def #{method.underscore}(filter: Api::Data::MarketFilter.new, locale: BetfairApiNgRails.config.locale)
run_request __method__, { filter: filter }, { locale: locale }
end
CODE
end
def list_market_catalogue(filter: BetfairApiNgRails::MarketFilter.new, market_projection: [], sort: "", max_results: '1', locale: BetfairApiNgRails.config.locale)
run_request __method__, { filter: filter, market_projection: market_projection, sort: sort, max_results: max_results }, { locale: locale }
end
def list_market_book(market_ids: [], price_projection: BetfairApiNgRails::PriceProjection.new, order_projection: '', match_projection: '', currency_code: 'USD', locale: BetfairApiNgRails.config.locale)
run_request __method__, { market_ids: market_ids, price_projection: price_projection, order_projection: order_projection, match_projection: match_projection }, { currency_code: currency_code, locale: locale }
end
def place_orders(market_id: "", instructions: [], customer_ref: "")
run_request __method__, { market_id: market_id, instructions: instructions, customer_ref: customer_ref }
end
end
end
end
end
......@@ -7,7 +7,7 @@ require 'betfair_api_ng_rails'
Dir[File.join(File.dirname(__FILE__), 'support/**/*.rb')].each { |f| require f }
module TestModule
extend BetfairApiNgRails::Api::RequestMethods
extend BetfairApiNgRails::Api::RequestMethods::All
end
RSpec.configure do |config|
......
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