lsports 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.rspec +1 -0
- data/.rubocop.yml +39 -0
- data/Gemfile +4 -0
- data/README.md +29 -0
- data/lib/lsports.rb +8 -0
- data/lib/lsports/api/prematch.rb +59 -0
- data/lib/lsports/api/reference.rb +60 -0
- data/lib/lsports/client.rb +29 -0
- data/lib/lsports/error.rb +33 -0
- data/lib/lsports/request.rb +13 -0
- data/lib/lsports/version.rb +5 -0
- data/lsports.gemspec +34 -0
- metadata +165 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 1c202505a3a984a44850901b6fbb582d1ee0347d78c1f46e54e1ccdd19cb9f43
|
4
|
+
data.tar.gz: 7d813f1024f23bb1fa47eccb553d4584df67ce171850dff7fdb01bc39a392f34
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 9f1b60e7d752799a061ef7e8fcf79779a34814378fdb7f33fa31c5f6e54bbda6884c4345dfdb3f0307c3b0f7a16a8a4bb14e8b4c3e58415050dc37cc183f2a5b
|
7
|
+
data.tar.gz: 29b56d3116b807120abeef8a262e362685c651535c00a1c880a39f75181bdf6e36c68f154adeaeedc840309875e3da8e200ef0086ca563386e0110a7812c839e
|
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--require spec_helper
|
data/.rubocop.yml
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
AllCops:
|
2
|
+
TargetRubyVersion: 2.5.1
|
3
|
+
|
4
|
+
|
5
|
+
Layout/ParameterAlignment:
|
6
|
+
EnforcedStyle: with_fixed_indentation
|
7
|
+
|
8
|
+
Metrics/AbcSize:
|
9
|
+
Max: 20
|
10
|
+
|
11
|
+
Metrics/BlockLength:
|
12
|
+
Exclude:
|
13
|
+
- spec/**/*.rb
|
14
|
+
|
15
|
+
Layout/LineLength:
|
16
|
+
Max: 120
|
17
|
+
IgnoreCopDirectives: true
|
18
|
+
|
19
|
+
Metrics/MethodLength:
|
20
|
+
Max: 20
|
21
|
+
|
22
|
+
|
23
|
+
Style/ClassAndModuleChildren:
|
24
|
+
Enabled: false
|
25
|
+
|
26
|
+
Style/Documentation:
|
27
|
+
Enabled: false
|
28
|
+
|
29
|
+
Style/FrozenStringLiteralComment:
|
30
|
+
Enabled: false
|
31
|
+
|
32
|
+
Style/HashEachMethods:
|
33
|
+
Enabled: true
|
34
|
+
|
35
|
+
Style/HashTransformKeys:
|
36
|
+
Enabled: true
|
37
|
+
|
38
|
+
Style/HashTransformValues:
|
39
|
+
Enabled: true
|
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# RTS Ruby Wrapper
|
2
|
+
|
3
|
+
|
4
|
+
## Installation
|
5
|
+
|
6
|
+
Add this line to your application's Gemfile:
|
7
|
+
|
8
|
+
```ruby
|
9
|
+
gem 'lsports'
|
10
|
+
```
|
11
|
+
|
12
|
+
And then execute:
|
13
|
+
|
14
|
+
$ bundle
|
15
|
+
|
16
|
+
Or install it yourself as:
|
17
|
+
|
18
|
+
$ gem install lsports
|
19
|
+
|
20
|
+
## Usage
|
21
|
+
|
22
|
+
|
23
|
+
## Contributing
|
24
|
+
|
25
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/rmishra-ror/lsports-ruby.
|
26
|
+
|
27
|
+
## License
|
28
|
+
|
29
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/lib/lsports.rb
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Api
|
4
|
+
module Prematch
|
5
|
+
# FIXTURES
|
6
|
+
# Get list of all the fixtures
|
7
|
+
# GET /GetFixtures{?lang, timestamp, fromdate, todate, indent, sports, locations, leagues, fixtures}
|
8
|
+
# Parameters
|
9
|
+
# Name: Description
|
10
|
+
# lang: Response content language. Default value: English
|
11
|
+
# timestamp: Response will contain content that was updated after given timestamp
|
12
|
+
# fromdate: Response will contain content that was updated after given timestamp
|
13
|
+
# todate: Response will contain events which start before given date
|
14
|
+
# indent: Response content will be indented
|
15
|
+
# sports: Comma separated list of sports
|
16
|
+
# locations: Comma separated list of locations
|
17
|
+
# leagues: Comma separated list of leagues
|
18
|
+
# fixtures: Comma separated list of fixtures
|
19
|
+
def fixtures(params = {})
|
20
|
+
get("GetFixtures", params: params)
|
21
|
+
end
|
22
|
+
|
23
|
+
# FIXTURE MARKETS
|
24
|
+
# Get list of all the fixture markets
|
25
|
+
# GET /GetFixtureMarkets{?lang, timestamp, fromdate, todate, indent, sports, locations, leagues, markets}
|
26
|
+
# Parameters
|
27
|
+
# Name: Description
|
28
|
+
# lang: Response content language. Default value: English
|
29
|
+
# timestamp: Response will contain content that was updated after given timestamp
|
30
|
+
# fromdate: Response will contain content that was updated after given timestamp
|
31
|
+
# todate: Response will contain events which start before given date
|
32
|
+
# indent: Response content will be indented
|
33
|
+
# sports: Comma separated list of sports
|
34
|
+
# locations: Comma separated list of locations
|
35
|
+
# leagues: Comma separated list of leagues
|
36
|
+
# markets: Comma separated list of markets
|
37
|
+
def fixture_markets(params = {})
|
38
|
+
get("GetFixtureMarkets", params: params)
|
39
|
+
end
|
40
|
+
|
41
|
+
# EVENTS
|
42
|
+
# Get list of all the events
|
43
|
+
# GET /GetEvents{?lang, timestamp, fromdate, todate, indent, sports, locations, leagues, markets}
|
44
|
+
# Parameters
|
45
|
+
# Name: Description
|
46
|
+
# lang: Response content language. Default value: English
|
47
|
+
# timestamp: Response will contain content that was updated after given timestamp
|
48
|
+
# fromdate: Response will contain content that was updated after given timestamp
|
49
|
+
# todate: Response will contain events which start before given date
|
50
|
+
# indent: Response content will be indented
|
51
|
+
# sports: Comma separated list of sports
|
52
|
+
# locations: Comma separated list of locations
|
53
|
+
# leagues: Comma separated list of leagues
|
54
|
+
# markets: Comma separated list of markets
|
55
|
+
def events(params = {})
|
56
|
+
get("GetEvents", params: params)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Api
|
4
|
+
module Reference
|
5
|
+
# SPORTS
|
6
|
+
# Get list of all the sports
|
7
|
+
# GET /GetSports{?lang, indent}
|
8
|
+
# Parameters
|
9
|
+
# Name: Description
|
10
|
+
# lang: Response content language. Default value: English
|
11
|
+
# indent: Response content will be indented
|
12
|
+
def sports(params = {})
|
13
|
+
get("GetSports", params: params)
|
14
|
+
end
|
15
|
+
|
16
|
+
# LOCATIONS
|
17
|
+
# Get list of all the locations
|
18
|
+
# GET /GetLocations{?lang, indent}
|
19
|
+
# Parameters
|
20
|
+
# Name: Description
|
21
|
+
# lang: Response content language. Default value: English
|
22
|
+
# indent: Response content will be indented
|
23
|
+
def locations(params = {})
|
24
|
+
get("GetLocations", params: params)
|
25
|
+
end
|
26
|
+
|
27
|
+
# LEAGUES
|
28
|
+
# Get list of all the leagues
|
29
|
+
# GET /GetLeagues{?lang, indent}
|
30
|
+
# Parameters
|
31
|
+
# Name: Description
|
32
|
+
# lang: Response content language. Default value: English
|
33
|
+
# indent: Response content will be indented
|
34
|
+
def leagues(params = {})
|
35
|
+
get("GetLeagues", params: params)
|
36
|
+
end
|
37
|
+
|
38
|
+
# BOOKMAKERS
|
39
|
+
# Get list of all the bookmakers
|
40
|
+
# GET /GetBookmakers{?lang, indent}
|
41
|
+
# Parameters
|
42
|
+
# Name: Description
|
43
|
+
# lang: Response content language. Default value: English
|
44
|
+
# indent: Response content will be indented
|
45
|
+
def bookmakers(params = {})
|
46
|
+
get("GetBookmakers", params: params)
|
47
|
+
end
|
48
|
+
|
49
|
+
# MARKETS
|
50
|
+
# Get list of all the markets
|
51
|
+
# GET /GetMarkets{?lang, indent}
|
52
|
+
# Parameters
|
53
|
+
# Name: Description
|
54
|
+
# lang: Response content language. Default value: English
|
55
|
+
# indent: Response content will be indented
|
56
|
+
def markets(params = {})
|
57
|
+
get("GetMarkets", params: params)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
|
4
|
+
module LSports
|
5
|
+
class Client < Request
|
6
|
+
attr_accessor :username, :password, :guid
|
7
|
+
BASE_URL = 'https://prematch.lsports.eu/OddService'
|
8
|
+
include ::Api::Reference
|
9
|
+
include ::Api::Prematch
|
10
|
+
|
11
|
+
def initialize(username:, password:, guid:)
|
12
|
+
@username = username
|
13
|
+
@password = password
|
14
|
+
@guid = guid
|
15
|
+
end
|
16
|
+
|
17
|
+
def request_url(path)
|
18
|
+
"#{BASE_URL}/#{path}"
|
19
|
+
end
|
20
|
+
|
21
|
+
def query_params(query)
|
22
|
+
{ params: params.merge(query) }
|
23
|
+
end
|
24
|
+
|
25
|
+
def params
|
26
|
+
{ username: username, password: password, guid: guid }
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module LSports
|
4
|
+
class Error < ::StandardError
|
5
|
+
class << self
|
6
|
+
def errors
|
7
|
+
@errors ||= {
|
8
|
+
400 => LSports::Error::BadRequest,
|
9
|
+
404 => LSports::Error::NotFound
|
10
|
+
}
|
11
|
+
end
|
12
|
+
|
13
|
+
def on_complete(response)
|
14
|
+
klass = errors[response.http_code&.to_i] || LSports::Error::Unknown
|
15
|
+
request = response.response&.request.inspect
|
16
|
+
raise klass.new({ code: response.http_code, body: response.http_body,
|
17
|
+
request: request })
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
# Raised when LSports returns a 4xx HTTP status code
|
22
|
+
ClientError = Class.new(self)
|
23
|
+
|
24
|
+
# Raised when LSports returns the HTTP status code 400
|
25
|
+
BadRequest = Class.new(ClientError)
|
26
|
+
|
27
|
+
# Raised when LSports returns the HTTP status code 404
|
28
|
+
NotFound = Class.new(ClientError)
|
29
|
+
|
30
|
+
# Raised when LSports returns unknown status code
|
31
|
+
Unknown = Class.new(self)
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'rest-client'
|
4
|
+
require 'json'
|
5
|
+
module LSports
|
6
|
+
class Request
|
7
|
+
def get(url, params: {})
|
8
|
+
JSON.parse RestClient.get(request_url(url), query_params(params))
|
9
|
+
rescue RestClient::Exception => e
|
10
|
+
LSports::Error.on_complete(e)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
data/lsports.gemspec
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
lib = File.expand_path('lib', __dir__)
|
4
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
+
require 'lsports/version'
|
6
|
+
|
7
|
+
Gem::Specification.new do |spec|
|
8
|
+
spec.name = 'lsports'
|
9
|
+
spec.version = LSports::VERSION
|
10
|
+
spec.authors = ['Rahul']
|
11
|
+
spec.email = ['rahulismishra@gmail.com']
|
12
|
+
spec.summary = 'A Ruby interface to the Lsports API.'
|
13
|
+
spec.description = 'A Ruby interface to the Lsports API.'
|
14
|
+
# spec.homepage = 'https://github.com/rmishra-ror/rts'
|
15
|
+
spec.license = 'MIT'
|
16
|
+
|
17
|
+
# Specify which files should be added to the gem when it is released.
|
18
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
19
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
20
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
21
|
+
end
|
22
|
+
spec.bindir = 'exe'
|
23
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
24
|
+
spec.require_paths = ['lib']
|
25
|
+
|
26
|
+
spec.add_development_dependency 'bundler', '~> 1.17', '>= 1.17.3'
|
27
|
+
spec.add_development_dependency 'pry'
|
28
|
+
spec.add_development_dependency 'rake', '~> 13.0'
|
29
|
+
spec.add_development_dependency 'rspec', '~> 3.8'
|
30
|
+
spec.add_development_dependency 'vcr', '~> 4.0'
|
31
|
+
spec.add_development_dependency 'webmock', '~> 3.4'
|
32
|
+
|
33
|
+
spec.add_runtime_dependency 'rest-client', '~> 2.1', '>= 2.1.0'
|
34
|
+
end
|
metadata
ADDED
@@ -0,0 +1,165 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: lsports
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Rahul
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2020-04-27 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.17'
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 1.17.3
|
23
|
+
type: :development
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - "~>"
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '1.17'
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 1.17.3
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: pry
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - ">="
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '0'
|
40
|
+
type: :development
|
41
|
+
prerelease: false
|
42
|
+
version_requirements: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - ">="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '0'
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: rake
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - "~>"
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '13.0'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - "~>"
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '13.0'
|
61
|
+
- !ruby/object:Gem::Dependency
|
62
|
+
name: rspec
|
63
|
+
requirement: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - "~>"
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '3.8'
|
68
|
+
type: :development
|
69
|
+
prerelease: false
|
70
|
+
version_requirements: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - "~>"
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '3.8'
|
75
|
+
- !ruby/object:Gem::Dependency
|
76
|
+
name: vcr
|
77
|
+
requirement: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - "~>"
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '4.0'
|
82
|
+
type: :development
|
83
|
+
prerelease: false
|
84
|
+
version_requirements: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - "~>"
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '4.0'
|
89
|
+
- !ruby/object:Gem::Dependency
|
90
|
+
name: webmock
|
91
|
+
requirement: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - "~>"
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: '3.4'
|
96
|
+
type: :development
|
97
|
+
prerelease: false
|
98
|
+
version_requirements: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - "~>"
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '3.4'
|
103
|
+
- !ruby/object:Gem::Dependency
|
104
|
+
name: rest-client
|
105
|
+
requirement: !ruby/object:Gem::Requirement
|
106
|
+
requirements:
|
107
|
+
- - ">="
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: 2.1.0
|
110
|
+
- - "~>"
|
111
|
+
- !ruby/object:Gem::Version
|
112
|
+
version: '2.1'
|
113
|
+
type: :runtime
|
114
|
+
prerelease: false
|
115
|
+
version_requirements: !ruby/object:Gem::Requirement
|
116
|
+
requirements:
|
117
|
+
- - ">="
|
118
|
+
- !ruby/object:Gem::Version
|
119
|
+
version: 2.1.0
|
120
|
+
- - "~>"
|
121
|
+
- !ruby/object:Gem::Version
|
122
|
+
version: '2.1'
|
123
|
+
description: A Ruby interface to the Lsports API.
|
124
|
+
email:
|
125
|
+
- rahulismishra@gmail.com
|
126
|
+
executables: []
|
127
|
+
extensions: []
|
128
|
+
extra_rdoc_files: []
|
129
|
+
files:
|
130
|
+
- ".rspec"
|
131
|
+
- ".rubocop.yml"
|
132
|
+
- Gemfile
|
133
|
+
- README.md
|
134
|
+
- lib/lsports.rb
|
135
|
+
- lib/lsports/api/prematch.rb
|
136
|
+
- lib/lsports/api/reference.rb
|
137
|
+
- lib/lsports/client.rb
|
138
|
+
- lib/lsports/error.rb
|
139
|
+
- lib/lsports/request.rb
|
140
|
+
- lib/lsports/version.rb
|
141
|
+
- lsports.gemspec
|
142
|
+
homepage:
|
143
|
+
licenses:
|
144
|
+
- MIT
|
145
|
+
metadata: {}
|
146
|
+
post_install_message:
|
147
|
+
rdoc_options: []
|
148
|
+
require_paths:
|
149
|
+
- lib
|
150
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
151
|
+
requirements:
|
152
|
+
- - ">="
|
153
|
+
- !ruby/object:Gem::Version
|
154
|
+
version: '0'
|
155
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - ">="
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: '0'
|
160
|
+
requirements: []
|
161
|
+
rubygems_version: 3.0.3
|
162
|
+
signing_key:
|
163
|
+
specification_version: 4
|
164
|
+
summary: A Ruby interface to the Lsports API.
|
165
|
+
test_files: []
|