-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Expose BFF API #251
Merged
carlschroedl
merged 14 commits into
pivot-libre:master
from
carlschroedl:exposeBffApi#234
Nov 18, 2018
Merged
Expose BFF API #251
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
ab87584
Updated to tideman 0.4.0, updated other dependencies via `composer up…
carlschroedl 246132c
First cut of a stateless BFF election-runner
carlschroedl 17d201f
Moved stateless election route to unauthenticated open route.
carlschroedl e11ea23
Exposed BFF Election API in Swagger. Removed auth from the Swagger do…
carlschroedl c43f7d6
Adjusted for breaking changes in Tideman library
carlschroedl 98e7df9
Restricted logo display to homepage to enable logo-less BFF form view.
carlschroedl 605f041
Added user interface for trying BFF elections.
carlschroedl bea79e3
Discarding local changes to vendor directory during build.
carlschroedl 099ff09
Added basic integration tests for BFF API and form.
carlschroedl 24c034d
Minor code quality fixes.
carlschroedl c2ed0ca
Auto-sizing height of textareas on BFF Try page. Some minor markup ch…
carlschroedl b223a66
Styling tweak.
carlschroedl 4556fa9
Updated redirect on login
carlschroedl ee387c3
Improving post-login welcome page UX.
carlschroedl File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,72 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers; | ||
|
||
use Illuminate\Routing\Controller as BaseController; | ||
use Carbon\Carbon; | ||
use App\Election; | ||
use App\Elector; | ||
use Illuminate\Http\Request; | ||
use Illuminate\Http\Response; | ||
use Illuminate\Support\Facades\Auth; | ||
use PivotLibre\Tideman\BffElectionRunner; | ||
|
||
class BffElectionController extends BaseController | ||
{ | ||
/** | ||
* Run a Ranked Pairs election via BFF ballots. | ||
* | ||
* @SWG\Post( | ||
* tags={"BFF Election Result"}, | ||
* path="/open/try", | ||
* summary="Run an election using BFF ballots", | ||
* operationId="calculateResult", | ||
* consumes={"application/x-www-form-urlencoded"}, | ||
* produces={"text/plain"}, | ||
* @SWG\Parameter( | ||
* name="ballots", | ||
* in="formData", | ||
* description="One or more BFF ballots, one on each line", | ||
* required=true, | ||
* type="string" | ||
* ), | ||
* @SWG\Parameter( | ||
* name="tieBreaker", | ||
* in="formData", | ||
* description="One BFF Ballot for resolving intermediate ties", | ||
* required=true, | ||
* type="string" | ||
* ), | ||
* @SWG\Response(response="200", description="Success", @SWG\Schema( | ||
* type="string", | ||
* description="JSON with a key `result` whose value is a BFF election result" | ||
* )), | ||
* @SWG\Response(response="400", description="Bad Request") | ||
* ) | ||
* | ||
* @return \Illuminate\Http\Response | ||
*/ | ||
public function calculateResult(Request $request) | ||
{ | ||
if (!$request->has('tieBreaker')) { | ||
abort(400, "tieBreaker is a required parameter"); | ||
} else { | ||
$tieBreaker = $request->input('tieBreaker'); | ||
} | ||
if (!$request->has('ballots')) { | ||
abort(400, "ballots is a required parameter"); | ||
} else { | ||
$ballots = $request->input('ballots'); | ||
} | ||
|
||
$runner = new BffElectionRunner(); | ||
$runner->setTieBreaker($tieBreaker); | ||
$result = $runner->run($ballots); | ||
return $result; | ||
} | ||
|
||
public function form() | ||
{ | ||
return view('bff_form'); | ||
} | ||
} |
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
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
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
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed this because I wanted the
/open
-prefixed services to be featured in the Swagger documentation, not just the/api
-prefixed services.