From 0e6c286cc7b059d2a124fc2ba856ef46f2d36ee0 Mon Sep 17 00:00:00 2001 From: Dreej <49828078+dreej-net@users.noreply.github.com> Date: Sun, 12 Sep 2021 05:31:49 +0200 Subject: [PATCH 01/14] Structure API implementation - New Resource --- .../Resources/CorporationStructureResource | 54 +++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 src/Http/Resources/CorporationStructureResource diff --git a/src/Http/Resources/CorporationStructureResource b/src/Http/Resources/CorporationStructureResource new file mode 100644 index 0000000..e0ddef7 --- /dev/null +++ b/src/Http/Resources/CorporationStructureResource @@ -0,0 +1,54 @@ + $this->info->name, + + // type_name = "Athanor" + // nothing returns the 'name' in invType Model, and i couldn't find the create_inType to get the columns names + // so my bet is there's a column 'name' in invType Table + // but i'd have to put the type_id which is 35835 for Athanor f.ex + // so i'm lost about how the thingy gets it, if it ever gets it this way... i feel like there's something missing + 'type_name'=> $this->type->typeName + // what is the difference between 'type_id' and 'typeID' btw ? + + // system_name = "Jita" + 'system_name'=>$this->solar_system->name, + + // in base corporation_structure Table + 'type_id'=> $this->type_id, // can be skipped if i get name (string) + 'system_id'=> $this->system_id, // can be skipped if i get name (string) + + 'structure_id'=> $this->structure_id, + 'fuel_expires'=>$this->fuel_expires, + 'state'=>$this->state, + 'state_timer_start'=>$this->state_timer_start, + 'state_timer_end'=>$this->state_timer_end, + 'unanchors_at'=>$this->unanchors_at, + 'reinforce_hour'=>$this->reinforce_hour, + 'next_reinforce_hour'=>$this->next_reinforce_hour, + 'next_reinforce_apply'=>$this->next_reinforce_apply, + ]; + } +} From 982cba1d71424e46f8eb29d00b787b1464b36962 Mon Sep 17 00:00:00 2001 From: Dreej <49828078+dreej-net@users.noreply.github.com> Date: Sun, 12 Sep 2021 05:32:42 +0200 Subject: [PATCH 02/14] Structure API implementation - New Route --- src/Http/routes.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Http/routes.php b/src/Http/routes.php index 09435f9..895544d 100644 --- a/src/Http/routes.php +++ b/src/Http/routes.php @@ -124,6 +124,7 @@ Route::group(['prefix' => 'corporation'], function () { Route::get('/assets/{corporation_id}')->uses('CorporationController@getAssets'); + Route::get('/structures/{corporation_id}')->uses('CorporationController@getStructures'); Route::get('/contacts/{corporation_id}')->uses('CorporationController@getContacts'); Route::get('/contracts/{corporation_id}')->uses('CorporationController@getContracts'); Route::get('/industry/{corporation_id}')->uses('CorporationController@getIndustry'); From d178574eff911cb5be8998ee4da570f357288b74 Mon Sep 17 00:00:00 2001 From: Dreej <49828078+dreej-net@users.noreply.github.com> Date: Sun, 12 Sep 2021 05:34:20 +0200 Subject: [PATCH 03/14] Structure API implementation - New Function --- .../Api/v2/CorporationController.php | 68 +++++++++++++++++++ 1 file changed, 68 insertions(+) diff --git a/src/Http/Controllers/Api/v2/CorporationController.php b/src/Http/Controllers/Api/v2/CorporationController.php index c5625a2..bd975b3 100644 --- a/src/Http/Controllers/Api/v2/CorporationController.php +++ b/src/Http/Controllers/Api/v2/CorporationController.php @@ -26,6 +26,7 @@ use Seat\Api\Http\Resources\ContactResource; use Seat\Api\Http\Resources\ContractResource; use Seat\Api\Http\Resources\CorporationSheetResource; +use Seat\Api\Http\Resources\CorporationStructure; use Seat\Api\Http\Resources\IndustryResource; use Seat\Api\Http\Resources\MemberTrackingResource; use Seat\Api\Http\Traits\Filterable; @@ -114,6 +115,73 @@ public function getAssets(int $corporation_id) return Resource::collection($query->paginate()); } + /** + * @OA\Get( + * path="/v2/corporation/strctures/{corporation_id}", + * tags={"Structures"}, + * summary="Get a paginated list of structures for a corporation", + * description="Returns a list of structures", + * security={ + * {"ApiKeyAuth": {}} + * }, + * @OA\Parameter( + * name="corporation_id", + * description="Corporation id", + * required=true, + * @OA\Schema( + * type="integer" + * ), + * in="path" + * ), + * @OA\Parameter( + * in="query", + * name="$filter", + * description="Query filter following OData format", + * @OA\Schema( + * type="string" + * ) + * ), + * @OA\Response(response=200, description="Successful operation", + * @OA\JsonContent( + * type="object", + * @OA\Property( + * type="array", + * property="data", + * @OA\Items(ref="#/components/schemas/CorporationStructure") + * ), + * @OA\Property( + * property="links", + * ref="#/components/schemas/ResourcePaginatedLinks" + * ), + * @OA\Property( + * property="meta", + * ref="#/components/schemas/ResourcePaginatedMetadata" + * ) + * ) + * ), + * @OA\Response(response=400, description="Bad request"), + * @OA\Response(response=401, description="Unauthorized"), + * ) + * + * @param int $corporation_id + * + * @return \Illuminate\Http\Resources\Json\AnonymousResourceCollection + */ + public function getStructures(int $corporation_id) + { + request()->validate([ + '$filter' => 'string', + ]); + + $query = CorporationStructure::with('type', 'info', 'solar_system') // = CorporationStructure Model, including type() & info() & solar_system() functions + ->where('corporation_id', $corporation_id) + ->where(function ($sub_query) { + $this->applyFilters(request(), $sub_query); + }); + + return Resource::collection($query->paginate()); + } + /** * @OA\Get( * path="/v2/corporation/contacts/{corporation_id}", From f5683de1ae9309863f66b1a1d19e43e6bb2153b2 Mon Sep 17 00:00:00 2001 From: Dreej <49828078+dreej-net@users.noreply.github.com> Date: Sun, 12 Sep 2021 12:27:56 +0200 Subject: [PATCH 04/14] Structure + MiningExtraction get() functions --- .../Api/v2/CorporationController.php | 27 ++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/src/Http/Controllers/Api/v2/CorporationController.php b/src/Http/Controllers/Api/v2/CorporationController.php index bd975b3..4cc607d 100644 --- a/src/Http/Controllers/Api/v2/CorporationController.php +++ b/src/Http/Controllers/Api/v2/CorporationController.php @@ -26,7 +26,7 @@ use Seat\Api\Http\Resources\ContactResource; use Seat\Api\Http\Resources\ContractResource; use Seat\Api\Http\Resources\CorporationSheetResource; -use Seat\Api\Http\Resources\CorporationStructure; +use Seat\Api\Http\Resources\CorporationStructure; // getStructures use Seat\Api\Http\Resources\IndustryResource; use Seat\Api\Http\Resources\MemberTrackingResource; use Seat\Api\Http\Traits\Filterable; @@ -39,6 +39,7 @@ use Seat\Eveapi\Models\Market\CorporationOrder; use Seat\Eveapi\Models\Wallet\CorporationWalletJournal; use Seat\Eveapi\Models\Wallet\CorporationWalletTransaction; +use Seat\Web\Models\UniverseMoonReport; // getMiningExtractions /** * Class CorporationController. @@ -382,6 +383,30 @@ public function getIndustry(int $corporation_id) return IndustryResource::collection($query->paginate()); } + + /** + * + */ + public function getMiningExtractions(int $corporation_id) + { + request()->validate([ + '$filter' => 'string', + ]); + + $query = UniverseMoonReport::with('content', 'moon', 'moon.solar_system', 'moon.constellation', + 'moon.region', 'moon.extraction', 'moon.extraction.structure', 'moon.extraction.structure.info') + ->whereHas('moon.extraction.structure', function ($query) use ($corporation_id) { + $query->where('corporation_id', $corporation_id); + }) + ->whereHas('moon.extraction', function ($query) { + $query->where('natural_decay_time', '>', carbon()->subSeconds(CorporationIndustryMiningExtraction::THEORETICAL_DEPLETION_COUNTDOWN)); + }) + ->where(function ($sub_query) { + $this->applyFilters(request(), $sub_query); + }); + + return CorporationMiningExtractionResource::collection($query->paginate()); + } /** * @OA\Get( From 5d64535d6c495913cb824ae60db007fedc70fd1a Mon Sep 17 00:00:00 2001 From: Dreej <49828078+dreej-net@users.noreply.github.com> Date: Sun, 12 Sep 2021 12:30:12 +0200 Subject: [PATCH 05/14] MiningExtraction API implementation - New Resource --- .../CorporationMiningExtractionResource.php | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 src/Http/Resources/CorporationMiningExtractionResource.php diff --git a/src/Http/Resources/CorporationMiningExtractionResource.php b/src/Http/Resources/CorporationMiningExtractionResource.php new file mode 100644 index 0000000..eea86f1 --- /dev/null +++ b/src/Http/Resources/CorporationMiningExtractionResource.php @@ -0,0 +1,35 @@ +$this->moon.solar_system->name, + 'moon_name'=>$this->moon->name, + 'structure_name'=>$this->moon.extraction.structure.info->name, + + 'extraction_start_time'=>$this->moon.extraction->extraction_start_time, + 'chunk_arrival_time'=>$this->moon.extraction->chunk_arrival_time, + 'natural_decay_time'=>$this->moon.extraction->natural_decay_time, + + 'content'=>$this->content + ]; + } +} From 0ed4cb01776e2792e5fbe4aea31f761050e85e84 Mon Sep 17 00:00:00 2001 From: Dreej <49828078+dreej-net@users.noreply.github.com> Date: Sun, 12 Sep 2021 12:33:53 +0200 Subject: [PATCH 06/14] Structure & MiningExtraction API implementation - New Routes --- src/Http/routes.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Http/routes.php b/src/Http/routes.php index 895544d..934d0ee 100644 --- a/src/Http/routes.php +++ b/src/Http/routes.php @@ -128,6 +128,7 @@ Route::get('/contacts/{corporation_id}')->uses('CorporationController@getContacts'); Route::get('/contracts/{corporation_id}')->uses('CorporationController@getContracts'); Route::get('/industry/{corporation_id}')->uses('CorporationController@getIndustry'); + Route::get('/mining-extractions/{corporation_id}')->uses('CorporationController@getMiningExtractions'); Route::get('/killmails/{corporation_id}')->uses('KillmailsController@getCorporationKillmails'); Route::get('/market-orders/{corporation_id}')->uses('CorporationController@getMarketOrders'); Route::get('/member-tracking/{corporation_id}')->uses('CorporationController@getMemberTracking'); From 7dd8aadac29fade056fe4510216637553cba87a1 Mon Sep 17 00:00:00 2001 From: Dreej <49828078+dreej-net@users.noreply.github.com> Date: Sun, 12 Sep 2021 12:40:23 +0200 Subject: [PATCH 07/14] Update routes.php changed mining-extractions to extractions --- src/Http/routes.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Http/routes.php b/src/Http/routes.php index 934d0ee..38d7ae4 100644 --- a/src/Http/routes.php +++ b/src/Http/routes.php @@ -128,7 +128,7 @@ Route::get('/contacts/{corporation_id}')->uses('CorporationController@getContacts'); Route::get('/contracts/{corporation_id}')->uses('CorporationController@getContracts'); Route::get('/industry/{corporation_id}')->uses('CorporationController@getIndustry'); - Route::get('/mining-extractions/{corporation_id}')->uses('CorporationController@getMiningExtractions'); + Route::get('/extractions/{corporation_id}')->uses('CorporationController@getMiningExtractions'); Route::get('/killmails/{corporation_id}')->uses('KillmailsController@getCorporationKillmails'); Route::get('/market-orders/{corporation_id}')->uses('CorporationController@getMarketOrders'); Route::get('/member-tracking/{corporation_id}')->uses('CorporationController@getMemberTracking'); From 98e8e5c860ba7a42408d7ab22b507b33ce0239f2 Mon Sep 17 00:00:00 2001 From: Dreej <49828078+dreej-net@users.noreply.github.com> Date: Sun, 12 Sep 2021 12:41:28 +0200 Subject: [PATCH 08/14] Update CorporationMiningExtractionResource.php --- .../Resources/CorporationMiningExtractionResource.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Http/Resources/CorporationMiningExtractionResource.php b/src/Http/Resources/CorporationMiningExtractionResource.php index eea86f1..2906203 100644 --- a/src/Http/Resources/CorporationMiningExtractionResource.php +++ b/src/Http/Resources/CorporationMiningExtractionResource.php @@ -21,13 +21,13 @@ public function toArray($request) { return [ - 'system_name'=>$this->moon.solar_system->name, + 'system_name'=>$this->moon->solar_system->name, 'moon_name'=>$this->moon->name, - 'structure_name'=>$this->moon.extraction.structure.info->name, + 'structure_name'=>$this->moon->extraction->structure->info->name, - 'extraction_start_time'=>$this->moon.extraction->extraction_start_time, - 'chunk_arrival_time'=>$this->moon.extraction->chunk_arrival_time, - 'natural_decay_time'=>$this->moon.extraction->natural_decay_time, + 'extraction_start_time'=>$this->moon->extraction->extraction_start_time, + 'chunk_arrival_time'=>$this->moon->extraction->chunk_arrival_time, + 'natural_decay_time'=>$this->moon->extraction->natural_decay_time, 'content'=>$this->content ]; From 6e510848eec84dd2f04d62ce2717b4082b178719 Mon Sep 17 00:00:00 2001 From: Dreej <49828078+dreej-net@users.noreply.github.com> Date: Sun, 12 Sep 2021 12:50:30 +0200 Subject: [PATCH 09/14] Rename CorporationStructureResource to CorporationStructureResource.php --- ...porationStructureResource => CorporationStructureResource.php} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename src/Http/Resources/{CorporationStructureResource => CorporationStructureResource.php} (100%) diff --git a/src/Http/Resources/CorporationStructureResource b/src/Http/Resources/CorporationStructureResource.php similarity index 100% rename from src/Http/Resources/CorporationStructureResource rename to src/Http/Resources/CorporationStructureResource.php From 49f802a7a53587b343d6dfcf21870252c3d6711b Mon Sep 17 00:00:00 2001 From: Dreej <49828078+dreej-net@users.noreply.github.com> Date: Sun, 12 Sep 2021 17:58:39 +0200 Subject: [PATCH 10/14] Update CorporationMiningExtractionResource.php --- src/Http/Resources/CorporationMiningExtractionResource.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Http/Resources/CorporationMiningExtractionResource.php b/src/Http/Resources/CorporationMiningExtractionResource.php index 2906203..0a8372c 100644 --- a/src/Http/Resources/CorporationMiningExtractionResource.php +++ b/src/Http/Resources/CorporationMiningExtractionResource.php @@ -23,7 +23,7 @@ public function toArray($request) return [ 'system_name'=>$this->moon->solar_system->name, 'moon_name'=>$this->moon->name, - 'structure_name'=>$this->moon->extraction->structure->info->name, + 'structure_name'=>$this->moon->extraction->structure->info->typeName, 'extraction_start_time'=>$this->moon->extraction->extraction_start_time, 'chunk_arrival_time'=>$this->moon->extraction->chunk_arrival_time, From b06e78571d80332c69488328911787fee5810b19 Mon Sep 17 00:00:00 2001 From: Dreej <49828078+dreej-net@users.noreply.github.com> Date: Sun, 12 Sep 2021 17:59:07 +0200 Subject: [PATCH 11/14] Update CorporationMiningExtractionResource.php --- src/Http/Resources/CorporationMiningExtractionResource.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Http/Resources/CorporationMiningExtractionResource.php b/src/Http/Resources/CorporationMiningExtractionResource.php index 0a8372c..2906203 100644 --- a/src/Http/Resources/CorporationMiningExtractionResource.php +++ b/src/Http/Resources/CorporationMiningExtractionResource.php @@ -23,7 +23,7 @@ public function toArray($request) return [ 'system_name'=>$this->moon->solar_system->name, 'moon_name'=>$this->moon->name, - 'structure_name'=>$this->moon->extraction->structure->info->typeName, + 'structure_name'=>$this->moon->extraction->structure->info->name, 'extraction_start_time'=>$this->moon->extraction->extraction_start_time, 'chunk_arrival_time'=>$this->moon->extraction->chunk_arrival_time, From 49488b1f1c2dc19710f2d1880e2a74746597adb7 Mon Sep 17 00:00:00 2001 From: Dreej <49828078+dreej-net@users.noreply.github.com> Date: Mon, 13 Sep 2021 05:38:52 +0200 Subject: [PATCH 12/14] Update CorporationStructureResource.php --- .../CorporationStructureResource.php | 21 +++++-------------- 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/src/Http/Resources/CorporationStructureResource.php b/src/Http/Resources/CorporationStructureResource.php index e0ddef7..0c123df 100644 --- a/src/Http/Resources/CorporationStructureResource.php +++ b/src/Http/Resources/CorporationStructureResource.php @@ -21,26 +21,15 @@ public function toArray($request) { return [ - // name = "playerInputString" (not 'Athanor' / 'Fortizar' / ...) - // i feel like it would be in CorporationAsset, since you can't get a Structure Name if it is not public 'name'=> $this->info->name, - - // type_name = "Athanor" - // nothing returns the 'name' in invType Model, and i couldn't find the create_inType to get the columns names - // so my bet is there's a column 'name' in invType Table - // but i'd have to put the type_id which is 35835 for Athanor f.ex - // so i'm lost about how the thingy gets it, if it ever gets it this way... i feel like there's something missing + 'structure_id'=> $this->structure_id, + 'type_name'=> $this->type->typeName - // what is the difference between 'type_id' and 'typeID' btw ? + 'type_id'=> $this->type_id, - // system_name = "Jita" 'system_name'=>$this->solar_system->name, - - // in base corporation_structure Table - 'type_id'=> $this->type_id, // can be skipped if i get name (string) - 'system_id'=> $this->system_id, // can be skipped if i get name (string) - - 'structure_id'=> $this->structure_id, + 'system_id'=> $this->system_id, + 'fuel_expires'=>$this->fuel_expires, 'state'=>$this->state, 'state_timer_start'=>$this->state_timer_start, From 5df54a5d8d875ad2e8455906601b8749d77d74d9 Mon Sep 17 00:00:00 2001 From: Dreej <49828078+dreej-net@users.noreply.github.com> Date: Mon, 13 Sep 2021 05:46:27 +0200 Subject: [PATCH 13/14] Update CorporationStructureResource.php --- .../CorporationStructureResource.php | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/Http/Resources/CorporationStructureResource.php b/src/Http/Resources/CorporationStructureResource.php index 0c123df..989bed4 100644 --- a/src/Http/Resources/CorporationStructureResource.php +++ b/src/Http/Resources/CorporationStructureResource.php @@ -30,6 +30,27 @@ public function toArray($request) 'system_name'=>$this->solar_system->name, 'system_id'=> $this->system_id, + //// + // + // Proposing : + // + // 'structure' => [ + // 'name' => $this->info->name, + // 'id' => $this->structure_id + // ], + // + // 'type' => [ + // 'name' => $this->type->typeName, + // 'id' => $this->type_id + // ], + // + // 'solar_system' => [ + // 'name' => $this->solar_system->name, + // 'id' => $this->system_id + // ], + // + //// + 'fuel_expires'=>$this->fuel_expires, 'state'=>$this->state, 'state_timer_start'=>$this->state_timer_start, From d6af7c2c0aa85df37b22acb7c3c67fe332a751ec Mon Sep 17 00:00:00 2001 From: Dreej <49828078+dreej-net@users.noreply.github.com> Date: Mon, 13 Sep 2021 05:57:20 +0200 Subject: [PATCH 14/14] Update CorporationController.php --- src/Http/Controllers/Api/v2/CorporationController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Http/Controllers/Api/v2/CorporationController.php b/src/Http/Controllers/Api/v2/CorporationController.php index 4cc607d..c159976 100644 --- a/src/Http/Controllers/Api/v2/CorporationController.php +++ b/src/Http/Controllers/Api/v2/CorporationController.php @@ -174,7 +174,7 @@ public function getStructures(int $corporation_id) '$filter' => 'string', ]); - $query = CorporationStructure::with('type', 'info', 'solar_system') // = CorporationStructure Model, including type() & info() & solar_system() functions + $query = CorporationStructure::with('type', 'info', 'solar_system') ->where('corporation_id', $corporation_id) ->where(function ($sub_query) { $this->applyFilters(request(), $sub_query);