Skip to content

Commit

Permalink
Merge pull request #744 from plural/rulings-export-api
Browse files Browse the repository at this point in the history
Add an API endpoint for current NRDB-hosted rulings.
  • Loading branch information
plural authored Mar 12, 2023
2 parents 72f2aea + ff74235 commit 2170e4d
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/AppBundle/Controller/PublicApi20Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -540,4 +540,23 @@ public function mwlAction(Request $request)
return $this->entityManager->getRepository('AppBundle:Mwl')->findAll();
}, $request);
}

/**
* Get all Ruling data
*/
public function rulingsAction(Request $request)
{
$rulings = $this->entityManager->getRepository('AppBundle:Ruling')->findAll();

$out = [];
foreach($rulings as $r) {
array_push($out, [
'title' => $r->getCard()->getTitle(),
'ruling' => str_replace('\r', '', $r->getRawText()),
'date_update' => date_format($r->getDateUpdate(), 'Y-m-d'),
'nsg_rules_team_verified' => $r->getNsgRulesTeamVerified()
]);
}
return $this->prepareResponseFromCache($out, count($out), new DateTime(), $request);
}
}
6 changes: 6 additions & 0 deletions src/AppBundle/Resources/config/routing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -685,6 +685,12 @@ api_public_mwl:
defaults:
_controller: AppBundle:PublicApi20:mwl

api_public_rulings:
path: /api/2.0/public/rulings
methods: [GET]
defaults:
_controller: AppBundle:PublicApi20:rulings

api_private_decks:
path: /api/2.0/private/decks
methods: [GET]
Expand Down

0 comments on commit 2170e4d

Please sign in to comment.