fantasydata 0.0.1

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.
Files changed (112) hide show
  1. data/.gitignore +19 -0
  2. data/.travis.yml +13 -0
  3. data/Gemfile +17 -0
  4. data/Guardfile +70 -0
  5. data/LICENSE +22 -0
  6. data/README.md +32 -0
  7. data/Rakefile +2 -0
  8. data/fantasydata.gemspec +22 -0
  9. data/lib/fantasydata.rb +47 -0
  10. data/lib/fantasydata/api/box_score.rb +104 -0
  11. data/lib/fantasydata/api/bye_weeks.rb +24 -0
  12. data/lib/fantasydata/api/fantasy.rb +68 -0
  13. data/lib/fantasydata/api/game.rb +31 -0
  14. data/lib/fantasydata/api/news.rb +22 -0
  15. data/lib/fantasydata/api/player_details.rb +26 -0
  16. data/lib/fantasydata/api/player_stat.rb +33 -0
  17. data/lib/fantasydata/api/schedule.rb +13 -0
  18. data/lib/fantasydata/api/stadium.rb +14 -0
  19. data/lib/fantasydata/api/standings.rb +14 -0
  20. data/lib/fantasydata/api/team.rb +18 -0
  21. data/lib/fantasydata/api/utils.rb +65 -0
  22. data/lib/fantasydata/api/week.rb +22 -0
  23. data/lib/fantasydata/base.rb +91 -0
  24. data/lib/fantasydata/bye_week.rb +8 -0
  25. data/lib/fantasydata/client.rb +77 -0
  26. data/lib/fantasydata/configurable.rb +79 -0
  27. data/lib/fantasydata/daily_fantasy_player.rb +11 -0
  28. data/lib/fantasydata/daily_fantasy_player_stats.rb +35 -0
  29. data/lib/fantasydata/daily_fantasy_points.rb +8 -0
  30. data/lib/fantasydata/default.rb +82 -0
  31. data/lib/fantasydata/error.rb +33 -0
  32. data/lib/fantasydata/error/bad_gateway.rb +11 -0
  33. data/lib/fantasydata/error/bad_request.rb +10 -0
  34. data/lib/fantasydata/error/client_error.rb +24 -0
  35. data/lib/fantasydata/error/configuration_error.rb +8 -0
  36. data/lib/fantasydata/error/forbidden.rb +10 -0
  37. data/lib/fantasydata/error/gateway_timeout.rb +11 -0
  38. data/lib/fantasydata/error/internal_server_error.rb +11 -0
  39. data/lib/fantasydata/error/not_acceptable.rb +10 -0
  40. data/lib/fantasydata/error/not_found.rb +10 -0
  41. data/lib/fantasydata/error/server_error.rb +28 -0
  42. data/lib/fantasydata/error/service_unavailable.rb +11 -0
  43. data/lib/fantasydata/error/too_many_requests.rb +12 -0
  44. data/lib/fantasydata/error/unauthorized.rb +10 -0
  45. data/lib/fantasydata/error/unprocessable_entity.rb +10 -0
  46. data/lib/fantasydata/fantasy_player_adp.rb +10 -0
  47. data/lib/fantasydata/game_stat.rb +93 -0
  48. data/lib/fantasydata/news.rb +8 -0
  49. data/lib/fantasydata/player_detail.rb +27 -0
  50. data/lib/fantasydata/player_game_stat.rb +46 -0
  51. data/lib/fantasydata/player_season_stat.rb +54 -0
  52. data/lib/fantasydata/response/parse_json.rb +25 -0
  53. data/lib/fantasydata/response/raise_error.rb +32 -0
  54. data/lib/fantasydata/schedule.rb +14 -0
  55. data/lib/fantasydata/scoring_detail.rb +10 -0
  56. data/lib/fantasydata/stadium.rb +9 -0
  57. data/lib/fantasydata/standings.rb +13 -0
  58. data/lib/fantasydata/team_detail.rb +20 -0
  59. data/lib/fantasydata/version.rb +3 -0
  60. data/spec/fantasydata/api/box_score_spec.rb +17 -0
  61. data/spec/fantasydata/api/bye_weeks_spec.rb +31 -0
  62. data/spec/fantasydata/api/daily_fantasy_spec.rb +189 -0
  63. data/spec/fantasydata/api/game_spec.rb +84 -0
  64. data/spec/fantasydata/api/news_spec.rb +66 -0
  65. data/spec/fantasydata/api/player_details_spec.rb +107 -0
  66. data/spec/fantasydata/api/player_stat_spec.rb +138 -0
  67. data/spec/fantasydata/api/schedule_spec.rb +37 -0
  68. data/spec/fantasydata/api/stadium_spec.rb +32 -0
  69. data/spec/fantasydata/api/standings_spec.rb +30 -0
  70. data/spec/fantasydata/api/team_spec.rb +56 -0
  71. data/spec/fantasydata/api/week_spec.rb +69 -0
  72. data/spec/fantasydata/box_score_spec.rb +64 -0
  73. data/spec/fantasydata/client_spec.rb +77 -0
  74. data/spec/fantasydata/error_spec.rb +37 -0
  75. data/spec/fantasydata_spec.rb +64 -0
  76. data/spec/fixtures/bye_weeks/bye_weeks.json +1 -0
  77. data/spec/fixtures/daily_fantasy/adp.json +1 -0
  78. data/spec/fixtures/daily_fantasy/daily_defense_game.json +1 -0
  79. data/spec/fixtures/daily_fantasy/daily_defense_seasons_proj.json +1 -0
  80. data/spec/fixtures/daily_fantasy/daily_defense_seasons_stats.json +1 -0
  81. data/spec/fixtures/daily_fantasy/daily_players.json +1 -0
  82. data/spec/fixtures/daily_fantasy/daily_points.json +1 -0
  83. data/spec/fixtures/daily_fantasy/defense_game_stats_projected.json +1 -0
  84. data/spec/fixtures/error_response.json +4 -0
  85. data/spec/fixtures/game/game_stats_by_season.json +1 -0
  86. data/spec/fixtures/game/game_stats_by_week.json +1 -0
  87. data/spec/fixtures/game/in_progress.json +1 -0
  88. data/spec/fixtures/game/in_progress_false.json +1 -0
  89. data/spec/fixtures/game/in_progress_true.json +1 -0
  90. data/spec/fixtures/news/by_player.json +1 -0
  91. data/spec/fixtures/news/by_team.json +1 -0
  92. data/spec/fixtures/news/recent.json +1 -0
  93. data/spec/fixtures/player_details/active.json +1 -0
  94. data/spec/fixtures/player_details/by_team.json +1 -0
  95. data/spec/fixtures/player_details/free_agents.json +1 -0
  96. data/spec/fixtures/player_details/player_find.json +1 -0
  97. data/spec/fixtures/player_stat/stat_by_delta.json +1 -0
  98. data/spec/fixtures/player_stat/stat_by_game_projection.json +1 -0
  99. data/spec/fixtures/player_stat/stat_by_player_id.json +1 -0
  100. data/spec/fixtures/player_stat/stat_by_week.json +1 -0
  101. data/spec/fixtures/player_stat/stat_by_week_and_team.json +1 -0
  102. data/spec/fixtures/player_stat/stat_by_week_and_team_projected.json +1 -0
  103. data/spec/fixtures/schedule/for_year.json +1 -0
  104. data/spec/fixtures/stadium/index.json +1 -0
  105. data/spec/fixtures/standings/by_year.json +1 -0
  106. data/spec/fixtures/team/active.json +1 -0
  107. data/spec/fixtures/team/by_year.json +1 -0
  108. data/spec/fixtures/week/current.json +1 -0
  109. data/spec/fixtures/week/last_completed.json +1 -0
  110. data/spec/fixtures/week/upcoming.json +1 -0
  111. data/spec/helper.rb +42 -0
  112. metadata +242 -0
@@ -0,0 +1,19 @@
1
+ ## PROJECT::GENERAL
2
+ coverage
3
+ rdoc
4
+ doc
5
+ log
6
+ pkg/*
7
+ tmp
8
+ .rvmrc
9
+ .rbenv*
10
+
11
+ ## BUNDLER
12
+ bin
13
+ *.gem
14
+ .bundle
15
+ Gemfile.lock
16
+ /bundle
17
+
18
+ ## PROJECT::SPECIFIC
19
+ .rbx
@@ -0,0 +1,13 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.2
4
+ - 2.2.0
5
+ - 2.1.5
6
+ - 2.0.0
7
+ - 1.9.3
8
+
9
+ addons:
10
+ code_climate:
11
+ repo_token: 13c47ef9f99297ad6c43f9901c4fdde048c2019be2fd2cb38b8f0861da832797
12
+
13
+ script: bundle exec rspec
data/Gemfile ADDED
@@ -0,0 +1,17 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'rake'
4
+
5
+ group :test do
6
+ gem 'pry'
7
+ gem "codeclimate-test-reporter", require: nil
8
+ gem 'rspec', '~>3.0'
9
+ gem 'webmock', '~>1.0'
10
+ gem 'timecop', '~>0.0'
11
+
12
+ gem 'guard'
13
+ gem 'guard-rspec'
14
+ end
15
+
16
+ # Specify your gem's dependencies in fantasydata.gemspec
17
+ gemspec
@@ -0,0 +1,70 @@
1
+ # A sample Guardfile
2
+ # More info at https://github.com/guard/guard#readme
3
+
4
+ ## Uncomment and set this to only include directories you want to watch
5
+ # directories %w(app lib config test spec features) \
6
+ # .select{|d| Dir.exists?(d) ? d : UI.warning("Directory #{d} does not exist")}
7
+
8
+ ## Note: if you are using the `directories` clause above and you are not
9
+ ## watching the project directory ('.'), then you will want to move
10
+ ## the Guardfile to a watched dir and symlink it back, e.g.
11
+ #
12
+ # $ mkdir config
13
+ # $ mv Guardfile config/
14
+ # $ ln -s config/Guardfile .
15
+ #
16
+ # and, you'll have to watch "config/Guardfile" instead of "Guardfile"
17
+
18
+ # Note: The cmd option is now required due to the increasing number of ways
19
+ # rspec may be run, below are examples of the most common uses.
20
+ # * bundler: 'bundle exec rspec'
21
+ # * bundler binstubs: 'bin/rspec'
22
+ # * spring: 'bin/rspec' (This will use spring if running and you have
23
+ # installed the spring binstubs per the docs)
24
+ # * zeus: 'zeus rspec' (requires the server to be started separately)
25
+ # * 'just' rspec: 'rspec'
26
+
27
+ guard :rspec, cmd: "bundle exec rspec" do
28
+ require "guard/rspec/dsl"
29
+ dsl = Guard::RSpec::Dsl.new(self)
30
+
31
+ # Feel free to open issues for suggestions and improvements
32
+
33
+ # RSpec files
34
+ rspec = dsl.rspec
35
+ watch(rspec.spec_helper) { rspec.spec_dir }
36
+ watch(rspec.spec_support) { rspec.spec_dir }
37
+ watch(rspec.spec_files)
38
+
39
+ # Ruby files
40
+ ruby = dsl.ruby
41
+ dsl.watch_spec_files_for(ruby.lib_files)
42
+
43
+ # Rails files
44
+ rails = dsl.rails(view_extensions: %w(erb haml slim))
45
+ dsl.watch_spec_files_for(rails.app_files)
46
+ dsl.watch_spec_files_for(rails.views)
47
+
48
+ watch(rails.controllers) do |m|
49
+ [
50
+ rspec.spec.("routing/#{m[1]}_routing"),
51
+ rspec.spec.("controllers/#{m[1]}_controller"),
52
+ rspec.spec.("acceptance/#{m[1]}")
53
+ ]
54
+ end
55
+
56
+ # Rails config changes
57
+ watch(rails.spec_helper) { rspec.spec_dir }
58
+ watch(rails.routes) { "#{rspec.spec_dir}/routing" }
59
+ watch(rails.app_controller) { "#{rspec.spec_dir}/controllers" }
60
+
61
+ # Capybara features specs
62
+ watch(rails.view_dirs) { |m| rspec.spec.("features/#{m[1]}") }
63
+ watch(rails.layouts) { |m| rspec.spec.("features/#{m[1]}") }
64
+
65
+ # Turnip features and steps
66
+ watch(%r{^spec/acceptance/(.+)\.feature$})
67
+ watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) do |m|
68
+ Dir[File.join("**/#{m[1]}.feature")][0] || "spec/acceptance"
69
+ end
70
+ end
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 Ryan Drost
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,32 @@
1
+ # Fantasydata
2
+
3
+ [![Build Status](https://travis-ci.org/Drosty/fantasydata.svg?branch=master)](https://travis-ci.org/Drosty/fantasydata)[![Code Climate](https://codeclimate.com/github/Drosty/fantasydata/badges/gpa.svg)](https://codeclimate.com/github/Drosty/fantasydata)[![Test Coverage](https://codeclimate.com/github/Drosty/fantasydata/badges/coverage.svg)](https://codeclimate.com/github/Drosty/fantasydata/coverage)
4
+
5
+
6
+ TODO: Write a gem description
7
+
8
+ ## Installation
9
+
10
+ Add this line to your application's Gemfile:
11
+
12
+ gem 'fantasydata'
13
+
14
+ And then execute:
15
+
16
+ $ bundle
17
+
18
+ Or install it yourself as:
19
+
20
+ $ gem install fantasydata
21
+
22
+ ## Usage
23
+
24
+ TODO: Write usage instructions here
25
+
26
+ ## Contributing
27
+
28
+ 1. Fork it
29
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
30
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
31
+ 4. Push to the branch (`git push origin my-new-feature`)
32
+ 5. Create new Pull Request
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
@@ -0,0 +1,22 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/fantasydata/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["Ryan Drost"]
6
+ gem.email = ["ryan.s.drost@gmail.com"]
7
+ gem.description = %q{Gem to wrap www.fantasydata.com API}
8
+ gem.summary = %q{This gem will wrap the FantasyData API and give easy access to the calls that can be made}
9
+ gem.homepage = "https://github.com/Drosty/fantasydata"
10
+ gem.license = 'MIT'
11
+
12
+ gem.files = `git ls-files`.split($\)
13
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
14
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
15
+ gem.name = "fantasydata"
16
+ gem.require_paths = ["lib"]
17
+ gem.version = Fantasydata::VERSION
18
+
19
+ gem.add_dependency 'faraday', '~> 0.9'
20
+ gem.add_dependency 'multi_json', '~> 1.0'
21
+
22
+ end
@@ -0,0 +1,47 @@
1
+ require "fantasydata/version"
2
+ require 'fantasydata/client'
3
+ require 'fantasydata/configurable'
4
+ require 'fantasydata/bye_week'
5
+ require 'fantasydata/fantasy_player_adp'
6
+ require 'fantasydata/daily_fantasy_player'
7
+ require 'fantasydata/daily_fantasy_points'
8
+ require 'fantasydata/news'
9
+ require 'fantasydata/player_detail'
10
+ require 'fantasydata/player_game_stat'
11
+ require 'fantasydata/player_season_stat'
12
+ require 'fantasydata/game_stat'
13
+ require 'fantasydata/scoring_detail'
14
+ require 'fantasydata/schedule'
15
+ require 'fantasydata/team_detail'
16
+ require 'fantasydata/stadium'
17
+ require 'fantasydata/standings'
18
+ require 'fantasydata/error'
19
+ require 'fantasydata/version'
20
+ require 'fantasydata/daily_fantasy_player_stats'
21
+
22
+
23
+ module Fantasydata
24
+ class << self
25
+ include Fantasydata::Configurable
26
+
27
+ # Delegate to a Echowrap::Client
28
+ #
29
+ # @return [Echowrap::Client]
30
+ def client
31
+ @client = Fantasydata::Client.new(options) unless defined?(@client) && @client.hash == options.hash
32
+ @client
33
+ end
34
+
35
+ def respond_to_missing?(method_name, include_private=false); client.respond_to?(method_name, include_private); end if RUBY_VERSION >= "1.9"
36
+ def respond_to?(method_name, include_private=false); client.respond_to?(method_name, include_private) || super; end if RUBY_VERSION < "1.9"
37
+
38
+ private
39
+
40
+ def method_missing(method_name, *args, &block)
41
+ return super unless client.respond_to?(method_name)
42
+ client.send(method_name, *args, &block)
43
+ end
44
+ end
45
+ end
46
+
47
+ Fantasydata.setup
@@ -0,0 +1,104 @@
1
+ require 'fantasydata/api/utils'
2
+
3
+ module Fantasydata
4
+ module API
5
+ module BoxScore
6
+ include Fantasydata::API::Utils
7
+
8
+ # This method returns individual box scores for a given season, week and home team.
9
+ #
10
+ # @see https://developer.fantasydata.com/docs/services/556a892e35491a1d30c7a8ba/operations/556a892f35491a02d05ebf40
11
+ # @authentication Requires api key
12
+ # @raise [Fantasydata::Error::Unauthorized] Error raised when supplied api key is not valid.
13
+ # @raise [Fantasydata::Error::Unauthorized] Error raised when supplied user credentials are not valid.
14
+ # @return [Fantasydata::BoxScore]
15
+ # @param season [String] Year of the season and the season type. If no season type is provided, then the default is regular season Examples: 2015REG, 2015PRE, 2015POST, 2015
16
+ # @param week [Integer] Week of the season. Valid values are as follows: Preseason 0 to 4, Regular Season 1 to 17, Postseason 1 to 4
17
+ # @param hometeam [String] Abbreviation of the home team. Example: WAS
18
+ # @example box_score_individual_game
19
+ # Fantasydata.box_score_individual_game('2015REG', 15, 'MIN')
20
+ def box_score_individual_game(season, week, hometeam)
21
+ end
22
+
23
+
24
+ # This method returns all box scores for a given season and week.
25
+ #
26
+ # @see https://developer.fantasydata.com/docs/services/556a892e35491a1d30c7a8ba/operations/556a892f35491a02d05ebf41
27
+ # @authentication Requires api key
28
+ # @raise [Fantasydata::Error::Unauthorized] Error raised when supplied api key is not valid.
29
+ # @raise [Fantasydata::Error::Unauthorized] Error raised when supplied user credentials are not valid.
30
+ # @return [Array<Fantasydata::BoxScore>]
31
+ # @param season [String] Year of the season and the season type. If no season type is provided, then the default is regular season Examples: 2015REG, 2015PRE, 2015POST, 2015
32
+ # @param week [Integer] Week of the season. Valid values are as follows: Preseason 0 to 4, Regular Season 1 to 17, Postseason 1 to 4
33
+ # @example box_scores_week
34
+ # Fantasydata.box_scores_week('2015REG', 15)
35
+ def box_scores_week(season, week)
36
+ end
37
+
38
+ # This method returns box scores for all games that are either in-progress or have been updated within the last 30 minutes.
39
+ #
40
+ # @see https://developer.fantasydata.com/docs/services/556a892e35491a1d30c7a8ba/operations/556a892f35491a02d05ebf3e
41
+ # @authentication Requires api key
42
+ # @raise [Fantasydata::Error::Unauthorized] Error raised when supplied api key is not valid.
43
+ # @raise [Fantasydata::Error::Unauthorized] Error raised when supplied user credentials are not valid.
44
+ # @return [Array<Fantasydata::BoxScore>]
45
+ # @example box_scores_active
46
+ # Fantasydata.box_scores_active
47
+ def box_scores_active
48
+ end
49
+
50
+ # This method returns all box scores for a given season and week, but only returns player stats that have changed in the last X minutes.
51
+ #
52
+ # @see https://developer.fantasydata.com/docs/services/556a892e35491a1d30c7a8ba/operations/556a892f35491a02d05ebf3e
53
+ # @authentication Requires api key
54
+ # @raise [Fantasydata::Error::Unauthorized] Error raised when supplied api key is not valid.
55
+ # @raise [Fantasydata::Error::Unauthorized] Error raised when supplied user credentials are not valid.
56
+ # @return [Array<Fantasydata::BoxScore>]
57
+ # @param season [String] Year of the season and the season type. If no season type is provided, then the default is regular season Examples: 2015REG, 2015PRE, 2015POST, 2015
58
+ # @param week [Integer] Week of the season. Valid values are as follows: Preseason 0 to 4, Regular Season 1 to 17, Postseason 1 to 4
59
+ # @param minutes [Integer] Only returns player statistics that have changed in the last X minutes. You specify how many minutes in time to go back. Valid entries are: 1 or 2 (etc.)
60
+ # @example box_scores_delta
61
+ # Fantasydata.box_scores_delta('2014REG', 1, 5)
62
+ def box_scores_delta(season, week, minutes)
63
+ end
64
+
65
+ # This method returns all box scores for the current week, but only returns player stats that have changed in the last X minutes.
66
+ #
67
+ # @see https://developer.fantasydata.com/docs/services/556a892e35491a1d30c7a8ba/operations/556a892f35491a02d05ebf3e
68
+ # @authentication Requires api key
69
+ # @raise [Fantasydata::Error::Unauthorized] Error raised when supplied api key is not valid.
70
+ # @raise [Fantasydata::Error::Unauthorized] Error raised when supplied user credentials are not valid.
71
+ # @return [Array<Fantasydata::BoxScore>]
72
+ # @param minutes [Integer] Only returns player statistics that have changed in the last X minutes. You specify how many minutes in time to go back. Valid entries are: 1 or 2 (etc.)
73
+ # @example box_scores_delta_current_week
74
+ # Fantasydata.box_scores_delta_current_week(5)
75
+ def box_scores_delta_current_week(minutes)
76
+ end
77
+
78
+ #
79
+ #
80
+ # @see https://developer.fantasydata.com/docs/services/556a892e35491a1d30c7a8ba/operations/556a892f35491a02d05ebf4b
81
+ # @authentication Requires api key
82
+ # @raise [Fantasydata::Error::Unauthorized] Error raised when supplied api key is not valid.
83
+ # @raise [Fantasydata::Error::Unauthorized] Error raised when supplied user credentials are not valid.
84
+ # @return [Array<Fantasydata::BoxScore>]
85
+ # @example box_scores_final
86
+ # Fantasydata.box_scores_final
87
+ def box_scores_final
88
+ end
89
+
90
+ #
91
+ #
92
+ # @see https://developer.fantasydata.com/docs/services/556a892e35491a1d30c7a8ba/operations/556a892f35491a02d05ebf55
93
+ # @authentication Requires api key
94
+ # @raise [Fantasydata::Error::Unauthorized] Error raised when supplied api key is not valid.
95
+ # @raise [Fantasydata::Error::Unauthorized] Error raised when supplied user credentials are not valid.
96
+ # @return [Array<Fantasydata::BoxScore>]
97
+ # @example box_scores_live
98
+ # Fantasydata.box_scores_live
99
+ def box_scores_live
100
+ end
101
+
102
+ end
103
+ end
104
+ end
@@ -0,0 +1,24 @@
1
+ require 'fantasydata/api/utils'
2
+
3
+ module Fantasydata
4
+ module API
5
+ module ByeWeeks
6
+ include Fantasydata::API::Utils
7
+
8
+ # Get bye weeks for the teams during a specified NFL season.
9
+ #
10
+ # @see https://developer.fantasydata.com/docs/services/556a892e35491a1d30c7a8ba/operations/556a892f35491a02d05ebf42
11
+ # @authentication Requires api key
12
+ # @raise [Fantasydata::Error::Unauthorized] Error raised when supplied api key is not valid.
13
+ # @raise [Fantasydata::Error::Unauthorized] Error raised when supplied user credentials are not valid.
14
+ # @return [Fantasydata::BoxScore]
15
+ # @param season [String] Year of the season and the season type. If no season type is provided, then the default is regular season Examples: 2015REG, 2015PRE, 2015POST, 2015
16
+ # @example bye_weeks_for_season
17
+ # Fantasydata.bye_weeks_for_season('2015REG')
18
+ def bye_weeks_for_season(season)
19
+ objects_from_response(Fantasydata::ByeWeek, :get, "/nfl/v2/JSON/Byes/#{season}")
20
+ end
21
+
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,68 @@
1
+ require 'fantasydata/api/utils'
2
+
3
+ module Fantasydata
4
+ module API
5
+ module Fantasy
6
+ include Fantasydata::API::Utils
7
+
8
+ # Gets daily fantasy player information for given day.
9
+ #
10
+ # @see https://developer.fantasydata.com/docs/services/556a892e35491a1d30c7a8ba/operations/556a892f35491a02d05ebf42
11
+ # @authentication Requires api key
12
+ # @raise [Fantasydata::Error::Unauthorized] Error raised when supplied api key is not valid.
13
+ # @raise [Fantasydata::Error::Unauthorized] Error raised when supplied user credentials are not valid.
14
+ # @return [Fantasydata::BoxScore]
15
+ # @param season [String] Year of the season and the season type. If no season type is provided, then the default is regular season Examples: 2015REG, 2015PRE, 2015POST, 2015
16
+ # @example daily_fantasy_for_day
17
+ # Fantasydata.daily_fantasy_for_day('2014-SEP-21')
18
+ def daily_fantasy_players_for_day(day)
19
+ day = convert_to_date(day)
20
+ objects_from_response(Fantasydata::DailyFantasyPlayer, :get, "/nfl/v2/JSON/DailyFantasyPlayers/#{day}")
21
+ end
22
+
23
+ # Get daily fantasy points for a given day.
24
+ #
25
+ # @see https://developer.fantasydata.com/docs/services/556a892e35491a1d30c7a8ba/operations/556a892f35491a02d05ebf42
26
+ # @authentication Requires api key
27
+ # @raise [Fantasydata::Error::Unauthorized] Error raised when supplied api key is not valid.
28
+ # @raise [Fantasydata::Error::Unauthorized] Error raised when supplied user credentials are not valid.
29
+ # @return [Fantasydata::BoxScore]
30
+ # @param season [String] Year of the season and the season type. If no season type is provided, then the default is regular season Examples: 2015REG, 2015PRE, 2015POST, 2015
31
+ # @example daily_fantasy_for_day
32
+ # Fantasydata.daily_fantasy_for_day('2014-SEP-21')
33
+ def daily_fantasy_points_for_day(day)
34
+ day = convert_to_date(day)
35
+ objects_from_response(Fantasydata::DailyFantasyPoints, :get, "/nfl/v2/JSON/DailyFantasyPoints/#{day}")
36
+ end
37
+
38
+ def daily_fantasy_defense_game_stats year, week
39
+ objects_from_response(Fantasydata::DailyFantasyPlayerStats, :get, "/nfl/v2/JSON/FantasyDefenseByGame/#{year}/#{week}")
40
+ end
41
+
42
+ def daily_fantasy_defense_game_projected_stats year, week
43
+ objects_from_response(Fantasydata::DailyFantasyPlayerStats, :get, "/nfl/v2/JSON/FantasyDefenseProjectionsByGame/#{year}/#{week}")
44
+ end
45
+
46
+ def daily_fantasy_defense_season_stats year
47
+ objects_from_response(Fantasydata::DailyFantasyPlayerStats, :get, "/nfl/v2/JSON/FantasyDefenseBySeason/#{year}")
48
+ end
49
+
50
+ def daily_fantasy_defense_season_projected_stats year
51
+ objects_from_response(Fantasydata::DailyFantasyPlayerStats, :get, "/nfl/v2/JSON/FantasyDefenseProjectionsBySeason/#{year}")
52
+ end
53
+
54
+ def fantasy_players_adp
55
+ objects_from_response(Fantasydata::FantasyPlayerAdp, :get, "/nfl/v2/JSON/FantasyPlayers")
56
+ end
57
+
58
+ private
59
+
60
+ def convert_to_date input
61
+ if input.is_a?(DateTime)
62
+ input = input.strftime("%Y-%b-%d").upcase
63
+ end
64
+ input
65
+ end
66
+ end
67
+ end
68
+ end