Skip to content

Commit

Permalink
Merge pull request #5 from rcompton78/refactorForMultipleVersions
Browse files Browse the repository at this point in the history
refactored to allow more versions
  • Loading branch information
bradbarkhouse committed Jan 29, 2018
2 parents 8325b9a + 3274c10 commit 85dabff
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 70 deletions.
30 changes: 4 additions & 26 deletions src/API_v1_0.php
Original file line number Diff line number Diff line change
Expand Up @@ -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";
}
}
37 changes: 0 additions & 37 deletions src/API_v1_1.php

This file was deleted.

8 changes: 3 additions & 5 deletions src/ApiFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
29 changes: 27 additions & 2 deletions src/BaseApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 85dabff

Please sign in to comment.