betradar 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +11 -0
- data/.rspec +3 -0
- data/.rubocop.yml +33 -0
- data/.travis.yml +10 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +90 -0
- data/LICENSE.txt +21 -0
- data/README.md +39 -0
- data/Rakefile +6 -0
- data/betradar.gemspec +35 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/betradar.rb +11 -0
- data/lib/betradar/api/betting_descriptions.rb +47 -0
- data/lib/betradar/api/booking_calendar.rb +9 -0
- data/lib/betradar/api/entity_description.rb +15 -0
- data/lib/betradar/api/odds_recover.rb +28 -0
- data/lib/betradar/api/probability.rb +19 -0
- data/lib/betradar/api/sport_event_information.rb +46 -0
- data/lib/betradar/api/static_sport_event_information.rb +30 -0
- data/lib/betradar/client.rb +27 -0
- data/lib/betradar/error.rb +55 -0
- data/lib/betradar/request.rb +19 -0
- data/lib/betradar/version.rb +3 -0
- metadata +208 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 26c6e2bf934b835cd71e3f240557686cc29edef7ae7b64d01e8acc0e5f33571b
|
4
|
+
data.tar.gz: c2575d75d7fd29d902447b4164979600b08afeb49a8a65e30b7fd126010db74f
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 2ccd1f2db4b4c0510b8da206fa626c561f7d83ae7ce0547673f9559eb3a3562a77e2c4e97a23042ccf2d1bfb49fedd45dd423aa04b61aa3993c33f0e5d31fc6b
|
7
|
+
data.tar.gz: 7671272b36f29702fa3b0aed139d6e8eb0052f09779002c1e2b572ac7a2a9c4258570e52008fe7fb67e57b5f69ae2d8f58650497952cd66ef143817369dd4bff
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
AllCops:
|
2
|
+
TargetRubyVersion: 2.4.1
|
3
|
+
|
4
|
+
Bundler/OrderedGems:
|
5
|
+
Enabled: false
|
6
|
+
|
7
|
+
Layout/AlignParameters:
|
8
|
+
EnforcedStyle: with_fixed_indentation
|
9
|
+
|
10
|
+
Metrics/AbcSize:
|
11
|
+
Max: 20
|
12
|
+
|
13
|
+
Metrics/LineLength:
|
14
|
+
Max: 120
|
15
|
+
|
16
|
+
Metrics/BlockLength:
|
17
|
+
Exclude:
|
18
|
+
- spec/**/*.rb
|
19
|
+
|
20
|
+
Style/FrozenStringLiteralComment:
|
21
|
+
EnforcedStyle: never
|
22
|
+
|
23
|
+
Style/SignalException:
|
24
|
+
EnforcedStyle: semantic
|
25
|
+
|
26
|
+
Style/RaiseArgs:
|
27
|
+
Enabled: false
|
28
|
+
|
29
|
+
Style/Documentation:
|
30
|
+
Enabled: false
|
31
|
+
|
32
|
+
Style/MultilineIfModifier:
|
33
|
+
Enabled: false
|
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,90 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
betradar (0.1.0)
|
5
|
+
ox (~> 2.10)
|
6
|
+
rest-client (~> 1.8)
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: https://rubygems.org/
|
10
|
+
specs:
|
11
|
+
addressable (2.5.2)
|
12
|
+
public_suffix (>= 2.0.2, < 4.0)
|
13
|
+
ast (2.4.0)
|
14
|
+
coderay (1.1.2)
|
15
|
+
crack (0.4.3)
|
16
|
+
safe_yaml (~> 1.0.0)
|
17
|
+
diff-lcs (1.3)
|
18
|
+
domain_name (0.5.20180417)
|
19
|
+
unf (>= 0.0.5, < 1.0.0)
|
20
|
+
hashdiff (0.3.7)
|
21
|
+
http-cookie (1.0.3)
|
22
|
+
domain_name (~> 0.5)
|
23
|
+
jaro_winkler (1.5.1)
|
24
|
+
method_source (0.9.0)
|
25
|
+
mime-types (2.99.3)
|
26
|
+
netrc (0.11.0)
|
27
|
+
ox (2.10.0)
|
28
|
+
parallel (1.12.1)
|
29
|
+
parser (2.5.1.2)
|
30
|
+
ast (~> 2.4.0)
|
31
|
+
powerpack (0.1.2)
|
32
|
+
pry (0.11.3)
|
33
|
+
coderay (~> 1.1.0)
|
34
|
+
method_source (~> 0.9.0)
|
35
|
+
public_suffix (3.0.3)
|
36
|
+
rainbow (3.0.0)
|
37
|
+
rake (10.5.0)
|
38
|
+
rest-client (1.8.0)
|
39
|
+
http-cookie (>= 1.0.2, < 2.0)
|
40
|
+
mime-types (>= 1.16, < 3.0)
|
41
|
+
netrc (~> 0.7)
|
42
|
+
rspec (3.8.0)
|
43
|
+
rspec-core (~> 3.8.0)
|
44
|
+
rspec-expectations (~> 3.8.0)
|
45
|
+
rspec-mocks (~> 3.8.0)
|
46
|
+
rspec-core (3.8.0)
|
47
|
+
rspec-support (~> 3.8.0)
|
48
|
+
rspec-expectations (3.8.1)
|
49
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
50
|
+
rspec-support (~> 3.8.0)
|
51
|
+
rspec-mocks (3.8.0)
|
52
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
53
|
+
rspec-support (~> 3.8.0)
|
54
|
+
rspec-support (3.8.0)
|
55
|
+
rubocop (0.59.2)
|
56
|
+
jaro_winkler (~> 1.5.1)
|
57
|
+
parallel (~> 1.10)
|
58
|
+
parser (>= 2.5, != 2.5.1.1)
|
59
|
+
powerpack (~> 0.1)
|
60
|
+
rainbow (>= 2.2.2, < 4.0)
|
61
|
+
ruby-progressbar (~> 1.7)
|
62
|
+
unicode-display_width (~> 1.0, >= 1.0.1)
|
63
|
+
ruby-progressbar (1.10.0)
|
64
|
+
safe_yaml (1.0.4)
|
65
|
+
unf (0.1.4)
|
66
|
+
unf_ext
|
67
|
+
unf_ext (0.0.7.5)
|
68
|
+
unicode-display_width (1.4.0)
|
69
|
+
vcr (4.0.0)
|
70
|
+
webmock (3.4.2)
|
71
|
+
addressable (>= 2.3.6)
|
72
|
+
crack (>= 0.3.2)
|
73
|
+
hashdiff
|
74
|
+
|
75
|
+
PLATFORMS
|
76
|
+
ruby
|
77
|
+
|
78
|
+
DEPENDENCIES
|
79
|
+
betradar!
|
80
|
+
bundler (~> 1.16)
|
81
|
+
pry
|
82
|
+
rake (~> 10.0)
|
83
|
+
rest-client (~> 1.8)
|
84
|
+
rspec (~> 3.8)
|
85
|
+
rubocop (~> 0.59.2)
|
86
|
+
vcr (~> 4.0)
|
87
|
+
webmock (~> 3.4)
|
88
|
+
|
89
|
+
BUNDLED WITH
|
90
|
+
1.16.6
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2018 Rahul
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
# Betradar
|
2
|
+
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/betradar`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'betradar'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install betradar
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
TODO: Write usage instructions here
|
26
|
+
|
27
|
+
## Development
|
28
|
+
|
29
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
+
|
31
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/betradar.
|
36
|
+
|
37
|
+
## License
|
38
|
+
|
39
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/betradar.gemspec
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
lib = File.expand_path('lib', __dir__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
require 'betradar/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = 'betradar'
|
7
|
+
spec.version = Betradar::VERSION
|
8
|
+
spec.authors = ['Rahul']
|
9
|
+
spec.email = ['rahulismishra@gmail.com']
|
10
|
+
|
11
|
+
spec.summary = 'aesmer'
|
12
|
+
spec.description = 'aesmer test'
|
13
|
+
spec.license = 'MIT'
|
14
|
+
|
15
|
+
# Specify which files should be added to the gem when it is released.
|
16
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
17
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
18
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
19
|
+
end
|
20
|
+
spec.bindir = 'exe'
|
21
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
22
|
+
spec.require_paths = ['lib']
|
23
|
+
|
24
|
+
spec.add_development_dependency 'bundler', '~> 1.16'
|
25
|
+
spec.add_development_dependency 'pry'
|
26
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
27
|
+
spec.add_development_dependency 'rest-client', '~> 1.8'
|
28
|
+
spec.add_development_dependency 'rspec', '~> 3.8'
|
29
|
+
spec.add_development_dependency 'rubocop', '~> 0.59.2'
|
30
|
+
spec.add_development_dependency 'vcr', '~> 4.0'
|
31
|
+
spec.add_development_dependency 'webmock', '~> 3.4'
|
32
|
+
|
33
|
+
spec.add_dependency 'ox', '~> 2.10'
|
34
|
+
spec.add_dependency 'rest-client', '~> 1.8'
|
35
|
+
end
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'bundler/setup'
|
4
|
+
require 'betradar'
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require 'irb'
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/lib/betradar.rb
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
require 'betradar/version'
|
2
|
+
require 'betradar/api/betting_descriptions'
|
3
|
+
require 'betradar/api/entity_description'
|
4
|
+
require 'betradar/api/probability'
|
5
|
+
require 'betradar/api/static_sport_event_information'
|
6
|
+
require 'betradar/api/booking_calendar'
|
7
|
+
require 'betradar/api/odds_recover'
|
8
|
+
require 'betradar/api/sport_event_information'
|
9
|
+
require 'betradar/request'
|
10
|
+
require 'betradar/client'
|
11
|
+
require 'betradar/error'
|
@@ -0,0 +1,47 @@
|
|
1
|
+
module Api
|
2
|
+
module BettingDescriptions
|
3
|
+
# Market descriptions
|
4
|
+
# Defines all currently available markets xml schema
|
5
|
+
def market_descriptions(mapping = true)
|
6
|
+
get("descriptions/en/markets.xml?include_mappings=#{mapping}")
|
7
|
+
end
|
8
|
+
|
9
|
+
# Void Reasons
|
10
|
+
# The different reasons for why we void a market. Check void_reason in settlements.
|
11
|
+
def void_reasons
|
12
|
+
get('descriptions/void_reasons.xml')
|
13
|
+
end
|
14
|
+
|
15
|
+
# Betstop descriptions
|
16
|
+
def betstop_descriptions
|
17
|
+
get('descriptions/betstop_reasons.xml')
|
18
|
+
end
|
19
|
+
|
20
|
+
# Betting status
|
21
|
+
def betting_status
|
22
|
+
get('descriptions/betting_status.xml')
|
23
|
+
end
|
24
|
+
|
25
|
+
# Match status
|
26
|
+
# Describes all match statuses.
|
27
|
+
def match_status
|
28
|
+
get('descriptions/en/match_status.xml')
|
29
|
+
end
|
30
|
+
|
31
|
+
# Outcome Reasons
|
32
|
+
def outcome_reasons
|
33
|
+
get('descriptions/outcome_reasons.xml')
|
34
|
+
end
|
35
|
+
|
36
|
+
# Variant Market Descriptions
|
37
|
+
def variant_market_descriptions(market_id, variant_urn, product = nil)
|
38
|
+
product = "#{product}/" if product
|
39
|
+
get("#{product}descriptions/en/markets/#{market_id}/variants/#{variant_urn}")
|
40
|
+
end
|
41
|
+
|
42
|
+
# Available producers
|
43
|
+
def producers
|
44
|
+
get('descriptions/producers.xml')
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Api
|
2
|
+
module EntityDescriptions
|
3
|
+
# Player profile
|
4
|
+
# Defines Name and details about a player
|
5
|
+
def player_profile(player_id)
|
6
|
+
get("sports/en/players/#{player_id}/profile.xml")
|
7
|
+
end
|
8
|
+
|
9
|
+
# Competitor information
|
10
|
+
# Name and details about a competitor
|
11
|
+
def competitor_information(competitor_id)
|
12
|
+
get("sports/en/competitors/#{competitor_id}/profile.xml")
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module Api
|
2
|
+
module OddsRecover
|
3
|
+
# Request recovery since after timestamp
|
4
|
+
# Do recovery of odds and stateful messages over the feed. Subscribes client to feed messages.
|
5
|
+
def recovery_after_timestamp(after, product = 'pre', request_id = -1)
|
6
|
+
post("#{product}/recovery/initiate_request?after=#{after}&request_id=#{request_id}")
|
7
|
+
end
|
8
|
+
|
9
|
+
# Request full odds recovery
|
10
|
+
# Do recovery of odds over the feed. Subscribes client to feed messages.
|
11
|
+
def full_odds_recovery(product = 'pre', request_id = -1)
|
12
|
+
post("#{product}/recovery/initiate_request?request_id=#{request_id}")
|
13
|
+
end
|
14
|
+
|
15
|
+
# Recover sport event
|
16
|
+
# Request to resend all odds for all markets for a sport event.
|
17
|
+
def event_odds(event_id, event_type = 'sr:match', product = 'pre', request_id = -1)
|
18
|
+
post("#{product}/odds/events/#{event_type}:#{event_id}/initiate_request?request_id=#{request_id}")
|
19
|
+
end
|
20
|
+
|
21
|
+
# Recover stateful-messages for a sport event
|
22
|
+
# Request to resend all stateful-messages (BetSettlement, RollbackBetSettlement, BetCancel, UndoBetCancel)
|
23
|
+
# for a sport event.
|
24
|
+
def stateful_messages(event_id, event_type = 'sr:match', product = 'pre', request_id = -1)
|
25
|
+
post("#{product}/stateful_messages/events/#{event_type}:#{event_id}/initiate_request?request_id=#{request_id}")
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Api
|
2
|
+
module Probability
|
3
|
+
# Sport event probabilities
|
4
|
+
# Get probabilities for a sport event.
|
5
|
+
def event_probabilities(event_id, event_type = 'sr:match')
|
6
|
+
get("api.betradar.com/v1/probabilities/#{event_type}:#{event_id}")
|
7
|
+
end
|
8
|
+
|
9
|
+
# Market probabilities
|
10
|
+
def market_probabilities(market_id, event_id, event_type = 'sr:match')
|
11
|
+
get("probabilities/#{event_type}:#{event_id}/#{market_id}")
|
12
|
+
end
|
13
|
+
|
14
|
+
# Market probabilities with specifiers
|
15
|
+
def market_probabilities_with_specifiers(market_id, market_specifier, event_id, event_type = 'sr:match')
|
16
|
+
get("probabilities/#{event_type}:#{event_id}/#{market_id}/#{market_specifier}")
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
module Api
|
2
|
+
module SportEventInformation
|
3
|
+
# Summary information about a sport event
|
4
|
+
def summary(event_id, event_type = 'sr:match')
|
5
|
+
get("sports/en/sport_events/#{event_type}:#{event_id}/summary.xml")
|
6
|
+
end
|
7
|
+
|
8
|
+
# Information about an ongoing sport event
|
9
|
+
# Detailed information (including event timeline) for a sport event.
|
10
|
+
# Prematch, Live or Post-match. Prematch info is very brief .
|
11
|
+
# Postmatch the results are there
|
12
|
+
def event_info(event_id, event_type = 'sr:match')
|
13
|
+
get("sports/en/sport_events/#{event_type}:#{event_id}/timeline.xml")
|
14
|
+
end
|
15
|
+
|
16
|
+
# All available categories for a sport
|
17
|
+
def categories(sport_id)
|
18
|
+
get("sports/en/sports/sr:sport:#{sport_id}/categories.xml")
|
19
|
+
end
|
20
|
+
|
21
|
+
# All available tournaments for a sport
|
22
|
+
def sport_tournaments(sport_id)
|
23
|
+
get("sports/en/sports/sr:sport:#{sport_id}/tournaments.xml")
|
24
|
+
end
|
25
|
+
|
26
|
+
# All available sports
|
27
|
+
def sports
|
28
|
+
get('sports/en/sports.xml')
|
29
|
+
end
|
30
|
+
|
31
|
+
# All available tournaments for all sports
|
32
|
+
def tournaments
|
33
|
+
get('sports/en/tournaments.xml')
|
34
|
+
end
|
35
|
+
|
36
|
+
# Basic information about a tournament (name, start/end date, list of competitors)
|
37
|
+
def tournaments_info(tournament_id, tournament_type = 'sr:tournament')
|
38
|
+
get("sports/en/tournaments/#{tournament_type}:#{tournament_id}/info.xml")
|
39
|
+
end
|
40
|
+
|
41
|
+
# All available seasons for tournament
|
42
|
+
def tournament_season(id, type = 'sr:tournament')
|
43
|
+
get("sports/en/tournaments/#{type}:#{id}/seasons.xml")
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module Api
|
2
|
+
module StaticSportEventInformation
|
3
|
+
# Fixture for a specified sport event
|
4
|
+
def fixture(event_id, event_type = 'sr:match')
|
5
|
+
get("sports/en/sport_events/#{event_type}:#{event_id}/fixture.xml")
|
6
|
+
end
|
7
|
+
|
8
|
+
# All sport events for a specific date
|
9
|
+
def schedules(schedule_date = nil)
|
10
|
+
schedule_date ||= Time.zone.today
|
11
|
+
schedule_date = Time.zone.parse(schedule_date.to_s).to_date.to_s
|
12
|
+
get("sports/en/schedules/#{schedule_date}/schedule.xml")
|
13
|
+
end
|
14
|
+
|
15
|
+
# Currently live sport events
|
16
|
+
def live_schedule
|
17
|
+
get('sports/en/schedules/live/schedule.xml')
|
18
|
+
end
|
19
|
+
|
20
|
+
# Schedule for a tournament
|
21
|
+
def tournament_schedule(tournament_uid)
|
22
|
+
get("sports/en/tournaments/#{tournament_uid}/schedule.xml")
|
23
|
+
end
|
24
|
+
|
25
|
+
# Lists the IDs of all fixtures that have changed in the last 24 hours.
|
26
|
+
def fixture_changes
|
27
|
+
get('sports/en/fixtures/changes.xml')
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Betradar
|
2
|
+
class Client < Request
|
3
|
+
attr_accessor :api_key
|
4
|
+
BASE_URL = 'https://api.betradar.com/v1'.freeze
|
5
|
+
include ::Api::OddsRecover
|
6
|
+
include ::Api::StaticSportEventInformation
|
7
|
+
include ::Api::SportEventInformation
|
8
|
+
include ::Api::BettingDescriptions
|
9
|
+
include ::Api::Probability
|
10
|
+
include ::Api::EntityDescriptions
|
11
|
+
include ::Api::BookingCalendar
|
12
|
+
|
13
|
+
def initialize(api_key)
|
14
|
+
@api_key = api_key
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def request_url(path)
|
20
|
+
"#{BASE_URL}/#{path}"
|
21
|
+
end
|
22
|
+
|
23
|
+
def headers
|
24
|
+
{ "x-access-token": api_key }
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
module Betradar
|
2
|
+
class Error < ::StandardError
|
3
|
+
class << self
|
4
|
+
def errors
|
5
|
+
@errors ||= {
|
6
|
+
400 => Betradar::Error::BadRequest,
|
7
|
+
401 => Betradar::Error::Unauthorized,
|
8
|
+
403 => Betradar::Error::Forbidden,
|
9
|
+
404 => Betradar::Error::NotFound,
|
10
|
+
429 => Betradar::Error::RateLimited,
|
11
|
+
500 => Betradar::Error::InternalServerError,
|
12
|
+
502 => Betradar::Error::ProxyError
|
13
|
+
}
|
14
|
+
end
|
15
|
+
|
16
|
+
def on_complete(response)
|
17
|
+
klass = errors[response.try(:http_code)&.to_i] || Betradar::Error::Unknown
|
18
|
+
fail klass.new(klass.new(response.inspect))
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
# Raised when Betradar returns a 4xx HTTP status code
|
23
|
+
ClientError = Class.new(self)
|
24
|
+
|
25
|
+
# Raised when Betradar returns the HTTP status code 400
|
26
|
+
BadRequest = Class.new(ClientError)
|
27
|
+
|
28
|
+
# Raised when Betradar returns the HTTP status code 401
|
29
|
+
Unauthorized = Class.new(ClientError)
|
30
|
+
|
31
|
+
# Raised when Betradar returns the HTTP status code 403
|
32
|
+
Forbidden = Class.new(ClientError)
|
33
|
+
|
34
|
+
# Raised when Betradar returns the HTTP status code 404
|
35
|
+
NotFound = Class.new(ClientError)
|
36
|
+
|
37
|
+
# Raised when Betradar returns the HTTP status code 429
|
38
|
+
RateLimited = Class.new(ClientError)
|
39
|
+
|
40
|
+
# Raised when Betradar returns a 5xx HTTP status code
|
41
|
+
ServerError = Class.new(self)
|
42
|
+
|
43
|
+
# Raised when Betradar returns the HTTP status code 500
|
44
|
+
InternalServerError = Class.new(ServerError)
|
45
|
+
|
46
|
+
# Raised when Betradar returns the HTTP status code 502
|
47
|
+
ProxyError = Class.new(ServerError)
|
48
|
+
|
49
|
+
# Raised when Betradar returns the HTTP status code 503
|
50
|
+
ServiceUnavailable = Class.new(ServerError)
|
51
|
+
|
52
|
+
# Raised when Betradar returns unknown status code
|
53
|
+
Unknown = Class.new(self)
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'rest-client'
|
2
|
+
require 'ox'
|
3
|
+
module Betradar
|
4
|
+
class Request
|
5
|
+
def get(url)
|
6
|
+
data = RestClient.get(request_url(url), headers)
|
7
|
+
Ox.load(data, mode: :hash)
|
8
|
+
rescue StandardError => e
|
9
|
+
Betradar::Error.on_complete(e)
|
10
|
+
end
|
11
|
+
|
12
|
+
def post(url, params = {})
|
13
|
+
data = RestClient.post(request_url(url), params, headers)
|
14
|
+
Ox.load(data, mode: :hash)
|
15
|
+
rescue StandardError => e
|
16
|
+
Betradar::Error.on_complete(e)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
metadata
ADDED
@@ -0,0 +1,208 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: betradar
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Rahul
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-12-04 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.16'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.16'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: pry
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rest-client
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.8'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1.8'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rspec
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '3.8'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '3.8'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rubocop
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 0.59.2
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 0.59.2
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: vcr
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '4.0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '4.0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: webmock
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '3.4'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '3.4'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: ox
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - "~>"
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '2.10'
|
132
|
+
type: :runtime
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - "~>"
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '2.10'
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: rest-client
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - "~>"
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '1.8'
|
146
|
+
type: :runtime
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - "~>"
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '1.8'
|
153
|
+
description: aesmer test
|
154
|
+
email:
|
155
|
+
- rahulismishra@gmail.com
|
156
|
+
executables: []
|
157
|
+
extensions: []
|
158
|
+
extra_rdoc_files: []
|
159
|
+
files:
|
160
|
+
- ".gitignore"
|
161
|
+
- ".rspec"
|
162
|
+
- ".rubocop.yml"
|
163
|
+
- ".travis.yml"
|
164
|
+
- Gemfile
|
165
|
+
- Gemfile.lock
|
166
|
+
- LICENSE.txt
|
167
|
+
- README.md
|
168
|
+
- Rakefile
|
169
|
+
- betradar.gemspec
|
170
|
+
- bin/console
|
171
|
+
- bin/setup
|
172
|
+
- lib/betradar.rb
|
173
|
+
- lib/betradar/api/betting_descriptions.rb
|
174
|
+
- lib/betradar/api/booking_calendar.rb
|
175
|
+
- lib/betradar/api/entity_description.rb
|
176
|
+
- lib/betradar/api/odds_recover.rb
|
177
|
+
- lib/betradar/api/probability.rb
|
178
|
+
- lib/betradar/api/sport_event_information.rb
|
179
|
+
- lib/betradar/api/static_sport_event_information.rb
|
180
|
+
- lib/betradar/client.rb
|
181
|
+
- lib/betradar/error.rb
|
182
|
+
- lib/betradar/request.rb
|
183
|
+
- lib/betradar/version.rb
|
184
|
+
homepage:
|
185
|
+
licenses:
|
186
|
+
- MIT
|
187
|
+
metadata: {}
|
188
|
+
post_install_message:
|
189
|
+
rdoc_options: []
|
190
|
+
require_paths:
|
191
|
+
- lib
|
192
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
193
|
+
requirements:
|
194
|
+
- - ">="
|
195
|
+
- !ruby/object:Gem::Version
|
196
|
+
version: '0'
|
197
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
198
|
+
requirements:
|
199
|
+
- - ">="
|
200
|
+
- !ruby/object:Gem::Version
|
201
|
+
version: '0'
|
202
|
+
requirements: []
|
203
|
+
rubyforge_project:
|
204
|
+
rubygems_version: 2.7.6
|
205
|
+
signing_key:
|
206
|
+
specification_version: 4
|
207
|
+
summary: aesmer
|
208
|
+
test_files: []
|