Skip to content

Instantly share code, notes, and snippets.

@jongravois
Created January 19, 2021 15:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jongravois/f76560fcdf4c59ba5daf17828795f2ca to your computer and use it in GitHub Desktop.
Save jongravois/f76560fcdf4c59ba5daf17828795f2ca to your computer and use it in GitHub Desktop.
<?php namespace App\Actions;
use Carbon\Carbon;
use Composer\Config;
use Illuminate\Support\Facades\Http;
class DeniedParty
{
public static function check($name=null)
{
$reporter = [];
if(! $name) {
$reporter['status'] = 'NOCHECK';
$reporter['results'] = '';
return $reporter;
} // end if
$path = 'https://api.trade.gov/gateway/v1/consolidated_screening_list/search?name=' . $name;
$srch = Http::withHeaders(['Authorization' => config('services.itar.basic')])
->get($path)->json();
if(! isset($srch['total'])) {
$reporter['status'] = 'NORESPONSE';
$reporter['results'] = '';
} elseif($srch['total'] > 0) {
$reporter['status'] = 'FAIL';
$reporter['results'] = $srch['results'][0]['source'];
// $company->update([
// 'denied_party_checked' => true,
// 'denied_party_cleared' => false,
// 'last_denied_party_check' => Carbon::today()
// ]);
} else {
$reporter['status'] = 'PASS';
$reporter['results'] = '';
// $company->update([
// 'denied_party_checked' => true,
// 'denied_party_cleared' => true,
// 'last_denied_party_check' => Carbon::today()
// ]);
} //end if
return $reporter;
} // end function
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment