diff --git a/app/Jobs/Commands/RentalMoons/UpdateRentalMoonPullJob.php b/app/Jobs/Commands/RentalMoons/UpdateRentalMoonPullJob.php new file mode 100644 index 000000000..1bcef60a9 --- /dev/null +++ b/app/Jobs/Commands/RentalMoons/UpdateRentalMoonPullJob.php @@ -0,0 +1,77 @@ +connection = 'redis'; + } + + /** + * Execute the job. + * + * @return void + */ + public function handle() + { + //Setup the configuration variable for ESI + $config = config('esi'); + //Setup the esi helper variable + $esiHelper = new Esi; + + //Check for the esi scope + if(!$esiHelper->HaveEsiScope($config['primary'], 'esi-industry.read_corporation_mining.v1')) { + //Send a mail to the holding toon to update the esi scopes + return null; + } + + //Get the refresh token + $token = $esiHelper->GetRefreshToken($config['primary']); + //Setup the esi authentication container + $esi = $esiHelper->SetupEsiAuthentication($token); + + try { + $responses = $esi->invoke('get', '/corporation/{corporation_id}/mining/extractions/', [ + 'corporation_id' => 98287666, + ]); + } catch(RequestExceptionFailed $e) { + return null; + } + + foreach($response as $response) { + AllianceRentalMoon::where([ + 'structure_id' => $response->structure_id, + ])->update([ + 'next_moon_pull' => $response->chunk_arrival_time, + ]); + } + } +}