CricApi 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CricApi.gemspec +1 -1
- data/Gemfile.lock +1 -1
- data/README.md +119 -4
- data/lib/CricApi.rb +37 -13
- data/lib/CricApi/version.rb +1 -1
- metadata +3 -4
- data/lib/CricApi/helper/request.rb +0 -78
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1b5210a5a0bf710137e733a7766af2fa428eb4f5
|
4
|
+
data.tar.gz: 04ae472b8b1def21c59bbe832af6d8f4b992ab57
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5aabdeb2931194ba2bef3bb70a60226cad3016bddc38ea23583e9072535b265941f7d5be7b9ae1f7bb6aa572f715dfdb9dca9602113035100435c2369304a42f
|
7
|
+
data.tar.gz: 4aa5061cb1bff89c1087ef02e52988e06c33403a99c66ce8be2b80dc15021cc8271008a77588ec51d2098aa87deb60998c3ff9ee7a167d4deb717a8c29aba5c2
|
data/CricApi.gemspec
CHANGED
@@ -12,7 +12,7 @@ Gem::Specification.new do |spec|
|
|
12
12
|
spec.summary = %q{This is a ruby wrapper to access cricapi.com live cricket data}
|
13
13
|
spec.description = %q{This is a ruby wrapper to access cricapi.com live cricket data}
|
14
14
|
spec.homepage = "https://github.com/KarthikGangadhar/CricApi"
|
15
|
-
spec.license = "
|
15
|
+
spec.license = ""
|
16
16
|
|
17
17
|
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
18
18
|
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -22,7 +22,122 @@ Or install it yourself as:
|
|
22
22
|
|
23
23
|
## Usage
|
24
24
|
|
25
|
-
|
25
|
+
The [CricApi](http://www.cricapi.com/), Free to use, super-high bandwidth, high performance Cricket API. Targeted at Developers and Cricket lovers.
|
26
|
+
|
27
|
+
|
28
|
+
In order to use the [CricApi](http://www.cricapi.com/) endpoints, u need to have an api_key which can use generated by signing into [cricapi](http://www.cricapi.com/). For testing purpose can use test_api_key "TESTKEY0273"
|
29
|
+
|
30
|
+
There are five endpoint, Usage is as Follow
|
31
|
+
|
32
|
+
```ruby
|
33
|
+
require 'CricApi'
|
34
|
+
|
35
|
+
api_key = "TESTKEY0273"
|
36
|
+
cricapi = CricApi::Request.new(api_key)
|
37
|
+
```
|
38
|
+
cricket endpoint, Old Match API
|
39
|
+
|
40
|
+
```ruby
|
41
|
+
|
42
|
+
cricapi.cricket
|
43
|
+
# => {
|
44
|
+
"ttl": 2,
|
45
|
+
"v": "1",
|
46
|
+
"cache": true,
|
47
|
+
"data": [
|
48
|
+
{
|
49
|
+
"unique_id": "1122751",
|
50
|
+
"description": "Mid West Rhinos 213/6 * v Mashonaland Eagles 321/10 ",
|
51
|
+
"title": "Mid West Rhinos 213/6 * v Mashonaland Eagles 321/10 "
|
52
|
+
}
|
53
|
+
]
|
54
|
+
}
|
55
|
+
```
|
56
|
+
schedule endpoint, Match Calender
|
57
|
+
|
58
|
+
```ruby
|
59
|
+
|
60
|
+
cricapi.schedule
|
61
|
+
# => {
|
62
|
+
"data": [
|
63
|
+
{
|
64
|
+
"unique_id": "will generate 1-2 days before match",
|
65
|
+
"name": "India v Sri Lanka at Kolkata, 1st Test - day 1",
|
66
|
+
"date": "16 November 2017"
|
67
|
+
},
|
68
|
+
{
|
69
|
+
"unique_id": "will generate 1-2 days before match",
|
70
|
+
"name": "India v Sri Lanka at Kolkata, 1st Test - day 2",
|
71
|
+
"date": "17 November 2017"
|
72
|
+
}
|
73
|
+
]
|
74
|
+
}
|
75
|
+
```
|
76
|
+
|
77
|
+
cricketScore endpoint, This requires a match unique_id, which will be provide by cricket endpoint
|
78
|
+
|
79
|
+
```ruby
|
80
|
+
|
81
|
+
unique_id = "1034809"
|
82
|
+
cricapi.cricketScore(unique_id)
|
83
|
+
# => {
|
84
|
+
"matchStarted": true,
|
85
|
+
"team-1": "England",
|
86
|
+
"team-2": "India",
|
87
|
+
"cache": true,
|
88
|
+
"v": "1",
|
89
|
+
"ttl": 2,
|
90
|
+
"provider": {
|
91
|
+
"source": "Various",
|
92
|
+
"url": "https://cricapi.com/",
|
93
|
+
"pubDate": "2017-11-11T06:24:19.712Z"
|
94
|
+
},
|
95
|
+
}
|
96
|
+
```
|
97
|
+
|
98
|
+
matches endpoint, This requires a match unique_id, which will be provide by cricket endpoint
|
99
|
+
|
100
|
+
```ruby
|
101
|
+
cricapi.matches
|
102
|
+
# => {
|
103
|
+
"matches": [
|
104
|
+
{
|
105
|
+
"unique_id": 1124063,
|
106
|
+
"date": "2017-11-10T00:00:00.000Z",
|
107
|
+
"team-2": "Band-e-Amir Region",
|
108
|
+
"team-1": "Mis Ainak Region",
|
109
|
+
"type": "First-class",
|
110
|
+
"dateTimeGMT": "2017-11-07T04:30:00.000Z",
|
111
|
+
"squad": true,
|
112
|
+
"toss_winner_team": "Band-e-Amir Region",
|
113
|
+
"matchStarted": true
|
114
|
+
}
|
115
|
+
]
|
116
|
+
}
|
117
|
+
```
|
118
|
+
|
119
|
+
playerStats endpoint, This requires a players pid, which will be obtained [here](http://www.cricapi.com/players/)
|
120
|
+
|
121
|
+
```ruby
|
122
|
+
|
123
|
+
pid = "32350"
|
124
|
+
cricapi.playerStats(unique_id)
|
125
|
+
# => {
|
126
|
+
"pid": 35320,
|
127
|
+
"profile": "\n\nSachin Tendulkar has been the most complete batsman of his time, the most prolific runmaker of all time, and arguably the biggest cricket icon the game has ever known. His batting was based on the purest principles: perfect balance, economy of movement, precision in stroke-making, and that intangible quality given only to geniuses - anticipation. If he didn't have a signature stroke - the upright, back-foot punch comes close - it's because he was equally proficient at each of the full range of orthodox shots (and plenty of improvised ones as well) and can pull them out at will. \n\n",
|
128
|
+
"imageURL": "http://cricapi.com/playerpic/35320.jpg",
|
129
|
+
"battingStyle": "Right-hand bat",
|
130
|
+
"bowlingStyle": "Right-arm offbreak, Legbreak googly",
|
131
|
+
"majorTeams": "India,Asia XI,Mumbai,Mumbai Indians,Yorkshire",
|
132
|
+
"currentAge": "44 years 186 days",
|
133
|
+
"born": "April 24, 1973, Bombay (now Mumbai), Maharashtra",
|
134
|
+
"fullName": "Sachin Ramesh Tendulkar",
|
135
|
+
"name": "Sachin Tendulkar",
|
136
|
+
"country": "India",
|
137
|
+
"playingRole": "Top-order batsman"
|
138
|
+
}
|
139
|
+
|
140
|
+
```
|
26
141
|
|
27
142
|
## Development
|
28
143
|
|
@@ -32,12 +147,12 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
32
147
|
|
33
148
|
## Contributing
|
34
149
|
|
35
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
150
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/karthikgangadhar/CricApi. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
36
151
|
|
37
152
|
## License
|
38
153
|
|
39
|
-
The gem is available as open source under the terms of the [
|
154
|
+
The gem is available as open source under the terms of the [License](https://opensource.org/licenses/MIT).
|
40
155
|
|
41
156
|
## Code of Conduct
|
42
157
|
|
43
|
-
Everyone interacting in the CricApi project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[
|
158
|
+
Everyone interacting in the CricApi project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[karthikgangadhar]/CricApi/blob/master/CODE_OF_CONDUCT.md).
|
data/lib/CricApi.rb
CHANGED
@@ -1,30 +1,54 @@
|
|
1
1
|
require "CricApi/version"
|
2
|
-
require "
|
2
|
+
require "hashie"
|
3
|
+
require "httparty"
|
3
4
|
|
4
5
|
module CricApi
|
6
|
+
class Request
|
7
|
+
include HTTParty
|
8
|
+
base_uri 'http://cricapi.com'
|
5
9
|
|
6
|
-
def
|
7
|
-
|
10
|
+
def initialize(key)
|
11
|
+
@options = { query: {site: "cricapi.com", apikey: key } }
|
12
|
+
end
|
13
|
+
|
14
|
+
def cricket
|
15
|
+
response = self.class.get("/api/cricket", @options)
|
16
|
+
cricket = clean_response(response)
|
17
|
+
cricket
|
8
18
|
end
|
9
19
|
|
10
|
-
def
|
11
|
-
|
20
|
+
def matches
|
21
|
+
response = self.class.get("/api/matches", @options)
|
22
|
+
matches = clean_response(response)
|
23
|
+
matches
|
12
24
|
end
|
13
25
|
|
14
|
-
def
|
15
|
-
|
26
|
+
def schedule
|
27
|
+
response = self.class.get("/api/matchCalendar", @options)
|
28
|
+
schedule = clean_response(response)
|
29
|
+
schedule
|
16
30
|
end
|
17
31
|
|
18
|
-
def
|
19
|
-
|
32
|
+
def cricketScore(id)
|
33
|
+
@options[:query][:unique_id] = id
|
34
|
+
response = self.class.post("/api/cricketScore", @options)
|
35
|
+
cricketScore = clean_response(response)
|
36
|
+
cricketScore
|
20
37
|
end
|
21
38
|
|
22
|
-
def
|
23
|
-
|
39
|
+
def playerStats(pid)
|
40
|
+
@options[:query][:pid] = pid
|
41
|
+
response = self.class.post("/api/playerStats", @options)
|
42
|
+
playerStats = clean_response(response)
|
43
|
+
playerStats
|
24
44
|
end
|
25
45
|
|
26
|
-
|
27
|
-
|
46
|
+
private
|
47
|
+
|
48
|
+
def clean_response(response)
|
49
|
+
is_response_present = (response.empty? && response.nil? && response.parsed_response.empty? && response.parsed_response.nil?)
|
50
|
+
is_response_present ? Hashie::Mash.new({ :error => "No data"}) : Hashie::Mash.new( response.parsed_response )
|
28
51
|
end
|
29
52
|
|
30
53
|
end
|
54
|
+
end
|
data/lib/CricApi/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: CricApi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- kgangadhar
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-11-
|
11
|
+
date: 2017-11-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|
@@ -100,13 +100,12 @@ files:
|
|
100
100
|
- bin/console
|
101
101
|
- bin/setup
|
102
102
|
- lib/CricApi.rb
|
103
|
-
- lib/CricApi/helper/request.rb
|
104
103
|
- lib/CricApi/version.rb
|
105
104
|
- tasks/debug.rake
|
106
105
|
- tasks/rspec.rake
|
107
106
|
homepage: https://github.com/KarthikGangadhar/CricApi
|
108
107
|
licenses:
|
109
|
-
-
|
108
|
+
- ''
|
110
109
|
metadata: {}
|
111
110
|
post_install_message:
|
112
111
|
rdoc_options: []
|
@@ -1,78 +0,0 @@
|
|
1
|
-
require 'httparty'
|
2
|
-
require 'json'
|
3
|
-
|
4
|
-
module Cricket
|
5
|
-
class Request
|
6
|
-
include HTTParty
|
7
|
-
base_uri 'https://apecricket.herokuapp.com'
|
8
|
-
|
9
|
-
def initialize(service, page)
|
10
|
-
@options = { query: {site: service, page: page} }
|
11
|
-
end
|
12
|
-
|
13
|
-
def cricket
|
14
|
-
self.class.get("/api/cricket", @options)
|
15
|
-
end
|
16
|
-
|
17
|
-
def matches
|
18
|
-
self.class.get("/api/matches", @options)
|
19
|
-
end
|
20
|
-
|
21
|
-
def matchCalendar
|
22
|
-
self.class.get("/api/matchCalendar", @options)
|
23
|
-
end
|
24
|
-
|
25
|
-
def getNews
|
26
|
-
self.class.get("/api/news", @options)
|
27
|
-
end
|
28
|
-
|
29
|
-
def cricketScore(id)
|
30
|
-
self.class.post("/api/cricketScore",
|
31
|
-
:body => {
|
32
|
-
:unique_id => id
|
33
|
-
}
|
34
|
-
)
|
35
|
-
end
|
36
|
-
|
37
|
-
def playerStats(id)
|
38
|
-
self.class.post("/api/playerStats",
|
39
|
-
:body => {
|
40
|
-
:pid => id
|
41
|
-
}
|
42
|
-
)
|
43
|
-
end
|
44
|
-
|
45
|
-
def ballByball(id)
|
46
|
-
self.class.post("/api/ballByBall",
|
47
|
-
:body => {
|
48
|
-
:unique_id => id
|
49
|
-
}
|
50
|
-
)
|
51
|
-
end
|
52
|
-
|
53
|
-
def commentry(id)
|
54
|
-
self.class.post("/api/commentry",
|
55
|
-
:body => {
|
56
|
-
:unique_id => id
|
57
|
-
}
|
58
|
-
)
|
59
|
-
end
|
60
|
-
|
61
|
-
def news(id)
|
62
|
-
self.class.post("/api/news",
|
63
|
-
:body => {
|
64
|
-
:unique_id => id
|
65
|
-
}
|
66
|
-
)
|
67
|
-
end
|
68
|
-
|
69
|
-
def score(id)
|
70
|
-
self.class.post("/api/score",
|
71
|
-
:body => {
|
72
|
-
:unique_id => id
|
73
|
-
}
|
74
|
-
)
|
75
|
-
end
|
76
|
-
|
77
|
-
end
|
78
|
-
end
|