44
55use Illuminate \Support \Facades \Http ;
66
7+ use Exception ;
8+
79class NeonApiService
810{
911 protected string $ baseUrl ;
@@ -46,7 +48,16 @@ private function fetch(string $endpoint, array $fields = [], ?int $personId = nu
4648 $ response = Http::get ($ url , $ params );
4749 $ response ->throw ();
4850
49- return $ response ->json () ?? [];
51+ $ responseJson = $ response ->json () ?? [];
52+
53+ if (isset ($ responseJson ['status ' ]) && $ responseJson ['status ' ] === 'error ' ) {
54+ throw new Exception (
55+ $ responseJson ['errorMessage ' ] ?? 'Unknown error ' ,
56+ $ responseJson ['errorCode ' ] ?? 0
57+ );
58+ }
59+
60+ return $ responseJson ;
5061 }
5162
5263 public function getTodaysParticipants (): array
@@ -140,31 +151,26 @@ public function getParticipant(int $id): array
140151 public function fetchPersonContactInfo (int $ personId , bool $ useWhereClause ): array
141152 {
142153 return $ this ->fetch ("persons/ {$ personId }" , [
143- 'regions_id ' ,
144- 'firstName ' ,
145- 'middleName ' ,
146- 'lastName ' ,
147- 'applicationDate ' ,
148- 'address1 ' ,
149- 'address2 ' ,
150- 'city ' ,
151- 'state ' ,
152- 'zip ' ,
153- 'employer ' ,
154- 'tShirtSize ' ,
155- 'homeCellPhone ' ,
156- 'workPhone ' ,
157- 'otherNumber ' ,
158- 'email ' ,
159- 'probationParoleCaseWorkerName ' ,
160- 'probationParoleCaseWorkerPhone ' ,
161- 'contactWithChildren ' ,
162- 'contactType ' ,
163- 'monthlyChildSupportPayment ' ,
164- 'maritalStatus ' ,
165- 'ethnicity ' ,
166- 'enteredDate ' ,
167- 'updatedDate ' ,
154+ "regions_id " ,
155+ "enteredDate " ,
156+ "address1 " ,
157+ "address2 " ,
158+ "city " ,
159+ "state " ,
160+ "zip " ,
161+ "employer " ,
162+ "tShirtSize " ,
163+ "homeCellPhone " ,
164+ "workPhone " ,
165+ "otherNumber " ,
166+ "email " ,
167+ "probationParoleCaseWorkerName " ,
168+ "probationParoleCaseWorkerPhone " ,
169+ "contactWithChildren " ,
170+ "contactType " ,
171+ "monthlyChildSupportPayment " ,
172+ "maritalStatus " ,
173+ "ethnicity "
168174 ], $ useWhereClause );
169175 }
170176
@@ -175,41 +181,126 @@ public function fetchPersonChildren(int $personId, bool $useWhereClause): array
175181 'lastName ' ,
176182 // Age to be calculated from dateOfBirth
177183 'dateOfBirth ' ,
178- 'enteredDate ' ,
179- 'updatedDate ' ,
180184 ], $ personId , $ useWhereClause );
181185 }
182186
183187 public function fetchPersonDisclosure (int $ personId , bool $ useWhereClause ): array
184188 {
185189 return $ this ->fetch ('persons_applications ' , [
186- 'enteredDate ' ,
187- 'updatedDate ' ,
190+ "persons_id " ,
191+ "division " ,
192+ "divisionOther " ,
193+ "homeCellPhone " ,
194+ "dateOfBirth " ,
195+ "fullAddress " ,
196+ "city " ,
197+ "state " ,
198+ "email " ,
199+ "releaseTo " ,
200+ "releaseToOther " ,
201+ "releaseToOtherAddress " ,
202+ "purposeOfDisclosure " ,
203+ "programName " ,
204+ "purposeOfDisclosureOther " ,
205+ "informationToBeDisclosed " ,
206+ "informationToBeDisclosedOther " ,
207+ "acceptsTextMessage "
188208 ], $ personId ,
189209 $ useWhereClause );
190210 }
191211
192212 public function fetchPersonAssessment (int $ personId , bool $ useWhereClause ): array
193213 {
194214 return $ this ->fetch ('persons_assessment_worksheet ' , [
195- 'enteredDate ' ,
196- 'updatedDate ' ,
215+ "persons_id " ,
216+ "fullName " ,
217+ "dateOfBirth " ,
218+ "missouriResident " ,
219+ "childUnder18 " ,
220+ "financiallyEligible " ,
221+ "dL " ,
222+ "utilityBill " ,
223+ "payStub " ,
224+ "writtenEmployerStatement " ,
225+ "socialSecurityBenefitsStatement " ,
226+ "selfAttestationOfNoEmploymentOrIncome " ,
227+ "unemploymentCompensation " ,
228+ "other " ,
229+ "hoseholdIncome " ,
230+ "numberOfFamilyMembersInHousehold " ,
231+ "percentageOfFPL "
197232 ], $ personId , $ useWhereClause );
198233 }
199234
200235 public function fetchPersonSurvey (int $ personId , bool $ useWhereClause ): array
201236 {
202237 return $ this ->fetch ('persons_introductory_survey ' , [
203- 'enteredDate ' ,
204- 'updatedDate ' ,
238+ "persons_id " ,
239+ "dateOfBirth " ,
240+ "programName " ,
241+ "reasons " ,
242+ "reasonsOther " ,
243+ "hearAboutUs " ,
244+ "hearAboutUsOther " ,
245+ "expectToGain " ,
246+ "expectToGainOther "
205247 ], $ personId , $ useWhereClause );
206248 }
207249
208250 public function fetchPersonServicePlan (int $ personId , bool $ useWhereClause ): array
209251 {
210252 return $ this ->fetch ('persons_service_plan ' , [
211- 'enteredDate ' ,
212- 'updatedDate ' ,
253+ "persons_id " ,
254+ "programName " ,
255+ "clientNumber " ,
256+ "reviewDates " ,
257+ "serviceAreas " ,
258+ "serviceIdentifiedByTheParticipants " ,
259+ "goals_parentingSkills " ,
260+ "goals_parentingSkillsObj " ,
261+ "goals_parentingSkillsPersonRes " ,
262+ "goals_parentingSkillsTimeline " ,
263+ "goals_parentingSkillsMeasure " ,
264+ "goals_managingStress " ,
265+ "goals_managingStressObj " ,
266+ "goals_managingStressPersonRes " ,
267+ "goals_managingStressTimeline " ,
268+ "goals_managingStressMeasure " ,
269+ "goals_custodyVisitation " ,
270+ "goals_custodyVisitationObj " ,
271+ "goals_custodyVisitationPersonRes " ,
272+ "goals_custodyVisitationTimeline " ,
273+ "goals_custodyVisitationMeasure " ,
274+ "goals_educationEmployment " ,
275+ "goals_educationEmploymentObj " ,
276+ "goals_educationEmploymentPersonRes " ,
277+ "goals_educationEmploymentTimeline " ,
278+ "goals_educationEmploymentMeasure " ,
279+ "goals_housingTransportation " ,
280+ "goals_housingTransportationObj " ,
281+ "goals_housingTransportationPersonRes " ,
282+ "goals_housingTransportationTimeline " ,
283+ "goals_housingTransportationMeasure " ,
284+ "goals_childSupportAction " ,
285+ "goals_childSupportActionObj " ,
286+ "goals_childSupportActionPersonRes " ,
287+ "goals_childSupportActionTimeline " ,
288+ "goals_childSupportActionMeasure " ,
289+ "goals_childSupportAwareness " ,
290+ "goals_childSupportAwarenessObj " ,
291+ "goals_childSupportAwarenessPersonRes " ,
292+ "goals_childSupportAwarenessTimeline " ,
293+ "goals_childSupportAwarenessMeasure " ,
294+ "goals_effectiveCoParenting " ,
295+ "goals_effectiveCoParentingObj " ,
296+ "goals_effectiveCoParentingPersonRes " ,
297+ "goals_effectiveCoParentingTimeline " ,
298+ "goals_effectiveCoParentingMeasure " ,
299+ "goals_fatherToFatherMentoring " ,
300+ "goals_fatherToFatherMentoringObj " ,
301+ "goals_fatherToFatherMentoringPersonRes " ,
302+ "goals_fatherToFatherMentoringTimeline " ,
303+ "goals_fatherToFatherMentoringMeasure "
213304 ], $ personId , $ useWhereClause );
214305 }
215306
0 commit comments