mysportsfeeds 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 643d591d7f1020328641580364dc88264c24c69a
4
+ data.tar.gz: 7a94e5024aa29bb1e4e803e5691e8103b8fda3cb
5
+ SHA512:
6
+ metadata.gz: 095d5ca86f84a78f93c403e02c7de0443e3696b61dd014bce5e3cc202c6f297760dc3756cfc0bc049f44f99095da2bccafaa28e961a40341856282bf5ca6dc08
7
+ data.tar.gz: 1a3573953596faa072ae14566b56d34e351a7fc4ca8d9bbff74023c3f843d8c3a16e4e9163ac46d30b6f77c297b3ec4fa8037b97bf29a3ad4fdfaca4d2d62747
@@ -0,0 +1,12 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+
11
+ # rspec failure tracking
12
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.2.5
5
+ before_install: gem install bundler -v 1.14.3
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in mysportsfeeds-ruby.gemspec
4
+ gemspec
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 TODO: Write your name
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.
@@ -0,0 +1,69 @@
1
+ # MySportsFeeds
2
+
3
+ ## Installation
4
+
5
+ Add this line to your application's Gemfile:
6
+
7
+ ```ruby
8
+ gem 'mysportsfeeds-ruby'
9
+ ```
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install mysportsfeeds-ruby
18
+
19
+ ## Usage
20
+
21
+ Create a client:
22
+
23
+ ```ruby
24
+ client = MySportsFeeds::Client.new('YOUR_USERNAME', 'YOUR_PASSWORD', { season: '2017-playoff' })
25
+ ```
26
+
27
+ Make some calls:
28
+
29
+ ```ruby
30
+ response = client.get_cumulative_player_stats
31
+ response.body # JSON dump of the response body
32
+ response.status_code # Response status code
33
+ ```
34
+
35
+ List of available methods:
36
+
37
+ ```ruby
38
+ client.get_cumulative_player_stats
39
+ client.get_full_game_schedule
40
+ client.get_daily_game_schedule(date)
41
+ client.get_daily_player_stats(date)
42
+ client.get_game_play_by_play(gameid)
43
+ client.get_game_box_score(gameid)
44
+ client.get_scoreboard(date)
45
+ client.get_roster_players(date)
46
+ client.get_active_players
47
+ client.get_overall_team_standings
48
+ client.get_conference_team_standings(team_stats)
49
+ client.get_division_team_standings(team_stats)
50
+ client.get_playoff_team_standings(team_stats)
51
+ client.get_player_injuries
52
+ client.get_latest_updates
53
+ client.get_daily_dfs(date)
54
+ ```
55
+
56
+ ## Development
57
+
58
+ 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.
59
+
60
+ 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).
61
+
62
+ ## Contributing
63
+
64
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/mysportsfeeds-ruby.
65
+
66
+
67
+ ## License
68
+
69
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ # require "rspec/core/rake_task"
3
+
4
+ # RSpec::Core::RakeTask.new(:spec)
5
+
6
+ # task :default => :spec
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "mysportsfeeds/ruby"
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__)
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,11 @@
1
+ require 'typhoeus'
2
+ require 'json'
3
+ require 'base64'
4
+
5
+ require 'mysportsfeeds/client'
6
+ require 'mysportsfeeds/api'
7
+ require 'mysportsfeeds/response'
8
+ require 'mysportsfeeds/version'
9
+
10
+ module MySportsFeeds
11
+ end
@@ -0,0 +1,46 @@
1
+ module MySportsFeeds
2
+ class Api
3
+ def initialize(username, password, options = {})
4
+ @username = username
5
+ @password = password
6
+ @options = options
7
+ end
8
+
9
+ def get(url, params = {})
10
+ request = make_request(url, :get, params)
11
+ response = request.run
12
+ Response::Success.new(JSON.parse(response.response_body), response.response_code)
13
+ rescue JSON::ParserError => e
14
+ Response::Error.new(e.message)
15
+ end
16
+
17
+ def make_request(url, method, params = {})
18
+ Typhoeus::Request.new(
19
+ build_url(url),
20
+ method: method,
21
+ params: params,
22
+ userpwd: "#{@username}:#{@password}",
23
+ accept_encoding: "gzip",
24
+ followlocation: true
25
+ )
26
+ end
27
+
28
+ private
29
+
30
+ def build_url(url)
31
+ "https://www.mysportsfeeds.com/api/feed/pull/nba/#{season}/#{url}.#{format}"
32
+ end
33
+
34
+ def format
35
+ @format ||= @options.fetch(:format, 'json')
36
+ end
37
+
38
+ def season
39
+ @season ||= @options.fetch(:season)
40
+ end
41
+
42
+ def force
43
+ @force ||= @options.fetch(:force, true)
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,75 @@
1
+ module MySportsFeeds
2
+ class Client
3
+ def initialize(username, password, options = {})
4
+ @api = MySportsFeeds::Api.new(username, password, options)
5
+ end
6
+
7
+ def get_cumulative_player_stats
8
+ @api.get('cumulative_player_stats')
9
+ end
10
+
11
+ def get_full_game_schedule
12
+ @api.get('full_game_schedule')
13
+ end
14
+
15
+ def get_daily_game_schedule(date)
16
+ @api.get('daily_game_schedule', { fordate: date })
17
+ end
18
+
19
+ def get_daily_player_stats(date)
20
+ @api.get('daily_player_stats', { fordate: date })
21
+ end
22
+
23
+ def get_game_play_by_play(gameid)
24
+ @api.get('game_playbyplay', { gameid: gameid })
25
+ end
26
+
27
+ def get_game_box_score(gameid)
28
+ @api.get('game_boxscore', { gameid: gameid })
29
+ end
30
+
31
+ def get_scoreboard(date)
32
+ @api.get('scoreboard', { fordate: date })
33
+ end
34
+
35
+ def get_roster_players(date)
36
+ @api.get('roster_players', { fordate: date })
37
+ end
38
+
39
+ def get_active_players
40
+ @api.get('active_players')
41
+ end
42
+
43
+ def get_overall_team_standings
44
+ @api.get('overall_team_standings')
45
+ end
46
+
47
+ def get_conference_team_standings(team_stats)
48
+ @api.get('conference_team_standings')
49
+ end
50
+
51
+ def get_division_team_standings(team_stats)
52
+ @api.get('division_team_standings')
53
+ end
54
+
55
+ def get_playoff_team_standings(team_stats)
56
+ @api.get('playoff_team_standings')
57
+ end
58
+
59
+ def get_player_injuries
60
+ @api.get('player_injuries')
61
+ end
62
+
63
+ def get_latest_updates
64
+ @api.get('latest_updates')
65
+ end
66
+
67
+ def get_daily_dfs(date)
68
+ @api.get('daily_dfs', { fordate: date })
69
+ end
70
+
71
+ def api
72
+ @api
73
+ end
74
+ end
75
+ end
@@ -0,0 +1,33 @@
1
+ module MySportsFeeds
2
+ module Response
3
+ class Success
4
+ attr_reader :body, :status
5
+
6
+ def initialize(body, status = 200)
7
+ @body = body
8
+ @status = status
9
+ end
10
+
11
+ def success?
12
+ true
13
+ end
14
+ end
15
+
16
+ class Error
17
+ attr_reader :status
18
+
19
+ def initialize(error, status = 422)
20
+ @error = error
21
+ @status = status
22
+ end
23
+
24
+ def body
25
+ { error: @error }
26
+ end
27
+
28
+ def success?
29
+ false
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,3 @@
1
+ module MySportsFeeds
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,28 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'mysportsfeeds/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "mysportsfeeds"
8
+ spec.version = MySportsFeeds::VERSION
9
+ spec.authors = ["Sean Chamberlain"]
10
+ spec.email = ["seanlchamberlain@gmail.com"]
11
+
12
+ spec.summary = "MySportsFeeds.com API Wrapper"
13
+ spec.description = "MySportsFeeds.com API Wrapper"
14
+ spec.homepage = "https://github.com/seanchambo/mysportsfeeds-ruby"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
18
+ f.match(%r{^(test|spec|features)/})
19
+ end
20
+ spec.require_paths = ["lib"]
21
+
22
+ spec.add_dependency "typhoeus", "~> 1.1.2"
23
+ spec.add_dependency "json", "~> 1.8"
24
+
25
+ spec.add_development_dependency "bundler", "~> 1.14"
26
+ spec.add_development_dependency "rake", "~> 10.0"
27
+ spec.add_development_dependency "rspec", "~> 3.0"
28
+ end
metadata ADDED
@@ -0,0 +1,129 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: mysportsfeeds
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Sean Chamberlain
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-04-24 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: typhoeus
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 1.1.2
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 1.1.2
27
+ - !ruby/object:Gem::Dependency
28
+ name: json
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.8'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.8'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.14'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.14'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '10.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '10.0'
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.0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '3.0'
83
+ description: MySportsFeeds.com API Wrapper
84
+ email:
85
+ - seanlchamberlain@gmail.com
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - ".gitignore"
91
+ - ".rspec"
92
+ - ".travis.yml"
93
+ - Gemfile
94
+ - LICENSE.txt
95
+ - README.md
96
+ - Rakefile
97
+ - bin/console
98
+ - bin/setup
99
+ - lib/mysportsfeeds.rb
100
+ - lib/mysportsfeeds/api.rb
101
+ - lib/mysportsfeeds/client.rb
102
+ - lib/mysportsfeeds/response.rb
103
+ - lib/mysportsfeeds/version.rb
104
+ - mysportsfeeds-ruby.gemspec
105
+ homepage: https://github.com/seanchambo/mysportsfeeds-ruby
106
+ licenses:
107
+ - MIT
108
+ metadata: {}
109
+ post_install_message:
110
+ rdoc_options: []
111
+ require_paths:
112
+ - lib
113
+ required_ruby_version: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ required_rubygems_version: !ruby/object:Gem::Requirement
119
+ requirements:
120
+ - - ">="
121
+ - !ruby/object:Gem::Version
122
+ version: '0'
123
+ requirements: []
124
+ rubyforge_project:
125
+ rubygems_version: 2.4.5.1
126
+ signing_key:
127
+ specification_version: 4
128
+ summary: MySportsFeeds.com API Wrapper
129
+ test_files: []