betfair_api_ng_rails 1.1.0 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +26 -1
- data/Rakefile +8 -8
- data/betfair_api_ng_rails.gemspec +12 -7
- data/lib/betfair_api_ng_rails.rb +162 -98
- data/lib/betfair_api_ng_rails/account.rb +4 -0
- data/lib/betfair_api_ng_rails/account_manager.rb +36 -0
- data/lib/betfair_api_ng_rails/account_session.rb +5 -0
- data/lib/betfair_api_ng_rails/account_session_manager.rb +29 -0
- data/lib/betfair_api_ng_rails/api/caching/helper.rb +34 -0
- data/lib/betfair_api_ng_rails/api/caching/response_cache.rb +57 -0
- data/lib/betfair_api_ng_rails/api/concerns/errorable.rb +1 -3
- data/lib/betfair_api_ng_rails/api/config.rb +20 -8
- data/lib/betfair_api_ng_rails/api/connection.rb +28 -10
- data/lib/betfair_api_ng_rails/api/connection_ext/caching.rb +60 -0
- data/lib/betfair_api_ng_rails/api/connection_ext/error_handling.rb +5 -1
- data/lib/betfair_api_ng_rails/api/connection_ext/logging.rb +34 -0
- data/lib/betfair_api_ng_rails/api/connection_ext/parsing.rb +2 -4
- data/lib/betfair_api_ng_rails/api/connection_ext/ssoid_refreshing.rb +40 -0
- data/lib/betfair_api_ng_rails/api/constants.rb +39 -18
- data/lib/betfair_api_ng_rails/api/data/account_details_response.rb +27 -0
- data/lib/betfair_api_ng_rails/api/data/account_funds_response.rb +26 -0
- data/lib/betfair_api_ng_rails/api/data/account_statement_report.rb +17 -0
- data/lib/betfair_api_ng_rails/api/data/competition.rb +3 -4
- data/lib/betfair_api_ng_rails/api/data/competition_result.rb +1 -3
- data/lib/betfair_api_ng_rails/api/data/concerns/attributable.rb +2 -6
- data/lib/betfair_api_ng_rails/api/data/concerns/hashable.rb +11 -4
- data/lib/betfair_api_ng_rails/api/data/constants.rb +2 -4
- data/lib/betfair_api_ng_rails/api/data/country_code_result.rb +1 -3
- data/lib/betfair_api_ng_rails/api/data/event.rb +1 -2
- data/lib/betfair_api_ng_rails/api/data/event_result.rb +1 -3
- data/lib/betfair_api_ng_rails/api/data/limit_on_close_order.rb +22 -0
- data/lib/betfair_api_ng_rails/api/data/limit_order.rb +23 -0
- data/lib/betfair_api_ng_rails/api/data/market_book.rb +2 -4
- data/lib/betfair_api_ng_rails/api/data/market_filter.rb +3 -2
- data/lib/betfair_api_ng_rails/api/data/market_on_close_order.rb +20 -0
- data/lib/betfair_api_ng_rails/api/data/order.rb +1 -3
- data/lib/betfair_api_ng_rails/api/data/place_execution_report.rb +24 -0
- data/lib/betfair_api_ng_rails/api/data/place_instruction.rb +25 -0
- data/lib/betfair_api_ng_rails/api/data/place_instruction_report.rb +27 -0
- data/lib/betfair_api_ng_rails/api/data/statement_item.rb +30 -0
- data/lib/betfair_api_ng_rails/api/data/statement_legacy_data.rb +40 -0
- data/lib/betfair_api_ng_rails/api/endpoint_factory.rb +21 -0
- data/lib/betfair_api_ng_rails/api/endpoints/australian.rb +17 -0
- data/lib/betfair_api_ng_rails/api/endpoints/base.rb +42 -0
- data/lib/betfair_api_ng_rails/api/endpoints/italian.rb +17 -0
- data/lib/betfair_api_ng_rails/api/endpoints/spanish.rb +17 -0
- data/lib/betfair_api_ng_rails/api/endpoints/uk.rb +17 -0
- data/lib/betfair_api_ng_rails/api/enums/execution_report_error_code.rb +22 -1
- data/lib/betfair_api_ng_rails/api/enums/execution_report_status.rb +12 -1
- data/lib/betfair_api_ng_rails/api/enums/include_item.rb +23 -0
- data/lib/betfair_api_ng_rails/api/enums/instruction_report_error_code.rb +25 -1
- data/lib/betfair_api_ng_rails/api/enums/instruction_report_status.rb +8 -1
- data/lib/betfair_api_ng_rails/api/enums/item_class.rb +19 -0
- data/lib/betfair_api_ng_rails/api/enums/order_status.rb +7 -1
- data/lib/betfair_api_ng_rails/api/enums/order_type.rb +11 -2
- data/lib/betfair_api_ng_rails/api/enums/persistence_type.rb +8 -1
- data/lib/betfair_api_ng_rails/api/enums/side.rb +7 -2
- data/lib/betfair_api_ng_rails/api/enums/wallet.rb +20 -0
- data/lib/betfair_api_ng_rails/api/formatter_factory.rb +2 -4
- data/lib/betfair_api_ng_rails/api/formatters/js_tree_formatter.rb +2 -4
- data/lib/betfair_api_ng_rails/api/hashalator.rb +6 -6
- data/lib/betfair_api_ng_rails/api/helper.rb +2 -4
- data/lib/betfair_api_ng_rails/api/http/factory.rb +19 -14
- data/lib/betfair_api_ng_rails/api/http/helpers/information_response.rb +2 -4
- data/lib/betfair_api_ng_rails/api/http/helpers/keep_alive_response.rb +3 -4
- data/lib/betfair_api_ng_rails/api/http/helpers/session_response.rb +3 -4
- data/lib/betfair_api_ng_rails/api/http/proxy_requester.rb +87 -0
- data/lib/betfair_api_ng_rails/api/http/requester.rb +3 -3
- data/lib/betfair_api_ng_rails/api/http/responser.rb +4 -3
- data/lib/betfair_api_ng_rails/api/invalid_endpoint_error.rb +6 -0
- data/lib/betfair_api_ng_rails/api/logs/console_logger.rb +13 -0
- data/lib/betfair_api_ng_rails/api/logs/file_logger.rb +23 -0
- data/lib/betfair_api_ng_rails/api/parsers/base.rb +14 -6
- data/lib/betfair_api_ng_rails/api/parsers/get_account_details.rb +13 -0
- data/lib/betfair_api_ng_rails/api/parsers/get_account_funds.rb +14 -0
- data/lib/betfair_api_ng_rails/api/parsers/get_account_statement.rb +15 -0
- data/lib/betfair_api_ng_rails/api/parsers/list_base.rb +18 -0
- data/lib/betfair_api_ng_rails/api/parsers/list_competitions.rb +5 -7
- data/lib/betfair_api_ng_rails/api/parsers/list_countries.rb +5 -7
- data/lib/betfair_api_ng_rails/api/parsers/list_event_types.rb +5 -7
- data/lib/betfair_api_ng_rails/api/parsers/list_events.rb +5 -7
- data/lib/betfair_api_ng_rails/api/parsers/list_market_book.rb +5 -7
- data/lib/betfair_api_ng_rails/api/parsers/list_market_catalogue.rb +5 -7
- data/lib/betfair_api_ng_rails/api/parsers/list_market_types.rb +5 -7
- data/lib/betfair_api_ng_rails/api/parsers/list_time_ranges.rb +5 -7
- data/lib/betfair_api_ng_rails/api/parsers/list_venues.rb +5 -7
- data/lib/betfair_api_ng_rails/api/parsers/place_orders.rb +14 -0
- data/lib/betfair_api_ng_rails/api/parsers/single_base.rb +19 -0
- data/lib/betfair_api_ng_rails/api/provider.rb +11 -14
- data/lib/betfair_api_ng_rails/api/request_method.rb +43 -0
- data/lib/betfair_api_ng_rails/api/request_methods/account.rb +51 -0
- data/lib/betfair_api_ng_rails/api/request_methods/all.rb +26 -0
- data/lib/betfair_api_ng_rails/api/request_methods/betting.rb +30 -0
- data/lib/betfair_api_ng_rails/api/session_manager.rb +34 -31
- data/lib/betfair_api_ng_rails/bad_response_error.rb +4 -0
- data/lib/betfair_api_ng_rails/errors.rb +3 -2
- data/lib/betfair_api_ng_rails/railtie.rb +7 -2
- data/lib/betfair_api_ng_rails/version.rb +1 -1
- data/lib/generators/betfair_api_ng_rails/install/templates/betfair_api_ng_rails.rb +20 -11
- data/lib/generators/betfair_api_ng_rails/install/templates/betfair_api_ng_rails.yml +5 -7
- data/spec/lib/betfair_api_ng_rails/account_manager_spec.rb +76 -0
- data/spec/lib/betfair_api_ng_rails/account_session_manager_spec.rb +59 -0
- data/spec/lib/betfair_api_ng_rails/account_session_spec.rb +13 -0
- data/spec/lib/betfair_api_ng_rails/account_spec.rb +18 -0
- data/spec/lib/betfair_api_ng_rails/api/caching/helper_spec.rb +89 -0
- data/spec/lib/betfair_api_ng_rails/api/caching/response_cache_spec.rb +131 -0
- data/spec/lib/betfair_api_ng_rails/api/config_spec.rb +37 -0
- data/spec/lib/betfair_api_ng_rails/api/connection_spec.rb +99 -0
- data/spec/lib/betfair_api_ng_rails/api/data/account_statement_report_spec.rb +11 -0
- data/spec/{betfair_api_ng_rails → lib/betfair_api_ng_rails}/api/data/competition_result_spec.rb +0 -0
- data/spec/{betfair_api_ng_rails → lib/betfair_api_ng_rails}/api/data/competition_spec.rb +0 -0
- data/spec/{betfair_api_ng_rails → lib/betfair_api_ng_rails}/api/data/concerns/attributable_spec.rb +0 -0
- data/spec/{betfair_api_ng_rails → lib/betfair_api_ng_rails}/api/data/concerns/hashable_spec.rb +16 -32
- data/spec/{betfair_api_ng_rails → lib/betfair_api_ng_rails}/api/data/concerns/jsonable_spec.rb +0 -0
- data/spec/{betfair_api_ng_rails → lib/betfair_api_ng_rails}/api/data/country_code_result_spec.rb +0 -0
- data/spec/{betfair_api_ng_rails → lib/betfair_api_ng_rails}/api/data/event_result_spec.rb +0 -0
- data/spec/{betfair_api_ng_rails → lib/betfair_api_ng_rails}/api/data/event_spec.rb +0 -0
- data/spec/{betfair_api_ng_rails → lib/betfair_api_ng_rails}/api/data/event_type_result_spec.rb +0 -0
- data/spec/{betfair_api_ng_rails → lib/betfair_api_ng_rails}/api/data/event_type_spec.rb +0 -0
- data/spec/{betfair_api_ng_rails → lib/betfair_api_ng_rails}/api/data/ex_best_offers_overrides_spec.rb +0 -0
- data/spec/{betfair_api_ng_rails → lib/betfair_api_ng_rails}/api/data/exchange_prices_spec.rb +0 -0
- data/spec/{betfair_api_ng_rails → lib/betfair_api_ng_rails}/api/data/market_book_spec.rb +1 -6
- data/spec/{betfair_api_ng_rails → lib/betfair_api_ng_rails}/api/data/market_catalogue_spec.rb +0 -0
- data/spec/{betfair_api_ng_rails → lib/betfair_api_ng_rails}/api/data/market_description_spec.rb +0 -0
- data/spec/{betfair_api_ng_rails → lib/betfair_api_ng_rails}/api/data/market_filter_spec.rb +0 -0
- data/spec/{betfair_api_ng_rails → lib/betfair_api_ng_rails}/api/data/market_type_result_spec.rb +0 -0
- data/spec/{betfair_api_ng_rails → lib/betfair_api_ng_rails}/api/data/match_spec.rb +0 -0
- data/spec/{betfair_api_ng_rails → lib/betfair_api_ng_rails}/api/data/order_spec.rb +0 -0
- data/spec/{betfair_api_ng_rails → lib/betfair_api_ng_rails}/api/data/price_projection_spec.rb +0 -0
- data/spec/{betfair_api_ng_rails → lib/betfair_api_ng_rails}/api/data/price_size_spec.rb +0 -0
- data/spec/{betfair_api_ng_rails → lib/betfair_api_ng_rails}/api/data/runner_catalog_spec.rb +0 -0
- data/spec/{betfair_api_ng_rails → lib/betfair_api_ng_rails}/api/data/runner_spec.rb +0 -0
- data/spec/{betfair_api_ng_rails → lib/betfair_api_ng_rails}/api/data/starting_prices_spec.rb +0 -0
- data/spec/lib/betfair_api_ng_rails/api/data/statement_item_spec.rb +9 -0
- data/spec/lib/betfair_api_ng_rails/api/data/statement_legacy_data_spec.rb +6 -0
- data/spec/{betfair_api_ng_rails → lib/betfair_api_ng_rails}/api/data/time_range_result_spec.rb +0 -0
- data/spec/{betfair_api_ng_rails → lib/betfair_api_ng_rails}/api/data/time_range_spec.rb +1 -3
- data/spec/{betfair_api_ng_rails → lib/betfair_api_ng_rails}/api/data/venue_result_spec.rb +0 -0
- data/spec/lib/betfair_api_ng_rails/api/endpoint_factory_spec.rb +27 -0
- data/spec/lib/betfair_api_ng_rails/api/endpoints/australian_spec.rb +6 -0
- data/spec/lib/betfair_api_ng_rails/api/endpoints/base_spec.rb +5 -0
- data/spec/lib/betfair_api_ng_rails/api/endpoints/italian_spec.rb +6 -0
- data/spec/lib/betfair_api_ng_rails/api/endpoints/spanish_spec.rb +7 -0
- data/spec/lib/betfair_api_ng_rails/api/endpoints/uk_spec.rb +6 -0
- data/spec/{betfair_api_ng_rails → lib/betfair_api_ng_rails}/api/formatters/js_tree_formatter_spec.rb +0 -0
- data/spec/{betfair_api_ng_rails → lib/betfair_api_ng_rails}/api/hashalator_spec.rb +27 -46
- data/spec/lib/betfair_api_ng_rails/api/http/factory_spec.rb +40 -0
- data/spec/lib/betfair_api_ng_rails/api/logs/console_logger_spec.rb +18 -0
- data/spec/lib/betfair_api_ng_rails/api/logs/file_logger_spec.rb +33 -0
- data/spec/lib/betfair_api_ng_rails/api/provider_spec.rb +53 -0
- data/spec/lib/betfair_api_ng_rails/api/request_method_spec.rb +38 -0
- data/spec/{betfair_api_ng_rails → lib/betfair_api_ng_rails}/api/request_methods_spec.rb +47 -32
- data/spec/lib/betfair_api_ng_rails/api/session_manager_spec.rb +77 -0
- data/spec/lib/betfair_api_ng_rails/integration/get_account_statement_spec.rb +57 -0
- data/spec/{betfair_api_ng_rails → lib/betfair_api_ng_rails}/integration/list_competitions_spec.rb +7 -9
- data/spec/{betfair_api_ng_rails → lib/betfair_api_ng_rails}/integration/list_countries_spec.rb +7 -9
- data/spec/{betfair_api_ng_rails → lib/betfair_api_ng_rails}/integration/list_event_types_spec.rb +7 -9
- data/spec/{betfair_api_ng_rails → lib/betfair_api_ng_rails}/integration/list_events_spec.rb +7 -9
- data/spec/{betfair_api_ng_rails → lib/betfair_api_ng_rails}/integration/list_market_book_spec.rb +7 -9
- data/spec/{betfair_api_ng_rails → lib/betfair_api_ng_rails}/integration/list_market_catalogue_spec.rb +7 -16
- data/spec/{betfair_api_ng_rails → lib/betfair_api_ng_rails}/integration/list_market_types_spec.rb +7 -9
- data/spec/{betfair_api_ng_rails → lib/betfair_api_ng_rails}/integration/list_time_ranges_spec.rb +7 -9
- data/spec/{betfair_api_ng_rails → lib/betfair_api_ng_rails}/integration/list_venues_spec.rb +7 -9
- data/spec/lib/betfair_api_ng_rails/integration/place_orders_spec.rb +55 -0
- data/spec/spec_helper.rb +9 -1
- data/spec/support/base_yaml_loader.rb +2 -4
- data/spec/support/data/models.yml +37 -1
- data/spec/support/data_models_yaml_loader.rb +1 -3
- data/spec/support/have_attr_accessor.rb +18 -0
- data/spec/support/helper.rb +1 -3
- data/spec/support/shared_examples/base_endpoint.rb +5 -0
- data/spec/support/shared_examples/concrete_endpoint.rb +28 -0
- data/spec/support/shared_examples/data_model.rb +2 -11
- data/spec/support/shared_examples/request_method.rb +5 -8
- data/spec/support/shared_examples/simple_list_filtering_request.rb +10 -19
- metadata +252 -117
- data/lib/betfair_api_ng_rails/api/request_methods.rb +0 -41
- data/spec/betfair_api_ng_rails/api/connection_spec.rb +0 -76
- data/spec/betfair_api_ng_rails/api/provider_spec.rb +0 -91
- data/spec/betfair_api_ng_rails/api/session_manager_spec.rb +0 -59
@@ -2,7 +2,6 @@ module BetfairApiNgRails
|
|
2
2
|
module Api
|
3
3
|
module Parsers
|
4
4
|
class Base
|
5
|
-
|
6
5
|
attr_reader :responser
|
7
6
|
|
8
7
|
def initialize(responser)
|
@@ -10,20 +9,29 @@ module BetfairApiNgRails
|
|
10
9
|
end
|
11
10
|
|
12
11
|
def process
|
13
|
-
|
12
|
+
raise 'Must be reimplemented!'
|
14
13
|
end
|
15
14
|
|
16
|
-
|
15
|
+
private
|
17
16
|
|
18
17
|
def fetch_result_json
|
19
|
-
responser.has_error? ?
|
18
|
+
responser.has_error? ? default_value : responser.api_result
|
19
|
+
rescue
|
20
|
+
raise BetfairApiNgRails::BadResponseError
|
20
21
|
end
|
21
22
|
|
22
|
-
def
|
23
|
+
def default_value
|
23
24
|
raise 'Must be reimplemented!'
|
24
25
|
end
|
25
26
|
|
27
|
+
def process_row(json_row)
|
28
|
+
data_class.from_json json_row
|
29
|
+
end
|
30
|
+
|
31
|
+
def data_class
|
32
|
+
raise 'Must be reimplemented!'
|
33
|
+
end
|
26
34
|
end
|
27
35
|
end
|
28
36
|
end
|
29
|
-
end
|
37
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module BetfairApiNgRails
|
2
|
+
module Api
|
3
|
+
module Parsers
|
4
|
+
class ListBase < Api::Parsers::Base
|
5
|
+
def process
|
6
|
+
fetch_result_json.map { |json_row| process_row json_row }
|
7
|
+
end
|
8
|
+
|
9
|
+
private
|
10
|
+
|
11
|
+
def default_value
|
12
|
+
[]
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
@@ -1,15 +1,13 @@
|
|
1
1
|
module BetfairApiNgRails
|
2
2
|
module Api
|
3
3
|
module Parsers
|
4
|
-
class ListCompetitions < Api::Parsers::
|
4
|
+
class ListCompetitions < Api::Parsers::ListBase
|
5
|
+
private
|
5
6
|
|
6
|
-
|
7
|
-
|
8
|
-
def process_row(json_row)
|
9
|
-
Api::Data::CompetitionResult.from_json json_row
|
7
|
+
def data_class
|
8
|
+
Api::Data::CompetitionResult
|
10
9
|
end
|
11
|
-
|
12
10
|
end
|
13
11
|
end
|
14
12
|
end
|
15
|
-
end
|
13
|
+
end
|
@@ -1,15 +1,13 @@
|
|
1
1
|
module BetfairApiNgRails
|
2
2
|
module Api
|
3
3
|
module Parsers
|
4
|
-
class ListCountries < Api::Parsers::
|
4
|
+
class ListCountries < Api::Parsers::ListBase
|
5
|
+
private
|
5
6
|
|
6
|
-
|
7
|
-
|
8
|
-
def process_row(json_row)
|
9
|
-
Api::Data::CountryCodeResult.from_json json_row
|
7
|
+
def data_class
|
8
|
+
Api::Data::CountryCodeResult
|
10
9
|
end
|
11
|
-
|
12
10
|
end
|
13
11
|
end
|
14
12
|
end
|
15
|
-
end
|
13
|
+
end
|
@@ -1,15 +1,13 @@
|
|
1
1
|
module BetfairApiNgRails
|
2
2
|
module Api
|
3
3
|
module Parsers
|
4
|
-
class ListEventTypes < Api::Parsers::
|
4
|
+
class ListEventTypes < Api::Parsers::ListBase
|
5
|
+
private
|
5
6
|
|
6
|
-
|
7
|
-
|
8
|
-
def process_row(json_row)
|
9
|
-
Api::Data::EventTypeResult.from_json json_row
|
7
|
+
def data_class
|
8
|
+
Api::Data::EventTypeResult
|
10
9
|
end
|
11
|
-
|
12
10
|
end
|
13
11
|
end
|
14
12
|
end
|
15
|
-
end
|
13
|
+
end
|
@@ -1,15 +1,13 @@
|
|
1
1
|
module BetfairApiNgRails
|
2
2
|
module Api
|
3
3
|
module Parsers
|
4
|
-
class ListEvents < Api::Parsers::
|
4
|
+
class ListEvents < Api::Parsers::ListBase
|
5
|
+
private
|
5
6
|
|
6
|
-
|
7
|
-
|
8
|
-
def process_row(json_row)
|
9
|
-
Api::Data::EventResult.from_json json_row
|
7
|
+
def data_class
|
8
|
+
Api::Data::EventResult
|
10
9
|
end
|
11
|
-
|
12
10
|
end
|
13
11
|
end
|
14
12
|
end
|
15
|
-
end
|
13
|
+
end
|
@@ -1,15 +1,13 @@
|
|
1
1
|
module BetfairApiNgRails
|
2
2
|
module Api
|
3
3
|
module Parsers
|
4
|
-
class ListMarketBook < Api::Parsers::
|
4
|
+
class ListMarketBook < Api::Parsers::ListBase
|
5
|
+
private
|
5
6
|
|
6
|
-
|
7
|
-
|
8
|
-
def process_row(json_row)
|
9
|
-
BetfairApiNgRails::MarketBook.from_json json_row
|
7
|
+
def data_class
|
8
|
+
BetfairApiNgRails::MarketBook
|
10
9
|
end
|
11
|
-
|
12
10
|
end
|
13
11
|
end
|
14
12
|
end
|
15
|
-
end
|
13
|
+
end
|
@@ -1,15 +1,13 @@
|
|
1
1
|
module BetfairApiNgRails
|
2
2
|
module Api
|
3
3
|
module Parsers
|
4
|
-
class ListMarketCatalogue < Api::Parsers::
|
4
|
+
class ListMarketCatalogue < Api::Parsers::ListBase
|
5
|
+
private
|
5
6
|
|
6
|
-
|
7
|
-
|
8
|
-
def process_row(json_row)
|
9
|
-
BetfairApiNgRails::MarketCatalogue.from_json json_row
|
7
|
+
def data_class
|
8
|
+
BetfairApiNgRails::MarketCatalogue
|
10
9
|
end
|
11
|
-
|
12
10
|
end
|
13
11
|
end
|
14
12
|
end
|
15
|
-
end
|
13
|
+
end
|
@@ -1,15 +1,13 @@
|
|
1
1
|
module BetfairApiNgRails
|
2
2
|
module Api
|
3
3
|
module Parsers
|
4
|
-
class ListMarketTypes < Api::Parsers::
|
4
|
+
class ListMarketTypes < Api::Parsers::ListBase
|
5
|
+
private
|
5
6
|
|
6
|
-
|
7
|
-
|
8
|
-
def process_row(json_row)
|
9
|
-
Api::Data::MarketTypeResult.from_json json_row
|
7
|
+
def data_class
|
8
|
+
Api::Data::MarketTypeResult
|
10
9
|
end
|
11
|
-
|
12
10
|
end
|
13
11
|
end
|
14
12
|
end
|
15
|
-
end
|
13
|
+
end
|
@@ -1,15 +1,13 @@
|
|
1
1
|
module BetfairApiNgRails
|
2
2
|
module Api
|
3
3
|
module Parsers
|
4
|
-
class ListTimeRanges < Api::Parsers::
|
4
|
+
class ListTimeRanges < Api::Parsers::ListBase
|
5
|
+
private
|
5
6
|
|
6
|
-
|
7
|
-
|
8
|
-
def process_row(json_row)
|
9
|
-
Api::Data::TimeRangeResult.from_json json_row
|
7
|
+
def data_class
|
8
|
+
Api::Data::TimeRangeResult
|
10
9
|
end
|
11
|
-
|
12
10
|
end
|
13
11
|
end
|
14
12
|
end
|
15
|
-
end
|
13
|
+
end
|
@@ -1,15 +1,13 @@
|
|
1
1
|
module BetfairApiNgRails
|
2
2
|
module Api
|
3
3
|
module Parsers
|
4
|
-
class ListVenues < Api::Parsers::
|
4
|
+
class ListVenues < Api::Parsers::ListBase
|
5
|
+
private
|
5
6
|
|
6
|
-
|
7
|
-
|
8
|
-
def process_row(json_row)
|
9
|
-
Api::Data::VenueResult.from_json json_row
|
7
|
+
def data_class
|
8
|
+
Api::Data::VenueResult
|
10
9
|
end
|
11
|
-
|
12
10
|
end
|
13
11
|
end
|
14
12
|
end
|
15
|
-
end
|
13
|
+
end
|
@@ -7,32 +7,29 @@ module BetfairApiNgRails
|
|
7
7
|
include Api::Concerns::Errorable
|
8
8
|
include Api::Constants
|
9
9
|
|
10
|
-
attr_reader :ssoid
|
10
|
+
attr_reader :ssoid, :application_key
|
11
11
|
|
12
|
-
def initialize(ssoid)
|
12
|
+
def initialize(ssoid, application_key)
|
13
13
|
@ssoid = ssoid
|
14
|
+
@application_key = application_key
|
14
15
|
end
|
15
16
|
|
16
17
|
def fetch(method: "", params: {})
|
17
|
-
raise "Not allowed method #{method.
|
18
|
+
raise "Not allowed method #{method.name}" unless method.allowed?
|
18
19
|
run_request for_method: method, params: params
|
19
20
|
end
|
20
21
|
|
21
|
-
|
22
|
+
private
|
22
23
|
|
23
24
|
def run_request(for_method: "", params: {})
|
24
|
-
http_requester.
|
25
|
-
|
25
|
+
requester = http_requester(for_method.api_url)
|
26
|
+
requester.set_api_req_body for_method, params
|
27
|
+
requester.do_request
|
26
28
|
end
|
27
29
|
|
28
|
-
def
|
29
|
-
|
30
|
+
def http_requester(api_url)
|
31
|
+
Api::Http::Factory.provider_requester api_url, ssoid, application_key
|
30
32
|
end
|
31
|
-
|
32
|
-
def http_requester
|
33
|
-
@_http_requester ||= Api::Http::Factory.provider_requester ssoid
|
34
|
-
end
|
35
|
-
|
36
33
|
end
|
37
34
|
end
|
38
|
-
end
|
35
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
module BetfairApiNgRails
|
2
|
+
module Api
|
3
|
+
class RequestMethod
|
4
|
+
include Api::Constants
|
5
|
+
|
6
|
+
attr_reader :name, :endpoint
|
7
|
+
|
8
|
+
def initialize(name, endpoint)
|
9
|
+
@name = name
|
10
|
+
@endpoint = endpoint
|
11
|
+
BetfairApiNgRails.log.write("==> Creating request method for #{name}")
|
12
|
+
end
|
13
|
+
|
14
|
+
def allowed?
|
15
|
+
allow_data.any?
|
16
|
+
end
|
17
|
+
|
18
|
+
def type
|
19
|
+
fetch_type
|
20
|
+
end
|
21
|
+
|
22
|
+
def api_url
|
23
|
+
endpoint.api_url(type)
|
24
|
+
end
|
25
|
+
|
26
|
+
def json_method
|
27
|
+
JSON_METHOD[type]
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
def fetch_type
|
33
|
+
allow_data.keys.first.to_s.to_sym
|
34
|
+
end
|
35
|
+
|
36
|
+
def allow_data
|
37
|
+
@_allow_data ||= ALLOWED_RESOURCES.select do |k, v|
|
38
|
+
v.include? name
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
module BetfairApiNgRails
|
2
|
+
module Api
|
3
|
+
module RequestMethods
|
4
|
+
module Account
|
5
|
+
#
|
6
|
+
# Returns the details relating your account, including your discount rate and Betfair point balance.
|
7
|
+
#
|
8
|
+
def get_account_details(account: '')
|
9
|
+
run_request __method__, {}, account
|
10
|
+
end
|
11
|
+
|
12
|
+
#
|
13
|
+
# Get available to bet amount. The getAccounts service will return the UK wallet balance by default
|
14
|
+
# from either the UK or AUS Accounts API endpoint if the wallet parameter is not specified.
|
15
|
+
#
|
16
|
+
def get_account_funds(account: '')
|
17
|
+
run_request __method__, {}, account
|
18
|
+
end
|
19
|
+
|
20
|
+
#
|
21
|
+
# Get account statement
|
22
|
+
#
|
23
|
+
# Parameters:
|
24
|
+
# locale - The language to be used where applicable. If not specified, the customer account default is returned.
|
25
|
+
# from_record - Specifies the first record that will be returned. Records start at index zero.
|
26
|
+
# If not specified then it will default to 0.
|
27
|
+
# record_count - Specifies the maximum number of records to be returned.
|
28
|
+
# Note that there is a page size limit of 100.
|
29
|
+
# item_date_range - Return items with an itemDate within this date range. Both from and to date times are inclusive.
|
30
|
+
# If from is not specified then the oldest available items will be in range. If to is not specified
|
31
|
+
# then the latest items will be in range. nb. This itemDataRange is currently only applied when
|
32
|
+
# includeItem is set to ALL or not specified, else items are NOT bound by itemDate.
|
33
|
+
# include_item - Which items to include, if not specified then defaults to ALL.
|
34
|
+
# wallet - Which wallet to return statementItems for. If unspecified then the UK wallet will be selected
|
35
|
+
# account - account username
|
36
|
+
#
|
37
|
+
# Returns:
|
38
|
+
# List of statement items chronologically ordered plus moreAvailable boolean to facilitate paging
|
39
|
+
#
|
40
|
+
def get_account_statement(args)
|
41
|
+
raise 'Must be a hash passed!' unless args.is_a? Hash
|
42
|
+
args[:locale] = args[:locale] || BetfairApiNgRails.config.locale
|
43
|
+
account = args[:account]
|
44
|
+
run_request __method__, args.except(:account), account
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
|