diff --git a/src/API_v1_0.php b/src/API_v1_0.php index 56aaa80..ad6d3e4 100644 --- a/src/API_v1_0.php +++ b/src/API_v1_0.php @@ -3,30 +3,8 @@ namespace MySportsFeeds; class API_v1_0 extends BaseApi { - # Constructor - public function __construct($verbose, $storeType = null, $storeLocation = null) { - - $this->baseUrl = "https://www.mysportsfeeds.com/api/feed/pull"; - - $this->validFeeds = [ - 'current_season', - 'cumulative_player_stats', - 'full_game_schedule', - 'daily_game_schedule', - 'daily_player_stats', - 'game_playbyplay', - 'game_boxscore', - 'scoreboard', - 'player_gamelogs', - 'team_gamelogs', - 'roster_players', - 'game_startinglineup', - 'active_players', - 'player_injuries', - 'latest_updates', - 'daily_dfs' - ]; - - parent::__construct($verbose, $storeType, $storeLocation); - } + protected function getBaseUrlForVersion($version) + { + return "https://www.mysportsfeeds.com/api/feed/pull"; + } } diff --git a/src/API_v1_1.php b/src/API_v1_1.php deleted file mode 100644 index e9f8597..0000000 --- a/src/API_v1_1.php +++ /dev/null @@ -1,37 +0,0 @@ -baseUrl = "https://api.mysportsfeeds.com/v1.1/pull"; - - /** - * I am not sure if these changed for v1.1 - */ - $this->validFeeds = [ - 'current_season', - 'cumulative_player_stats', - 'full_game_schedule', - 'daily_game_schedule', - 'daily_player_stats', - 'game_playbyplay', - 'game_boxscore', - 'scoreboard', - 'player_gamelogs', - 'team_gamelogs', - 'roster_players', - 'game_startinglineup', - 'active_players', - 'player_injuries', - 'latest_updates', - 'daily_dfs' - ]; - - parent::__construct($verbose, $storeType, $storeLocation); - } - -} \ No newline at end of file diff --git a/src/ApiFactory.php b/src/ApiFactory.php index c4ba700..8979f35 100644 --- a/src/ApiFactory.php +++ b/src/ApiFactory.php @@ -9,13 +9,11 @@ public static function create($version, $verbose, $storeType, $storeLocation) $apiVersion = null; switch($version) { case '1.0': - $apiVersion = new API_v1_0($verbose, $storeType, $storeLocation); - break; - case '1.1': - $apiVersion = new API_v1_1($verbose, $storeType, $storeLocation); + $apiVersion = new API_v1_0($version, $verbose, $storeType, $storeLocation); break; default: - throw new \ErrorException("Unrecognized version specified. Supported versions are: '1.0, 1.1'"); + $apiVersion = new BaseApi($version, $verbose, $storeType, $storeLocation); + break; } return $apiVersion; diff --git a/src/BaseApi.php b/src/BaseApi.php index bbb5fbd..7ea56c0 100644 --- a/src/BaseApi.php +++ b/src/BaseApi.php @@ -10,16 +10,41 @@ class BaseApi protected $verbose; protected $storeType; protected $storeLocation; - protected $validFeeds; protected $storeOutput; + protected $version; + protected $validFeeds = [ + 'current_season', + 'cumulative_player_stats', + 'full_game_schedule', + 'daily_game_schedule', + 'daily_player_stats', + 'game_playbyplay', + 'game_boxscore', + 'scoreboard', + 'player_gamelogs', + 'team_gamelogs', + 'roster_players', + 'game_startinglineup', + 'active_players', + 'player_injuries', + 'latest_updates', + 'daily_dfs' + ]; # Constructor - public function __construct($verbose, $storeType = null, $storeLocation = null) { + public function __construct($version, $verbose, $storeType = null, $storeLocation = null) { $this->auth = null; $this->verbose = $verbose; $this->storeType = $storeType; $this->storeLocation = $storeLocation; + $this->version = $version; + $this->baseUrl = $this->getBaseUrlForVersion($version); + } + + protected function getBaseUrlForVersion($version) + { + return "https://api.mysportsfeeds.com/v{$version}/pull"; } # Verify a feed