-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from rcompton78/refactorForVersionedApis
Refactored API to allow easier versioning
- Loading branch information
Showing
5 changed files
with
290 additions
and
232 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
|
||
namespace MySportsFeeds; | ||
|
||
class API_v1_1 extends BaseApi | ||
{ | ||
# Constructor | ||
public function __construct($verbose, $storeType = null, $storeLocation = null) { | ||
|
||
$this->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); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
|
||
namespace MySportsFeeds; | ||
|
||
class ApiFactory | ||
{ | ||
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); | ||
break; | ||
default: | ||
throw new \ErrorException("Unrecognized version specified. Supported versions are: '1.0, 1.1'"); | ||
} | ||
|
||
return $apiVersion; | ||
} | ||
} |
Oops, something went wrong.