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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a6aabd14ad812f282db2de9aa4926f481be1409d
4
- data.tar.gz: eeedd5d736fc4d4255dd21909407bafc0d747c11
3
+ metadata.gz: 1b5210a5a0bf710137e733a7766af2fa428eb4f5
4
+ data.tar.gz: 04ae472b8b1def21c59bbe832af6d8f4b992ab57
5
5
  SHA512:
6
- metadata.gz: 7dd60df6a3eb72885fc6b1ea0529724888a1d5ef83945582dc488c759ecef6dd0a7e57bdd781deaad9d7c21084ff3e4ed9c990e5630b62af43f96d7f76d0b544
7
- data.tar.gz: 7a268f5ebdec90d0efe4139ecf7ca12afadeec187bedb8b219afbea1c32dbe49aa6406fe3206568e963e1bd8097f81b5e2dc60e398c5bb4c0f9f6edfbb888fb3
6
+ metadata.gz: 5aabdeb2931194ba2bef3bb70a60226cad3016bddc38ea23583e9072535b265941f7d5be7b9ae1f7bb6aa572f715dfdb9dca9602113035100435c2369304a42f
7
+ data.tar.gz: 4aa5061cb1bff89c1087ef02e52988e06c33403a99c66ce8be2b80dc15021cc8271008a77588ec51d2098aa87deb60998c3ff9ee7a167d4deb717a8c29aba5c2
@@ -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 = "MIT"
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.
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- CricApi (0.1.0)
4
+ CricApi (0.2.0)
5
5
  hashie
6
6
  httparty
7
7
 
data/README.md CHANGED
@@ -22,7 +22,122 @@ Or install it yourself as:
22
22
 
23
23
  ## Usage
24
24
 
25
- Write usage instructions here
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/[USERNAME]/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.
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 [MIT License](https://opensource.org/licenses/MIT).
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/[USERNAME]/CricApi/blob/master/CODE_OF_CONDUCT.md).
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).
@@ -1,30 +1,54 @@
1
1
  require "CricApi/version"
2
- require "CricApi/helper/request"
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 self.cricket
7
- Cricket::Request.new('https://apecricket.herokuapp.com', 0).cricket
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 self.matches
11
- Cricket::Request.new('https://apecricket.herokuapp.com', 0).matches
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 self.schedule
15
- Cricket::Request.new('https://apecricket.herokuapp.com', 0).matchCalendar
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 self.cricketScore(id)
19
- Cricket::Request.new('https://apecricket.herokuapp.com', 0).cricketScore(id)
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 self.playerStats(pid)
23
- Cricket::Request.new('https://apecricket.herokuapp.com', 0).playerStats(pid)
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
- def self.score(id)
27
- Cricket::Request.new('https://apecricket.herokuapp.com', 0).playerStats(id)
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
@@ -1,3 +1,3 @@
1
1
  module CricApi
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
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.1.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-10 00:00:00.000000000 Z
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
- - MIT
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