betfair_api_ng_rails 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +8 -4
- data/lib/betfair_api_ng_rails.rb +5 -16
- data/lib/betfair_api_ng_rails/api/base_requester.rb +1 -1
- data/lib/betfair_api_ng_rails/api/bf/config.rb +1 -12
- data/lib/betfair_api_ng_rails/api/bf/constants.rb +5 -0
- data/lib/betfair_api_ng_rails/api/bf/formatters/js_tree_formatter.rb +1 -1
- data/lib/betfair_api_ng_rails/api/bf/parser.rb +5 -1
- data/lib/betfair_api_ng_rails/api/bf/provider.rb +8 -3
- data/lib/betfair_api_ng_rails/api/formatter_factory.rb +21 -0
- data/lib/betfair_api_ng_rails/api/soccer/requester.rb +3 -2
- data/lib/betfair_api_ng_rails/version.rb +1 -1
- metadata +3 -14
- data/lib/betfair_api_ng_rails/api/soccer/cleared_order_requester.rb +0 -10
- data/lib/betfair_api_ng_rails/api/soccer/competition_requester.rb +0 -10
- data/lib/betfair_api_ng_rails/api/soccer/country_requester.rb +0 -10
- data/lib/betfair_api_ng_rails/api/soccer/current_order_requester.rb +0 -10
- data/lib/betfair_api_ng_rails/api/soccer/event_requester.rb +0 -10
- data/lib/betfair_api_ng_rails/api/soccer/event_type_requester.rb +0 -10
- data/lib/betfair_api_ng_rails/api/soccer/market_book_requester.rb +0 -10
- data/lib/betfair_api_ng_rails/api/soccer/market_catalogue_requester.rb +0 -10
- data/lib/betfair_api_ng_rails/api/soccer/market_profit_and_loss_requester.rb +0 -10
- data/lib/betfair_api_ng_rails/api/soccer/market_type_requester.rb +0 -10
- data/lib/betfair_api_ng_rails/api/soccer/time_range_requester.rb +0 -10
- data/lib/betfair_api_ng_rails/api/soccer/venue_requester.rb +0 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9d4331f320e5e91adc30dcca6364e44be4bc38ad
|
4
|
+
data.tar.gz: 32f2bb4dd3cf565ed282c9ddb1ba31e8a0538192
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 09b7ff8a4028830d7addc66f5aabf22ed3a14bffe9d08bf071bccf5ec8634c5803dccb3873ebf036cdf396d1ca83fa74e4784e1e3f1fa79dabeadce7cf06e500
|
7
|
+
data.tar.gz: 00b898d7cbe81d336514bab145731cac7424fe8113429dbe118d902618cf8b24bf44825b345f7f7ba545eff1d9fc5f3e72b4ed1931b09974644c4e1bd765cf95
|
data/README.md
CHANGED
@@ -20,6 +20,10 @@ Or install it yourself as:
|
|
20
20
|
|
21
21
|
$ gem install betfair_api_ng_rails
|
22
22
|
|
23
|
+
Or if you want to stay on the edge:
|
24
|
+
|
25
|
+
gem 'betfair_api_ng_rails', github: 'alterego-labs/betfair_api_ng_rails'
|
26
|
+
|
23
27
|
After this run next rake command:
|
24
28
|
|
25
29
|
$ bundle exec rake betfair_api_ng_rails:install
|
@@ -38,8 +42,8 @@ In this files you must specify credentials to API-NG. Also you should notice tha
|
|
38
42
|
Sample code for fetching competitions list:
|
39
43
|
|
40
44
|
```ruby
|
41
|
-
requester = BetfairApiNgRails::Api::Soccer::
|
42
|
-
res = requester.load
|
45
|
+
requester = BetfairApiNgRails::Api::Soccer::Requester.new provider: :bf
|
46
|
+
res = requester.load resource: :competitions
|
43
47
|
```
|
44
48
|
|
45
49
|
For all available methods see [there](https://api.developer.betfair.com/services/webapps/docs/display/1smk3cen4v3lu3yomq5qye0ni/Betting+Operations).
|
@@ -47,8 +51,8 @@ For all available methods see [there](https://api.developer.betfair.com/services
|
|
47
51
|
Also you may passing filering params in _load_:
|
48
52
|
|
49
53
|
```ruby
|
50
|
-
requester = BetfairApiNgRails::Api::Soccer::
|
51
|
-
res = requester.load parameters: { event_ids: [1, 2] }
|
54
|
+
requester = BetfairApiNgRails::Api::Soccer::Requester.new provider: :bf
|
55
|
+
res = requester.load resource: :competitions, parameters: { event_ids: [1, 2] }
|
52
56
|
```
|
53
57
|
|
54
58
|
## Contributing
|
data/lib/betfair_api_ng_rails.rb
CHANGED
@@ -4,10 +4,11 @@ module BetfairApiNgRails
|
|
4
4
|
|
5
5
|
module Api
|
6
6
|
|
7
|
-
autoload :BaseParser,
|
8
|
-
autoload :BaseProvider,
|
9
|
-
autoload :BaseRequester,
|
10
|
-
autoload :BaseFormatter,
|
7
|
+
autoload :BaseParser, 'betfair_api_ng_rails/api/base_parser'
|
8
|
+
autoload :BaseProvider, 'betfair_api_ng_rails/api/base_provider'
|
9
|
+
autoload :BaseRequester, 'betfair_api_ng_rails/api/base_requester'
|
10
|
+
autoload :BaseFormatter, 'betfair_api_ng_rails/api/base_formatter'
|
11
|
+
autoload :FormatterFactory, 'betfair_api_ng_rails/api/formatter_factory'
|
11
12
|
|
12
13
|
module BF
|
13
14
|
|
@@ -30,18 +31,6 @@ module BetfairApiNgRails
|
|
30
31
|
module Soccer
|
31
32
|
|
32
33
|
autoload :Requester, 'betfair_api_ng_rails/api/soccer/requester'
|
33
|
-
autoload :CompetitionRequester, 'betfair_api_ng_rails/api/soccer/competition_requester'
|
34
|
-
autoload :EventTypeRequester, 'betfair_api_ng_rails/api/soccer/event_type_requester'
|
35
|
-
autoload :TimeRangeRequester, 'betfair_api_ng_rails/api/soccer/time_range_requester'
|
36
|
-
autoload :EventRequester, 'betfair_api_ng_rails/api/soccer/event_requester'
|
37
|
-
autoload :MarketTypeRequester, 'betfair_api_ng_rails/api/soccer/market_type_requester'
|
38
|
-
autoload :CountryRequester, 'betfair_api_ng_rails/api/soccer/country_requester'
|
39
|
-
autoload :VenueRequester, 'betfair_api_ng_rails/api/soccer/venue_requester'
|
40
|
-
autoload :MarketCatalogueRequester, 'betfair_api_ng_rails/api/soccer/market_catalogue_requester'
|
41
|
-
autoload :MarketBookRequester, 'betfair_api_ng_rails/api/soccer/market_book_requester'
|
42
|
-
autoload :CurrentOrderRequester, 'betfair_api_ng_rails/api/soccer/current_order_requester'
|
43
|
-
autoload :ClearedOrderRequester, 'betfair_api_ng_rails/api/soccer/cleared_order_requester'
|
44
|
-
autoload :MarketProfitAndLossRequester, 'betfair_api_ng_rails/api/soccer/market_profit_and_loss_requester'
|
45
34
|
|
46
35
|
end
|
47
36
|
|
@@ -1,4 +1,3 @@
|
|
1
|
-
require 'active_support/core_ext/object'
|
2
1
|
require 'betfair_api_ng_rails/api/bf/formatters/js_tree_formatter'
|
3
2
|
|
4
3
|
module BetfairApiNgRails
|
@@ -18,17 +17,7 @@ module BetfairApiNgRails
|
|
18
17
|
:formatter
|
19
18
|
|
20
19
|
def formatter=(value)
|
21
|
-
@formatter = initialize_formatter value
|
22
|
-
end
|
23
|
-
|
24
|
-
private
|
25
|
-
|
26
|
-
def initialize_formatter(name)
|
27
|
-
name.is_a?(Symbol) ? initialize_formatter_by(name: name) : name.try(:new)
|
28
|
-
end
|
29
|
-
|
30
|
-
def initialize_formatter_by(name: "")
|
31
|
-
"BetfairApiNgRails::Api::BF::Formatters::#{name.to_s.camelize}Formatter".constantize.new
|
20
|
+
@formatter = BetfairApiNgRails::Api::FormatterFactory.initialize_formatter value
|
32
21
|
end
|
33
22
|
|
34
23
|
end
|
@@ -16,6 +16,11 @@ module BetfairApiNgRails
|
|
16
16
|
"Accept" => "application/json"
|
17
17
|
}
|
18
18
|
|
19
|
+
ALLOWED_RESOURCES = {
|
20
|
+
soccer: [:event_types, :competitions, :time_ranges, :events, :market_types, :countries, :venues, :market_catalogue,
|
21
|
+
:market_book, :current_orders, :cleared_orders, :market_profit_and_loss]
|
22
|
+
}
|
23
|
+
|
19
24
|
end
|
20
25
|
end
|
21
26
|
end
|
@@ -16,7 +16,8 @@ module BetfairApiNgRails
|
|
16
16
|
|
17
17
|
def fetch(data: "", parameters: {}, sport: "")
|
18
18
|
return [] unless session_manager.request_ssoid
|
19
|
-
|
19
|
+
raise "Not allowed method #{data.to_s} for sport #{sport.to_s}" unless is_method_allowed?(data, sport)
|
20
|
+
setup_http_requester with_method: data, params: parameters
|
20
21
|
do_request data, parameters, sport
|
21
22
|
end
|
22
23
|
|
@@ -36,14 +37,18 @@ module BetfairApiNgRails
|
|
36
37
|
response.map { |r| Api::BF::Config.formatter.format(record: r, resource: data) }
|
37
38
|
end
|
38
39
|
|
39
|
-
def setup_http_requester(with_method: "")
|
40
|
+
def setup_http_requester(with_method: "", params: {})
|
40
41
|
@http_requester = Api::BF::HttpRequester.new(Api::BF::Config.api_url).tap do |req|
|
41
42
|
req.set_request_headers API_REQUEST_HEADERS
|
42
43
|
req.set_auth_headers Api::BF::Config.application_key, session_manager.ssoid
|
43
|
-
req.set_api_req_body build_function(with_method)
|
44
|
+
req.set_api_req_body build_function(with_method), params
|
44
45
|
end
|
45
46
|
end
|
46
47
|
|
48
|
+
def is_method_allowed?(data, sport)
|
49
|
+
ALLOWED_RESOURCES[sport.to_sym].include? data.to_sym
|
50
|
+
end
|
51
|
+
|
47
52
|
end
|
48
53
|
end
|
49
54
|
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'active_support/core_ext/object'
|
2
|
+
|
3
|
+
module BetfairApiNgRails
|
4
|
+
module Api
|
5
|
+
class FormatterFactory
|
6
|
+
class << self
|
7
|
+
|
8
|
+
def initialize_formatter(name)
|
9
|
+
name.is_a?(Symbol) ? initialize_formatter_by(name: name) : name.try(:new)
|
10
|
+
end
|
11
|
+
|
12
|
+
private
|
13
|
+
|
14
|
+
def initialize_formatter_by(name: "")
|
15
|
+
"BetfairApiNgRails::Api::BF::Formatters::#{name.to_s.camelize}Formatter".constantize.new
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -3,12 +3,13 @@ module BetfairApiNgRails
|
|
3
3
|
module Soccer
|
4
4
|
class Requester < BetfairApiNgRails::Api::BaseRequester
|
5
5
|
|
6
|
-
def initialize(provider)
|
6
|
+
def initialize(provider: "")
|
7
7
|
@sport = :soccer
|
8
8
|
super provider
|
9
9
|
end
|
10
10
|
|
11
|
-
def load(parameters: {})
|
11
|
+
def load(resource: "", parameters: {})
|
12
|
+
@data = resource
|
12
13
|
make_fetch parameters: parameters
|
13
14
|
end
|
14
15
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: betfair_api_ng_rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- sergio1990
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-03-
|
11
|
+
date: 2014-03-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -79,19 +79,8 @@ files:
|
|
79
79
|
- lib/betfair_api_ng_rails/api/bf/parser.rb
|
80
80
|
- lib/betfair_api_ng_rails/api/bf/provider.rb
|
81
81
|
- lib/betfair_api_ng_rails/api/bf/session_manager.rb
|
82
|
-
- lib/betfair_api_ng_rails/api/
|
83
|
-
- lib/betfair_api_ng_rails/api/soccer/competition_requester.rb
|
84
|
-
- lib/betfair_api_ng_rails/api/soccer/country_requester.rb
|
85
|
-
- lib/betfair_api_ng_rails/api/soccer/current_order_requester.rb
|
86
|
-
- lib/betfair_api_ng_rails/api/soccer/event_requester.rb
|
87
|
-
- lib/betfair_api_ng_rails/api/soccer/event_type_requester.rb
|
88
|
-
- lib/betfair_api_ng_rails/api/soccer/market_book_requester.rb
|
89
|
-
- lib/betfair_api_ng_rails/api/soccer/market_catalogue_requester.rb
|
90
|
-
- lib/betfair_api_ng_rails/api/soccer/market_profit_and_loss_requester.rb
|
91
|
-
- lib/betfair_api_ng_rails/api/soccer/market_type_requester.rb
|
82
|
+
- lib/betfair_api_ng_rails/api/formatter_factory.rb
|
92
83
|
- lib/betfair_api_ng_rails/api/soccer/requester.rb
|
93
|
-
- lib/betfair_api_ng_rails/api/soccer/time_range_requester.rb
|
94
|
-
- lib/betfair_api_ng_rails/api/soccer/venue_requester.rb
|
95
84
|
- lib/betfair_api_ng_rails/version.rb
|
96
85
|
- lib/generators/betfair_api_ng_rails/install/install_generator.rb
|
97
86
|
- lib/generators/betfair_api_ng_rails/install/templates/betfair_api_ng_rails.rb
|