Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
163 changes: 127 additions & 36 deletions app/Services/Integrations/NeonApiService.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

use Illuminate\Support\Facades\Http;

use Exception;

class NeonApiService
{
protected string $baseUrl;
Expand Down Expand Up @@ -46,7 +48,16 @@ private function fetch(string $endpoint, array $fields = [], ?int $personId = nu
$response = Http::get($url, $params);
$response->throw();

return $response->json() ?? [];
$responseJson = $response->json() ?? [];

if (isset($responseJson['status']) && $responseJson['status'] === 'error') {
throw new Exception(
$responseJson['errorMessage'] ?? 'Unknown error',
$responseJson['errorCode'] ?? 0
);
}

return $responseJson;
}

public function getTodaysParticipants(): array
Expand Down Expand Up @@ -140,31 +151,26 @@ public function getParticipant(int $id): array
public function fetchPersonContactInfo(int $personId, bool $useWhereClause): array
{
return $this->fetch("persons/{$personId}", [
'regions_id',
'firstName',
'middleName',
'lastName',
'applicationDate',
'address1',
'address2',
'city',
'state',
'zip',
'employer',
'tShirtSize',
'homeCellPhone',
'workPhone',
'otherNumber',
'email',
'probationParoleCaseWorkerName',
'probationParoleCaseWorkerPhone',
'contactWithChildren',
'contactType',
'monthlyChildSupportPayment',
'maritalStatus',
'ethnicity',
'enteredDate',
'updatedDate',
"regions_id",
"enteredDate",
"address1",
"address2",
"city",
"state",
"zip",
"employer",
"tShirtSize",
"homeCellPhone",
"workPhone",
"otherNumber",
"email",
"probationParoleCaseWorkerName",
"probationParoleCaseWorkerPhone",
"contactWithChildren",
"contactType",
"monthlyChildSupportPayment",
"maritalStatus",
"ethnicity"
], $useWhereClause);
}

Expand All @@ -175,41 +181,126 @@ public function fetchPersonChildren(int $personId, bool $useWhereClause): array
'lastName',
// Age to be calculated from dateOfBirth
'dateOfBirth',
'enteredDate',
'updatedDate',
], $personId, $useWhereClause);
}

public function fetchPersonDisclosure(int $personId, bool $useWhereClause): array
{
return $this->fetch('persons_applications', [
'enteredDate',
'updatedDate',
"persons_id",
"division",
"divisionOther",
"homeCellPhone",
"dateOfBirth",
"fullAddress",
"city",
"state",
"email",
"releaseTo",
"releaseToOther",
"releaseToOtherAddress",
"purposeOfDisclosure",
"programName",
"purposeOfDisclosureOther",
"informationToBeDisclosed",
"informationToBeDisclosedOther",
"acceptsTextMessage"
], $personId,
$useWhereClause);
}

public function fetchPersonAssessment(int $personId, bool $useWhereClause): array
{
return $this->fetch('persons_assessment_worksheet', [
'enteredDate',
'updatedDate',
"persons_id",
"fullName",
"dateOfBirth",
"missouriResident",
"childUnder18",
"financiallyEligible",
"dL",
"utilityBill",
"payStub",
"writtenEmployerStatement",
"socialSecurityBenefitsStatement",
"selfAttestationOfNoEmploymentOrIncome",
"unemploymentCompensation",
"other",
"hoseholdIncome",
"numberOfFamilyMembersInHousehold",
"percentageOfFPL"
], $personId, $useWhereClause);
}

public function fetchPersonSurvey(int $personId, bool $useWhereClause): array
{
return $this->fetch('persons_introductory_survey', [
'enteredDate',
'updatedDate',
"persons_id",
"dateOfBirth",
"programName",
"reasons",
"reasonsOther",
"hearAboutUs",
"hearAboutUsOther",
"expectToGain",
"expectToGainOther"
], $personId, $useWhereClause);
}

public function fetchPersonServicePlan(int $personId, bool $useWhereClause): array
{
return $this->fetch('persons_service_plan', [
'enteredDate',
'updatedDate',
"persons_id",
"programName",
"clientNumber",
"reviewDates",
"serviceAreas",
"serviceIdentifiedByTheParticipants",
"goals_parentingSkills",
"goals_parentingSkillsObj",
"goals_parentingSkillsPersonRes",
"goals_parentingSkillsTimeline",
"goals_parentingSkillsMeasure",
"goals_managingStress",
"goals_managingStressObj",
"goals_managingStressPersonRes",
"goals_managingStressTimeline",
"goals_managingStressMeasure",
"goals_custodyVisitation",
"goals_custodyVisitationObj",
"goals_custodyVisitationPersonRes",
"goals_custodyVisitationTimeline",
"goals_custodyVisitationMeasure",
"goals_educationEmployment",
"goals_educationEmploymentObj",
"goals_educationEmploymentPersonRes",
"goals_educationEmploymentTimeline",
"goals_educationEmploymentMeasure",
"goals_housingTransportation",
"goals_housingTransportationObj",
"goals_housingTransportationPersonRes",
"goals_housingTransportationTimeline",
"goals_housingTransportationMeasure",
"goals_childSupportAction",
"goals_childSupportActionObj",
"goals_childSupportActionPersonRes",
"goals_childSupportActionTimeline",
"goals_childSupportActionMeasure",
"goals_childSupportAwareness",
"goals_childSupportAwarenessObj",
"goals_childSupportAwarenessPersonRes",
"goals_childSupportAwarenessTimeline",
"goals_childSupportAwarenessMeasure",
"goals_effectiveCoParenting",
"goals_effectiveCoParentingObj",
"goals_effectiveCoParentingPersonRes",
"goals_effectiveCoParentingTimeline",
"goals_effectiveCoParentingMeasure",
"goals_fatherToFatherMentoring",
"goals_fatherToFatherMentoringObj",
"goals_fatherToFatherMentoringPersonRes",
"goals_fatherToFatherMentoringTimeline",
"goals_fatherToFatherMentoringMeasure"
], $personId, $useWhereClause);
}

Expand Down
Loading