jump bridge fuel structure written

This commit is contained in:
2018-12-29 19:02:16 -06:00
parent 92a707190a
commit 8b856bc1f8
5 changed files with 175 additions and 1 deletions

View File

@@ -14,6 +14,7 @@ use App\Models\Esi\EsiScope;
use App\Models\Esi\EsiToken;
use App\Models\ScheduledTask\ScheduleJob;
use App\Models\Market\MonthlyMarketTax;
use App\Models\Mail\EveMail;
use Seat\Eseye\Cache\NullCache;
use Seat\Eseye\Configuration;
@@ -70,6 +71,7 @@ class SendMail extends Command
$bills = MonthlyMarketTax::where(['month' => $date->monthName, 'year' => $date->year])->get();
//For each of the bills send a mail out
foreach($bills as $bill) {
//Send a mail out with the bill
$subject = 'Market Taxes Owed';
$body = 'Month: ' .
$bill->month .

View File

@@ -91,4 +91,8 @@ class StructureController extends Controller
return view('structures.taxes')->with('totalTaxes', $totalTaxes);
}
public function displayJumpBridgeFuel() {
}
}

View File

@@ -0,0 +1,154 @@
<?php
namespace App\Library\Structures;
use App\Library\Esi\Esi;
use App\Models\Esi\EsiScope;
use App\Models\Esi\EsiToken;
use Seat\Eseye\Configuration;
use Seat\Eseye\Containers\EsiAuthentication;
use Seat\Eseye\Eseye;
use Seat\Eseye\Exceptions\RequestFailedException;
class JumpBridgeFuel {
private $charId;
private $corpId;
private $hasScopes;
public function construct($charId, $corpId) {
$this->charId = $charId;
$this->corpId = $corpId;
//Set ESI Scopes true or false whether we have the correct ones
$esi = new Esi();
if($esi->HaveEsiScope($this->charId, 'esi-assets.read_corporation_assets.v1') &&
$esi->HaveEsiScope($this->charId, 'esi-corporations.read_structures.v1')) {
$this->hasScopes = true;
} else {
$this->hasScopes = false;
}
}
public function GetCorrrectScopes() {
return $this->hasScopes;
}
public function GetStructureFuel() {
}
private function GetStructures($charId, $corpId) {
//Delcare the data array for returning
$data = array();
//Get a list of structures.
$config = config('esi');
//Get the token from the database
$token = EsiToken::where(['character_id' => $charId])->get(['refresh_token']);
//Setup the ESI authentication container
$authentication = new EsiAuthentication([
'client_id' => $config['client_id'],
'secret' => $config['secret'],
'refresh_token' => $token[0]->refresh_token,
]);
//Setup the ESI authentication container
$esi = new Eseye($authentication);
//set the ESI version we need to work with
$esi->setVersion('v3');
//Set our current page
$currentPage = 1;
//Set our default total pages, and will refresh this later
$totalPages = 1;
//If more than one page is found, decode the first, then the second
do {
//Try to gather the structures from ESI
try {
$structures = $esi->page($currentPage)
->invoke('get', '/corporations/{corporation_id}/structures/', [
'corporation_id' => $corpId,
]);
} catch(RequestFailedException $e) {
return null;
}
//Set the actual total pages after we performed the esi call
$totalPages = $structures->pages;
foreach($structures as $structure) {
if($structure->type_id == 35841) {
$data = array_push($data, $structure);
}
}
} while ($currentPage < $totalPages);
//Add structures to a data array for just jump bridge type, and return the data array
return $data;
}
private function GetAssets($corpId, $structures) {
//Delcare the data array for returning
$data = array();
//Get a list of structures.
$config = config('esi');
//Get the token from the database
$token = EsiToken::where(['character_id' => $charId])->get(['refresh_token']);
//Setup the ESI authentication container
$authentication = new EsiAuthentication([
'client_id' => $config['client_id'],
'secret' => $config['secret'],
'refresh_token' => $token[0]->refresh_token,
]);
//Setup the ESI authentication container
$esi = new Eseye($authentication);
//set the ESI version we need to work with
$esi->setVersion('v3');
//Set our current page
$currentPage = 1;
//Set our default total pages, and will refresh this later
$totalPages = 1;
//If more than one page is available we want to get all the pages
do {
try {
//Try to pull the data from ESI
$assets = $esi->page($currentPage)
->invoke('get', '/corporations/{corporation_id}/assets/', [
'corporation_id' => $corpId,
]);
} catch(RequestFailedException $e) {
//If ESI fails, we just return null
return null;
}
//Set the total number of pages
$totalPages = $assets->pages;
//For each entry, we only want to save the entries
foreach($assets as $asset) {
if($asset->type_id == 16273) {
//If the type id is correct then push the data onto the array
$data = array_push($data, $asset);
}
}
} while($currentPage < $totalPages);
//Return the list of assets, the structure the asset is in, and the division,
//to the calling function
return $data;
}
}
?>

View File

@@ -1,6 +1,6 @@
<?php
namespace App\Models;
namespace App\Models\Mail;
use Illuminate\Database\Eloquent\Model;

View File

@@ -104,6 +104,14 @@
@break
@endif
@endforeach
@foreach($scopes as $scope)
@if($scope->scope == 'esi-assets.read_corporation_assets.v1')
<div class="form-group col-md-6">
{{ Form::label('scopes[]', 'Corporation Assets') }}
{{ Form::checkbox('scopes[]', 'esi-assets.read_corporation_assets.v1', 'true') }}
</div>
@endif
@endforeach
@if($publicData == false)
<div class="form-group col-md-6">
@@ -159,6 +167,12 @@
{{ Form::checkbox('scopes[]', 'esi-markets.structure_markets.v1') }}
</div>
@endif
@if($corpAssets == false)
<div class="form-group col-md-6">
{{ Form::label('scopes[]', 'Corporation Assets') }}
{{ Form::checkbox('scopes[]', 'esi-assets.read_corporation_assets.v1') }}
</div>
@endif
{{ Form::submit('Submit', ['class' => 'btn btn-primary']) }}
{!! Form::close() !!}