working on jump bridge tax class
This commit is contained in:
@@ -10,6 +10,7 @@ use Seat\Eseye\Cache\NullCache;
|
||||
use Seat\Eseye\Configuration;
|
||||
use Seat\Eseye\Containers\EsiAuthentication;
|
||||
use Seat\Eseye\Eseye;
|
||||
use Seat\Eseye\Exceptions\RequestFailedException;
|
||||
|
||||
/**
|
||||
* This class represents a few ESI helper functions for the program
|
||||
@@ -36,12 +37,29 @@ class Esi {
|
||||
return false;
|
||||
}
|
||||
|
||||
public function GetCharacterData($charId) {
|
||||
$esi = new Eseye();
|
||||
try {
|
||||
$character = $esi->invoke('get', '/characters/{character_id}/', [
|
||||
'character_id' => $charId,
|
||||
]);
|
||||
} catch(RequestFailedException $e) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $character;
|
||||
}
|
||||
|
||||
public function GetCharacterName($charId) {
|
||||
$esi = new Eseye();
|
||||
$character = $esi->invoke('get', '/characters/{character_id}/', [
|
||||
'character_id' => $charId,
|
||||
]);
|
||||
|
||||
try {
|
||||
$character = $esi->invoke('get', '/characters/{character_id}/', [
|
||||
'character_id' => $charId,
|
||||
]);
|
||||
} catch(RequestFailedException $e) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $character->name;
|
||||
}
|
||||
|
||||
@@ -54,12 +72,17 @@ class Esi {
|
||||
]);
|
||||
//Create the esi container
|
||||
$esi = new Eseye($authentication);
|
||||
$character = $esi->setQueryString([
|
||||
'categories' => 'character',
|
||||
'language' => 'en-us',
|
||||
'search' => $name,
|
||||
'strict' => 'true',
|
||||
])->invoke('get', '/search/');
|
||||
try {
|
||||
$character = $esi->setQueryString([
|
||||
'categories' => 'character',
|
||||
'language' => 'en-us',
|
||||
'search' => $name,
|
||||
'strict' => 'true',
|
||||
])->invoke('get', '/search/');
|
||||
} catch(RequestFailedException $e) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
$character = json_decode($character, true);
|
||||
|
||||
@@ -68,22 +91,31 @@ class Esi {
|
||||
|
||||
public function FindCorporationId($charId) {
|
||||
$esi = new Eseye();
|
||||
$character = $esi->invoke('get', '/characters/{character_id}/', [
|
||||
'character_id' => $charId,
|
||||
]);
|
||||
|
||||
try {
|
||||
$character = $esi->invoke('get', '/characters/{character_id}/', [
|
||||
'character_id' => $charId,
|
||||
]);
|
||||
} catch(RequestFailedException $e) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $character->corporation_id;
|
||||
}
|
||||
|
||||
public function FindCorporationName($charId) {
|
||||
$esi = new Eseye();
|
||||
$character = $esi->invoke('get', '/characters/{character_id}/', [
|
||||
'character_id' => $charId,
|
||||
]);
|
||||
|
||||
$corporation = $esi->invoke('get', '/corporations/{corporation_id}/', [
|
||||
'corporation_id' => $character->corporation_id,
|
||||
]);
|
||||
try {
|
||||
$character = $esi->invoke('get', '/characters/{character_id}/', [
|
||||
'character_id' => $charId,
|
||||
]);
|
||||
|
||||
$corporation = $esi->invoke('get', '/corporations/{corporation_id}/', [
|
||||
'corporation_id' => $character->corporation_id,
|
||||
]);
|
||||
} catch(RequestFailedException $e) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
return $corporation->name;
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ use Seat\Eseye\Cache\NullCache;
|
||||
use Seat\Eseye\Configuration;
|
||||
use Seat\Eseye\Containers\EsiAuthentication;
|
||||
use Seat\Eseye\Eseye;
|
||||
use Seat\Eseye\Exceptions\RequestFailedException;
|
||||
|
||||
class Mail {
|
||||
|
||||
@@ -39,7 +40,7 @@ class Mail {
|
||||
])->invoke('post', '/characters/{character_id}/mail/', [
|
||||
'character_id' => 93738489,
|
||||
]);
|
||||
} catch(\Seat\Eseye\Exceptions\RequestFailedException $e) {
|
||||
} catch(RequestFailedException $e) {
|
||||
return $e->getEsiResponse();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -80,6 +80,7 @@ class JumpBridgeTax {
|
||||
//Make an array for corporations, and amounts
|
||||
$corps = array();
|
||||
$amounts = array();
|
||||
$esi = new Esi();
|
||||
|
||||
//Get all of the parties which have utilized the jump bridge
|
||||
$parties = DB::table('jump_bridge_journal')
|
||||
@@ -91,7 +92,19 @@ class JumpBridgeTax {
|
||||
//Run through each party and assign them into a corporation, then add the corporation to the corporation array if they don't
|
||||
//exist in the array.
|
||||
foreach($parties as $party) {
|
||||
//If the entry in the database lookup table isn't found, add it.
|
||||
if(!CharacterToCorporation::where(['character_id' => $party->first_party_id])->exists()) {
|
||||
$character = $esi->GetCharacterData($party->first_party_id);
|
||||
$corporation = $esi->GetCorporationData($character->corporation_id);
|
||||
$char = new CharacterToCorporation;
|
||||
$char->character_id = $party->first_party_id;
|
||||
$char->character_name = $character->name;
|
||||
$char->corporation_id = $character->corporation_id;
|
||||
$char->corporation_name = $corporation->name;
|
||||
$char->save();
|
||||
}
|
||||
|
||||
//Perform the lookup and add the user into the corps array, and the ammount to the amount array
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -166,7 +166,6 @@ class LookupHelper {
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user