CricApi 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1b5210a5a0bf710137e733a7766af2fa428eb4f5
4
- data.tar.gz: 04ae472b8b1def21c59bbe832af6d8f4b992ab57
3
+ metadata.gz: 80ee3c50b616d6210699df38377105580b46510d
4
+ data.tar.gz: b76ac480ac496dc1f4dc37490e54e7e016502b0e
5
5
  SHA512:
6
- metadata.gz: 5aabdeb2931194ba2bef3bb70a60226cad3016bddc38ea23583e9072535b265941f7d5be7b9ae1f7bb6aa572f715dfdb9dca9602113035100435c2369304a42f
7
- data.tar.gz: 4aa5061cb1bff89c1087ef02e52988e06c33403a99c66ce8be2b80dc15021cc8271008a77588ec51d2098aa87deb60998c3ff9ee7a167d4deb717a8c29aba5c2
6
+ metadata.gz: c04db05e16174d9346cced2280bbb574af60d6861f3e486c77f4bb11596cf2d8f28f571c0f7db114e97a037061eb17c6f6b2b558d2a795987ca6cc2825d555e4
7
+ data.tar.gz: 311080451c9f68e047113bf1812fea71646d7864827a25c4a1acb03e9d7c7e047131fb853f32962e1dfeae4f575b5946845fbab05cf3b4ce83528b6aa04095b5
@@ -9,10 +9,10 @@ Gem::Specification.new do |spec|
9
9
  spec.authors = ["kgangadhar"]
10
10
  spec.email = ["karthikg1643@gmail.com"]
11
11
 
12
- spec.summary = %q{This is a ruby wrapper to access cricapi.com live cricket data}
13
- spec.description = %q{This is a ruby wrapper to access cricapi.com live cricket data}
12
+ spec.summary = %q{Welcome to cric-api. The live cricket score, player statistics and fantasy scorecard API allow you to get API data anytime, 24x7 at your fingertips. It's extremely simple, easy to use - with a huge collection of examples.}
13
+ spec.description = %q{Welcome to cric-api. The live cricket score, player statistics and fantasy scorecard API allow you to get API data anytime, 24x7 at your fingertips. It's extremely simple, easy to use - with a huge collection of examples.}
14
14
  spec.homepage = "https://github.com/KarthikGangadhar/CricApi"
15
- spec.license = ""
15
+ spec.license = "none"
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.
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- CricApi (0.2.0)
4
+ CricApi (0.2.1)
5
5
  hashie
6
6
  httparty
7
7
 
data/README.md CHANGED
@@ -1,8 +1,6 @@
1
1
  # CricApi
2
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/CricApi`. To experiment with that code, run `bin/console` for an interactive prompt.
4
-
5
- Delete this and the text above, and describe your gem
3
+ Welcome to cric-api. The live cricket score, player statistics and fantasy scorecard API allow you to get API data anytime, 24x7 at your fingertips. It's extremely simple, easy to use - with a huge collection of examples.
6
4
 
7
5
  ## Installation
8
6
 
@@ -27,7 +25,7 @@ The [CricApi](http://www.cricapi.com/), Free to use, super-high bandwidth, high
27
25
 
28
26
  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
27
 
30
- There are five endpoint, Usage is as Follow
28
+ There are 7 endpoints, Usage is as Follow
31
29
 
32
30
  ```ruby
33
31
  require 'CricApi'
@@ -35,92 +33,94 @@ There are five endpoint, Usage is as Follow
35
33
  api_key = "TESTKEY0273"
36
34
  cricapi = CricApi::Request.new(api_key)
37
35
  ```
38
- cricket endpoint, Old Match API
36
+ #### cricket endpoint, Old Match API ####
39
37
 
40
38
  ```ruby
41
39
 
42
40
  cricapi.cricket
43
41
  # => {
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
- ]
42
+ "ttl": 2,
43
+ "v": "1",
44
+ "cache": true,
45
+ "data": [
46
+ {
47
+ "unique_id": "1122751",
48
+ "description": "Mid West Rhinos 213/6 * v Mashonaland Eagles 321/10 ",
49
+ "title": "Mid West Rhinos 213/6 * v Mashonaland Eagles 321/10 "
50
+ }
51
+ ]
54
52
  }
55
53
  ```
56
- schedule endpoint, Match Calender
54
+ #### schedule endpoint, Match Calender ####
57
55
 
58
56
  ```ruby
59
57
 
60
58
  cricapi.schedule
61
59
  # => {
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
- ]
60
+ "data": [
61
+ {
62
+ "unique_id": "will generate 1-2 days before match",
63
+ "name": "India v Sri Lanka at Kolkata, 1st Test - day 1",
64
+ "date": "16 November 2017"
65
+ },
66
+ {
67
+ "unique_id": "will generate 1-2 days before match",
68
+ "name": "India v Sri Lanka at Kolkata, 1st Test - day 2",
69
+ "date": "17 November 2017"
70
+ }
71
+ ]
74
72
  }
75
73
  ```
76
74
 
77
- cricketScore endpoint, This requires a match unique_id, which will be provide by cricket endpoint
75
+ #### cricketScore endpoint,
76
+ This requires a match unique_id, which will be provide by cricket endpoint
78
77
 
79
78
  ```ruby
80
79
 
81
- unique_id = "1034809"
80
+ unique_id = "1034809"
82
81
  cricapi.cricketScore(unique_id)
83
82
  # => {
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
- }
83
+ "matchStarted": true,
84
+ "team-1": "England",
85
+ "team-2": "India",
86
+ "cache": true,
87
+ "v": "1",
88
+ "ttl": 2,
89
+ "provider": {
90
+ "source": "Various",
91
+ "url": "https://cricapi.com/",
92
+ "pubDate": "2017-11-11T06:24:19.712Z"
93
+ },
94
+ }
96
95
  ```
97
96
 
98
- matches endpoint, This requires a match unique_id, which will be provide by cricket endpoint
99
-
97
+ #### matches endpoint ####
98
+
100
99
  ```ruby
101
100
  cricapi.matches
102
101
  # => {
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
- ]
102
+ "matches": [
103
+ {
104
+ "unique_id": 1124063,
105
+ "date": "2017-11-10T00:00:00.000Z",
106
+ "team-2": "Band-e-Amir Region",
107
+ "team-1": "Mis Ainak Region",
108
+ "type": "First-class",
109
+ "dateTimeGMT": "2017-11-07T04:30:00.000Z",
110
+ "squad": true,
111
+ "toss_winner_team": "Band-e-Amir Region",
112
+ "matchStarted": true
113
+ }
114
+ ]
116
115
  }
117
116
  ```
118
117
 
119
- playerStats endpoint, This requires a players pid, which will be obtained [here](http://www.cricapi.com/players/)
118
+ #### playerStats endpoint,
119
+ This requires a players pid, which will be obtained [here](http://www.cricapi.com/players/)
120
120
 
121
121
  ```ruby
122
122
 
123
- pid = "32350"
123
+ pid = "32350"
124
124
  cricapi.playerStats(unique_id)
125
125
  # => {
126
126
  "pid": 35320,
@@ -139,6 +139,119 @@ playerStats endpoint, This requires a players pid, which will be obtained [here]
139
139
 
140
140
  ```
141
141
 
142
+ The remaining 2 are Fantasy API endpoints, Fantasy API are billable since they're designed to help you generate income by running Fantasy Cricket portals. Each hit is 1 credit. You get 250 credits free. Deducted from your prepaid account.
143
+
144
+ #### fantasySummary endpoint,
145
+ This requires a match unique_id, which will be provide by cricket endpoint
146
+
147
+ ```ruby
148
+
149
+ unique_id = "1034809"
150
+ cricapi.fantasySummary(unique_id)
151
+ # =>
152
+ #Array of teams of the format:
153
+ {
154
+ "team": [{
155
+ "name": "Gloucestershire",
156
+ "players": [{ // active batsmen/bowlers/fielders only
157
+ "pid": "298564",
158
+ "name": "WA Tavare"
159
+ }, ... ]
160
+ }, {
161
+ "name": "Leicestershire",
162
+ "players: [...]
163
+ }]
164
+ }
165
+
166
+ #Inning-wise, Player-wise array of Batting scores of the format:
167
+
168
+ [{
169
+ "title": "Gloucestershire 1st innings",
170
+ "scores": [
171
+ [{
172
+ "pid": "298564", // -----------------> Use this with playerStats CricAPI for more info
173
+ "batsman": "WA Tavare",
174
+ "dismissal-info": "c Cosgrove b Jones",
175
+ "R": "7", // -----------------> Runs
176
+ "M": "14", // -----------------> Minutes Batted
177
+ "B": "13", // -----------------> Balls Played
178
+ "4s": "1", // -----------------> FOURs hit
179
+ "6s": "0", // -----------------> SIXes hit
180
+ "SR": "53.84" // -----------------> Strike Rate / 100 Balls
181
+ }, ... ]
182
+ ]
183
+ }, {
184
+ "title": "Gloucestershire 2nd innings",
185
+ "scores": [ ... ]
186
+ }, ...]
187
+
188
+ #Inning-wise, Player-wise array of Bowling scores of the format:
189
+
190
+ [{
191
+ "title": "Bowling",
192
+ "scores": [
193
+ [{
194
+ "pid": "6903", // -----------------> Use this with playerStats CricAPI for more info
195
+ "bowler": "CJ McKay",
196
+ "O": "11", // -----------------> Overs bowled (decimal value)
197
+ "M": "1", // -----------------> Maidens bowled
198
+ "R": "42", // -----------------> Runs conceded
199
+ "W": "1", // -----------------> Wickets taken
200
+ "Econ": "3.81", // -----------------> Economy of runs per 6 balls
201
+ "0s": "48" // -----------------> Dot balls bowled
202
+ }, ... ]
203
+ ]
204
+ }, {
205
+ "title": "Bowling",
206
+ "scores": [ ... ]
207
+ }, ...]
208
+
209
+ #Inning-wise, Player-wise array of Fielding scores of the format:
210
+
211
+ [{
212
+ "title": "Fielding",
213
+ "scores": [
214
+ [{
215
+ "pid": "6903", // -----------------> Use this with playerStats CricAPI for more info
216
+ "name": "CJ McKay",
217
+ "catch": 3, // -----------------> Catches
218
+ "lbw": 4, // -----------------> LBWs
219
+ "stumped": 2, // -----------------> Stumped
220
+ "bowled": 0 // -----------------> Bowled
221
+ }, ... ]
222
+ ]
223
+ }, {
224
+ "title": "Fielding",
225
+ "scores": [ ... ]
226
+ }, ...]
227
+
228
+
229
+ ```
230
+
231
+ #### playerFinder endpoint
232
+ This takes player name as input
233
+
234
+ ```ruby
235
+
236
+ name = "Tendulkar"
237
+ cricapi.fantasySquad(name)
238
+ # =>
239
+ #Array of players in the format:
240
+
241
+ {
242
+ "data": [
243
+ {
244
+ "pid": 35320,
245
+ "fullName": "Sachin Ramesh Tendulkar",
246
+ "name": "Sachin Tendulkar"
247
+ }
248
+ ]
249
+ }
250
+
251
+
252
+ ```
253
+
254
+
142
255
  ## Development
143
256
 
144
257
  After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
@@ -43,11 +43,25 @@ module CricApi
43
43
  playerStats
44
44
  end
45
45
 
46
+ def fantasySummary(unique_id)
47
+ @options[:query][:unique_id] = unique_id
48
+ response = self.class.post("/api/fantasySummary", @options)
49
+ summary = clean_response(response)
50
+ summary
51
+ end
52
+
53
+ def playerFinder(name)
54
+ @options[:query][:name] = name
55
+ response = self.class.post("/api/playerFinder", @options)
56
+ player = clean_response(response)
57
+ player
58
+ end
59
+
46
60
  private
47
61
 
48
62
  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 )
63
+ response_not_present = (response.empty? && response.nil? && response.parsed_response.empty? && response.parsed_response.nil?)
64
+ response_not_present ? Hashie::Mash.new({ :error => "No data"}) : Hashie::Mash.new( response.parsed_response )
51
65
  end
52
66
 
53
67
  end
@@ -1,3 +1,3 @@
1
1
  module CricApi
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
3
3
  end
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.2.0
4
+ version: 0.2.1
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 00:00:00.000000000 Z
11
+ date: 2017-11-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -80,7 +80,9 @@ dependencies:
80
80
  - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
- description: This is a ruby wrapper to access cricapi.com live cricket data
83
+ description: Welcome to cric-api. The live cricket score, player statistics and fantasy
84
+ scorecard API allow you to get API data anytime, 24x7 at your fingertips. It's extremely
85
+ simple, easy to use - with a huge collection of examples.
84
86
  email:
85
87
  - karthikg1643@gmail.com
86
88
  executables: []
@@ -105,7 +107,7 @@ files:
105
107
  - tasks/rspec.rake
106
108
  homepage: https://github.com/KarthikGangadhar/CricApi
107
109
  licenses:
108
- - ''
110
+ - none
109
111
  metadata: {}
110
112
  post_install_message:
111
113
  rdoc_options: []
@@ -126,5 +128,7 @@ rubyforge_project:
126
128
  rubygems_version: 2.4.3
127
129
  signing_key:
128
130
  specification_version: 4
129
- summary: This is a ruby wrapper to access cricapi.com live cricket data
131
+ summary: Welcome to cric-api. The live cricket score, player statistics and fantasy
132
+ scorecard API allow you to get API data anytime, 24x7 at your fingertips. It's extremely
133
+ simple, easy to use - with a huge collection of examples.
130
134
  test_files: []