Skip to content

Commit 2170e4d

Browse files
authored
Merge pull request #744 from plural/rulings-export-api
Add an API endpoint for current NRDB-hosted rulings.
2 parents 72f2aea + ff74235 commit 2170e4d

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

src/AppBundle/Controller/PublicApi20Controller.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -540,4 +540,23 @@ public function mwlAction(Request $request)
540540
return $this->entityManager->getRepository('AppBundle:Mwl')->findAll();
541541
}, $request);
542542
}
543+
544+
/**
545+
* Get all Ruling data
546+
*/
547+
public function rulingsAction(Request $request)
548+
{
549+
$rulings = $this->entityManager->getRepository('AppBundle:Ruling')->findAll();
550+
551+
$out = [];
552+
foreach($rulings as $r) {
553+
array_push($out, [
554+
'title' => $r->getCard()->getTitle(),
555+
'ruling' => str_replace('\r', '', $r->getRawText()),
556+
'date_update' => date_format($r->getDateUpdate(), 'Y-m-d'),
557+
'nsg_rules_team_verified' => $r->getNsgRulesTeamVerified()
558+
]);
559+
}
560+
return $this->prepareResponseFromCache($out, count($out), new DateTime(), $request);
561+
}
543562
}

src/AppBundle/Resources/config/routing.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -685,6 +685,12 @@ api_public_mwl:
685685
defaults:
686686
_controller: AppBundle:PublicApi20:mwl
687687

688+
api_public_rulings:
689+
path: /api/2.0/public/rulings
690+
methods: [GET]
691+
defaults:
692+
_controller: AppBundle:PublicApi20:rulings
693+
688694
api_private_decks:
689695
path: /api/2.0/private/decks
690696
methods: [GET]

0 commit comments

Comments
 (0)