Skip to content
Open
Show file tree
Hide file tree
Changes from 31 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
d0ec640
feat: add ci/actions and fix migrations
PThorpe92 Nov 1, 2023
6b85d4a
fix: dependencies errors building
PThorpe92 Nov 1, 2023
785ce10
chore: migrate canvas utilities from other repository
Aug 31, 2023
b98a37c
fix: typo in canvasUtil
Aug 31, 2023
c39a3b7
fix: upgraded to meet schema
PThorpe92 Sep 28, 2023
beb0b33
fix: finish migration to schema
PThorpe92 Sep 28, 2023
79b9370
fix: naming issues in CanvasUtil
PThorpe92 Sep 28, 2023
6f85d20
fix: continued work
PThorpe92 Oct 2, 2023
8250662
fix: controller name
PThorpe92 Oct 3, 2023
d888c93
fix: refacotor boilerplate from canvasServices
PThorpe92 Oct 4, 2023
7ba9b8b
fix: discussed changes
PThorpe92 Oct 4, 2023
0ebf147
fix items in review with nokie. PR closes UN-102
PThorpe92 Oct 6, 2023
e325dc0
remove misnamed file, update api routes
PThorpe92 Oct 6, 2023
32f7408
final touches
PThorpe92 Oct 10, 2023
32fbec8
move to namespace
PThorpe92 Oct 11, 2023
0a17c36
fix: remove redundant files
PThorpe92 Nov 1, 2023
08793d6
fix: attempt to fix ci/package.lock
PThorpe92 Nov 1, 2023
c7b3628
fix: lots of merge conflicts
PThorpe92 Nov 1, 2023
73ec0e9
fix: lots and lots of stuff
PThorpe92 Nov 1, 2023
933682b
fix: change .github workflow to reflect cwd
PThorpe92 Nov 1, 2023
a248138
feat: add seeders/factories and testing.md
PThorpe92 Nov 2, 2023
7e92115
fix: finish seeders. we can now seed every Model for testing
PThorpe92 Nov 2, 2023
aeb3a0c
feat: work on making tests pass (still work to be done)
PThorpe92 Nov 6, 2023
c5f2082
feat: add a couple tests
PThorpe92 Nov 7, 2023
f4404e4
fix: many bugs
PThorpe92 Nov 7, 2023
3f69c1e
fix: work on tests
PThorpe92 Nov 8, 2023
efb8f9f
Fix student model needing HasUuids
nokierae Nov 8, 2023
21b7c74
feat: work on tests
PThorpe92 Nov 8, 2023
85c79b2
fix: all but 2 tests
PThorpe92 Nov 9, 2023
4f8b8a3
fix: lockfile for build on ubuntu; tests still fail
PThorpe92 Nov 9, 2023
09ba771
major fixes/updates, many bugs fixed
Nov 9, 2023
b55bdd8
fix: add consumerProviderResource for ULv1
PThorpe92 Nov 15, 2023
f21e73b
fix: change to foreign UUID for student mapping constraint
PThorpe92 Nov 16, 2023
ac85dd5
fix: route issue and controller for platform_connections
PThorpe92 Nov 16, 2023
3594d92
feat: add platformConnection tests + fix surrounding issues
PThorpe92 Nov 16, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions .env.testing
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
APP_NAME=Laravel
APP_ENV=local
APP_KEY=base64:UlGssQGrsDgLbYxxgWVAlVC6d/X22Ecr2W+GlqFK5i8=
APP_DEBUG=true
APP_URL=http://localhost

LOG_CHANNEL=stack
LOG_DEPRECATIONS_CHANNEL=null
LOG_LEVEL=debug

DB_CONNECTION=sqlite

BROADCAST_DRIVER=log
CACHE_DRIVER=file
FILESYSTEM_DISK=local
QUEUE_CONNECTION=sync
SESSION_DRIVER=database
SESSION_LIFETIME=120

MEMCACHED_HOST=127.0.0.1

35 changes: 35 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Build Laravel PHP Project

on:
push:
branches: ["main"]
pull_request:
branches: ["main"]

jobs:
phpunit:
runs-on: ubuntu-latest
container:
image: kirschbaumdevelopment/laravel-test-runner:8.2

steps:
- uses: actions/checkout@v1
with:
fetch-depth: 1

- name: Install front-end dependencies
run: |
npm install
npm run build

- name: Install composer dependencies
run: |
composer update
composer install
- name: Prepare Laravel Application
run: |
cp .env.testing .env
php artisan migrate:fresh --env=testing

- name: Run Testsuite
run: php artisan test
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ yarn-error.log
/.fleet
/.idea
/.vscode
D2L_api.md
11 changes: 11 additions & 0 deletions app/Enums/PlatformConnectionType.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

namespace App\Enums;


enum PlatformConnectionType: string
{
case ENABLED = 'enabled';
case DISABLED = 'disabled';
case ARCHIVED = 'archived';
}
16 changes: 8 additions & 8 deletions app/Http/Controllers/Api/V1/ConsumerPlatformController.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class ConsumerPlatformController extends Controller
*/
public function index(): \Illuminate\Http\Resources\Json\AnonymousResourceCollection
{
return ConsumerPlatformResource::collection(ConsumerPlatform::all(['*']));
return ConsumerPlatformResource::collection(ConsumerPlatform::all());
}

/**
Expand All @@ -51,7 +51,7 @@ public function store(StoreConsumerPlatformRequest $request): ConsumerPlatformRe
* @param string $id
* @return ConsunmerPlatformResource
*/
public function show(ShowConsumerPlatformRequest $id): ConsumerPlatformResource
public function show(string $id): ConsumerPlatformResource
{
try {
$consumerPlatform = ConsumerPlatform::where('id', $id)->first();
Expand All @@ -62,16 +62,16 @@ public function show(ShowConsumerPlatformRequest $id): ConsumerPlatformResource
}

/**
* Update the specified resource in storage
* PATCH /api/v1/consumer_platforms/{id}
* Update the specified resource in storage (id in path, JSON request body)
* PATCH /api/v1/consumer_platforms/{id}/{request_body}
* @param UpdateConsumerPlatformRequest $request
* @return \Illuminate\Http\JsonResponse
* @throws \Exception
*/
public function edit(UpdateConsumerPlatformRequest $request): \Illuminate\Http\JsonResponse
public function update(string $id, UpdateConsumerPlatformRequest $request): \Illuminate\Http\JsonResponse
{
$validated = $request->validated();
$consumerPlatform = ConsumerPlatform::where('id', $validated['id'])->first();
$consumerPlatform = ConsumerPlatform::where('id', $id)->first();
if ($consumerPlatform === null) {
return response()->json(PLATFORM_NOT_FOUND, 404);
}
Expand All @@ -86,9 +86,9 @@ public function edit(UpdateConsumerPlatformRequest $request): \Illuminate\Http\J
* @return \Illuminate\Http\JsonResponse
* @throws \Exception
*/
public function destroy(ShowConsumerPlatformRequest $request): \Illuminate\Http\JsonResponse
public function destroy(string $id): \Illuminate\Http\JsonResponse
{
$consumerPlatform = ConsumerPlatform::where('id', $request->input('id'))->first();
$consumerPlatform = ConsumerPlatform::where('id', $id)->first();
if ($consumerPlatform === null) {
return response()->json(PLATFORM_NOT_FOUND, 404);
} else {
Expand Down
1 change: 0 additions & 1 deletion app/Http/Controllers/Api/V1/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Routing\Controller as BaseController;


class Controller extends BaseController
{
use AuthorizesRequests, ValidatesRequests;
Expand Down
64 changes: 29 additions & 35 deletions app/Http/Controllers/Api/V1/PlatformConnectionController.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@
use App\Http\Requests\UpdatePlatformConnectionRequest;
use App\Models\PlatformConnection;
use App\Http\Resources\PlatformConnectionResource;

use Illuminate\Support\Facades\DB;

class PlatformConnectionController extends Controller
{

/* Get all platform connections */
//*************************************************************
// GET: /api/platform_connection/
// GET: /api/v1/platform_connection/
// Request $req example:
// { "consumer_id": 1 }
// *************************************************************
Expand All @@ -25,6 +25,21 @@ public function index(): \Illuminate\Http\Resources\Json\AnonymousResourceCollec
return PlatformConnectionResource::collection(PlatformConnection::all());
}

// look up a relative connection per consumer platform id
// *************************************************************
// GET: /api/v1/consumer_platforms/{id}/platform_connection
// Request $req example:
// "consumer_id": 1 || "provider_id": 1
// *************************************************************
public function show(string $id): PlatformConnectionResource
{
$platform = PlatformConnection::where('consumer_platform_id', $id)->first();
if (!$platform) {
return response()->json(['error' => 'No matching platform connection found'], 401);
}
return new PlatformConnectionResource($platform);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@PThorpe92 in order to be able to return the requisite Provider Platform data (and Connection state) to the v.1 UI this needs to return the ConsumerProviderResource::collection that was in the #3 request that you had integrated into your branch earlier when we collaborated.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ConsumerProviderResource?

The show function you have in the link returns

public function show(ConsumerPlatform $consumerPlatform)
    {
        return ConsumerPlatformResource::make($consumerPlatform);
    }

So because this is a show function and you have specified the ID in the URL, it should return a collection of all that consumer platforms connections? that does make sense.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. Additionally it gets the state value of the Platform Connection and adds that to the json Provider Platform (for that particular Consumer Platform) response data

}

/* Create a new platform connection */
//*************************************************************
// POST: /api/v1/platform_connection/
Expand All @@ -33,62 +48,41 @@ public function index(): \Illuminate\Http\Resources\Json\AnonymousResourceCollec
// *************************************************************
public function store(StorePlatformConnectionRequest $req): PlatformConnectionResource
{
$validated = $req->validated();
$exists = PlatformConnection::where($validated)->first();
if ($exists) {
return response()->json(['error' => 'Platform connection already exists'], 401);
}
try {
$platform_connection = PlatformConnection::create($req->validated());
return new PlatformConnectionResource($platform_connection);
$platform_connection = new PlatformConnection($req->validated());
} catch (\Exception) {
return response()->json(INVALID_REQUEST_BODY, 401);
}
}

// Get a specific platform connection by consumer or provider id
// *************************************************************
// GET: /api/v1/platform_connection/{id}
// Request $req example:
// "consumer_id": 1 || "provider_id": 1
// *************************************************************
public function show(ShowPlatformConnectionRequest $req): PlatformConnectionResource
{
try {
$validated = $req->validated();
return new PlatformConnectionResource(PlatformConnection::where($validated)->first());
} catch (\Exception) {
return response()->json(INVALID_REQUEST_BODY, 401);
}
return new PlatformConnectionResource($platform_connection);
}

// Update a platform connection (The only possible update here would be the state)
// *************************************************************
// PUT: /api/v1/platform_connection/{request_body}
// PUT: /api/v1/consumer_platforms/{id}/platform_connections/{request_body}
// Request $req example:
// { "consumer_id": 1, "provider_id": 1, "state": "enabled" }
// *************************************************************
public function update(UpdatePlatformConnectionRequest $req): PlatformConnectionResource
public function update(string $id, UpdatePlatformConnectionRequest $req): PlatformConnectionResource
{
// they should have both the id's, and a new state
$conn = PlatformConnection::where('consumer_platform_id', $id)->first();
$validated = $req->validated();
$PlatformConnection = PlatformConnection::where($validated)->first();
$PlatformConnection->state = $validated['state'];
return new PlatformConnectionResource($PlatformConnection->save());
if (!$PlatformConnection) {
return response()->json(['error' => 'No matching platform connection found'], 401);
}
$conn->update('state', $validated['state']);
$conn->save();
return new PlatformConnectionResource($conn);
}

// Delete a platform connection
// *************************************************************
// DELETE: /api/v1/platform_connection/{request_body}
// DELETE: /api/v1/consumer_platforms/{id}/platform_connection/{request_body}
// Request $req example:
// { "consumer_id": 1, "provider_id": 1 }
// *************************************************************
public function delete(ShowPlatformConnectionRequest $req): \Illuminate\Http\JsonResponse
public function delete(string $id): \Illuminate\Http\JsonResponse
{
try {
PlatformConnectionRequest::where($req->validated())->delete();
PlatformConnection::where('consumer_platform_id', $id)->delete();
return response()->json(['success' => 'Platform connection deleted successfully'], 200);
} catch (\Exception) {
return response()->json(INVALID_REQUEST_BODY, 401);
Expand Down
52 changes: 25 additions & 27 deletions app/Http/Controllers/Api/V1/ProviderPlatformController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@
namespace App\Http\Controllers\Api\V1;

use App\Models\ProviderPlatform;
use Illuminate\Http\Request;
use App\Http\Controllers\Api\V1\Controller;
use App\Http\Requests\StoreProviderPlatformRequest;
use App\Http\Requests\ShowProviderPlatformRequest;
use App\Http\Resources\ProviderPlatformResource;

class ProviderPlatformController extends Controller
Expand All @@ -18,74 +16,74 @@ class ProviderPlatformController extends Controller
// ****************************************************
public function index()
{
return ProviderPlatformResource::collection(ProviderPlatform::all(['*']));
return ProviderPlatformResource::collection(ProviderPlatform::all());
}
//


// List information on a specific provider platform
// ****************************************************
// GET: /api/provider_platforms/{request_body}
// GET: /api/v1/provider_platforms/{id}
// @param Request $request
// @return JsonResponse
// ****************************************************
public function show(ShowProviderPlatformRequest $request, $id): ProviderPlatformResource|\Illuminate\Http\JsonResponse
public function show(string $id): ProviderPlatformResource|\Illuminate\Http\JsonResponse
{
$providerPlatform = ProviderPlatform::where('id', $id)->first();
$providerPlatform = ProviderPlatform::where('id', $id)->get()->first();

if ($providerPlatform) {
return new ProviderPlatformResource($providerPlatform);
return ProviderPlatformResource::make($providerPlatform);
} else {
return response()->json(INVALID_REQUEST_BODY, 401);
}
}
// Create a new provider platform (does not register connection)

// Create a new provider platform
// ****************************************************
// POST: /api/provider_platform/{request_body}
// Request $request
// ****************************************************
public function store(StoreProviderPlatformRequest $req): ProviderPlatformResource
{
try {
$validated = $req->validated();
} catch (\Exception) {
$valid = $req->validated();
$provider = new ProviderPlatform($valid);
if (!$valid) {
return response()->json(INVALID_REQUEST_BODY, 401);
}
$provider = ProviderPlatform::create($validated);
// Create a new platform connection.
$provider->save();
return new ProviderPlatformResource($provider);
}

// Update a provider platform
// Update a provider platform (require all fields in JSON request body)
// ****************************************************
// PUT: /api/provider_platform/{request_body}
// PUT: /api/provider_platform/{id} {request_body}
// @param Request $request
// @return JsonResponse
// Request $request
// ****************************************************
public function update(StoreProviderPlatformRequest $request)
public function update(string $id, StoreProviderPlatformRequest $request): ProviderPlatformResource | \Illuminate\Http\JsonResponse
{
$validated = $request->validated();
$providerPlatform = ProviderPlatform::where($validated)->first();
$providerPlatform = ProviderPlatform::where('id', $id)->first();
if (!$providerPlatform) {
return response()->json(['error' => 'Invalid provider ID'], 401);
return response()->json(['error' => 'Invalid provider platform ID'], 401);
} else {
$providerPlatform->update($validated);
return new ProviderPlatformResource($providerPlatform);
return ProviderPlatformResource::make($providerPlatform);
}
}

// Delete a provider platform
// Delete a provider platform (use id from path parameter, not request body)
// ****************************************************
// DELETE: /api/provider_platform/{request_body}
// Request $req example:
// { "provider_id": 1 }
// DELETE: /api/v1/provider_platform/{id}
// ****************************************************
public function destroy(Request $request, $providerId): \Illuminate\Http\JsonResponse
public function destroy(string $id): \Illuminate\Http\JsonResponse
{
$providerPlatform = ProviderPlatform::where('id', $providerId)->first();
$providerPlatform = ProviderPlatform::where('id', $id)->first();
if (!$providerPlatform) {
return response()->json(['error' => 'Invalid provider ID'], 401);
} else {
$providerPlatform->delete();
return response()->json(json_encode($providerPlatform));
return response()->json(json_encode(["success" => 'Provider Platform deleted successfully']), 200);
}
}
}
Loading