@@ -250,26 +250,222 @@ public function __destruct()
250250 }
251251
252252 /**
253- * Obtain listing of all Customers
253+ * Gives you endpoint's excel data as PHP array
254+ *
255+ * @param string $endpoint suffix
254256 *
255257 * @return array
256258 */
257- public function listCustomers ( )
259+ public function getExcelData ( $ endpoint )
258260 {
259- $ responseCode = $ this ->doCurlRequest ($ this ->baseEndpoint . 'ws/v10/list-excel-customers ' , 'POST ' );
260- $ customersData = [];
261+ $ responseCode = $ this ->doCurlRequest ($ this ->baseEndpoint . 'ws/v10/ ' . $ endpoint , 'POST ' );
262+ $ excelData = [];
261263 if ($ responseCode == 200 ) {
262- $ xls = sys_get_temp_dir () . '/list-excel-customers_ ' . \Ease \Functions::randomString () . '.xls ' ;
264+ $ xls = sys_get_temp_dir () . '/ ' . $ endpoint . ' _ ' . \Ease \Functions::randomString () . '.xls ' ;
263265 file_put_contents ($ xls , $ this ->lastCurlResponse );
264266 $ spreadsheet = IOFactory::load ($ xls );
265267 unlink ($ xls );
266268 $ customersDataRaw = $ spreadsheet ->getActiveSheet ()->toArray (null , true , true , true );
267269 $ columns = $ customersDataRaw [1 ];
268270 unset($ customersDataRaw [1 ]);
269271 foreach ($ customersDataRaw as $ recordId => $ recordData ) {
270- $ customersData [$ recordId ] = array_combine ($ columns , $ recordData );
272+ $ excelData [$ recordId ] = array_combine ($ columns , $ recordData );
271273 }
272274 }
273- return $ customersData ;
275+ return $ excelData ;
276+ }
277+
278+ /**
279+ * Obtain listing of all Customers
280+ *
281+ * @return array
282+ */
283+ public function listCustomers ()
284+ {
285+ return $ this ->getExcelData ('list-excel-customers ' );
286+ }
287+
288+ /**
289+ * The last columns contain the unique unit ID, numeric ID of the unit type,
290+ * numeric ID of the unit availability, unique project ID and deal ID from
291+ * the Realpad database. See the appendix for the unit type and availability
292+ * enums.
293+ *
294+ * @return array
295+ */
296+ public function listProducts ()
297+ {
298+ return $ this ->getExcelData ('list-excel-products ' );
299+ }
300+
301+ /**
302+ * The last column contains the unique Deal ID from the Realpad database.
303+ *
304+ * @return array
305+ */
306+ public function listBusinessCases ()
307+ {
308+ return $ this ->getExcelData ('list-excel-business-cases ' );
309+ }
310+
311+ /**
312+ * Obtain listing of all Projects
313+ *
314+ * @return array
315+ */
316+ public function listProjects ()
317+ {
318+ return $ this ->getExcelData ('list-excel-projects ' );
319+ }
320+
321+ /**
322+ * The last three columns contain the unique document ID, customer ID,
323+ * and sales agent ID from the Realpad database. The first column is the
324+ * relevant deal ID.
325+ *
326+ * @return array
327+ */
328+ public function listDealDocuments ()
329+ {
330+ return $ this ->getExcelData ('list-excel-deal-documents ' );
331+ }
332+
333+ /**
334+ * The last column contains the unique payment ID from the Realpad database.
335+ * The second column is the relevant deal ID.
336+ *
337+ * @return array
338+ */
339+ public function listPaymentsPrescribed ()
340+ {
341+ return $ this ->getExcelData ('list-excel-payments-prescribed ' );
342+ }
343+
344+ /**
345+ * The first column contains the unique incoming payment ID from the Realpad
346+ * database. The second column is the relevant Deal ID.
347+ *
348+ * @return array
349+ */
350+ public function listPaymentsIncoming ()
351+ {
352+ return $ this ->getExcelData ('list-excel-payments-incoming ' );
353+ }
354+
355+ /**
356+ * The last columns contain the additional product ID, its type ID, and the
357+ * ID of the associated prescribed payment from the Realpad database.
358+ * The first column is the relevant deal ID.
359+ *
360+ * @return array
361+ */
362+ public function listAdditionalProducts ()
363+ {
364+ return $ this ->getExcelData ('list-excel-additional-products ' );
365+ }
366+
367+ /**
368+ * Among the columns, there are those representing the deal ID and
369+ * inspection ID from the Realpad database.
370+ *
371+ * @return array
372+ */
373+ public function listInspections ()
374+ {
375+ return $ this ->getExcelData ('list-excel-inspections ' );
376+ }
377+
378+ /**
379+ * Accepts an additional optional parameter mode. By default all the Deal
380+ * Warranty Claim Defects are returned. Certain developers will also see the
381+ * Communal Areas Defects here by default. If mode is specified, other
382+ * Defects can be returned. Available modes are:
383+ * DEAL_DEFECTS, DEAL_DEFECTS_COMMUNAL_AREA, DEAL_DEFECTS_COMBINED,
384+ * INSPECTION_DEFECTS, INSPECTION_DEFECTS_COMMUNAL_AREA,
385+ * INSPECTION_DEFECTS_COMBINED.
386+ *
387+ * The last column contains the unique defect ID from the Realpad database.
388+ * The second column is the relevant deal ID.
389+ *
390+ * @todo Implement Modes
391+ *
392+ * @return array
393+ */
394+ public function listDefects ()
395+ {
396+ return $ this ->getExcelData ('list-excel-defects ' );
397+ }
398+
399+ /**
400+ * The last columns contain the task ID, customer ID, and sales agent ID
401+ * from the Realpad database.
402+ *
403+ * @return array
404+ */
405+ public function listTasks ()
406+ {
407+ return $ this ->getExcelData ('list-excel-tasks ' );
408+ }
409+
410+ /**
411+ * The last columns contain the event ID, customer ID, unit, and project ID
412+ * from the Realpad database.
413+ *
414+ * @return array
415+ */
416+ public function listEvents ()
417+ {
418+ return $ this ->getExcelData ('list-excel-events ' );
419+ }
420+
421+ /**
422+ * The last column contains the unit ID from the Realpad database.
423+ *
424+ * @return array
425+ */
426+ public function listSalesStatus ()
427+ {
428+ return $ this ->getExcelData ('list-excel-sales-status ' );
429+ }
430+
431+ /**
432+ * Accepts an additional required parameter unitid, which has to be a valid
433+ * unit Realpad database ID obtained from some other endpoint.
434+ * The first column contains the timestamp of when the given unit started
435+ * containing the data on the given row. The second column contains the name
436+ * of the user who caused that data to be recorded.
437+ *
438+ * @return array
439+ */
440+ public function listUnitHistory ()
441+ {
442+ return $ this ->getExcelData ('list-excel-unit-history ' );
443+ }
444+
445+ /**
446+ * Accepts several additional optional parameters:
447+ * ● `filter_status` - if left empty, invoices in all statuses are sent. 1 - new invoices. 2 -
448+ * invoices in Review #1. 3 - invoices in Review #2. 4 - invoices in approval. 5 - fully
449+ * approved invoices. 6 - fully rejected invoices.
450+ *
451+ * ● `filter_groupcompany` - if left empty, invoices from all the group companies are sent. If
452+ * Realpad database IDs of group companies are provided (as a comma-separated list),
453+ * then only invoices from these companies are sent.
454+ *
455+ * ● `filter_issued_from`` - specify a date in the 2019-12-31 format to only send invoices
456+ * issues after that date.
457+ *
458+ * ● `filter_issued_to` - specify a date in the 2019-12-31 format to only send invoices issues
459+ * before that date.
460+ * The initial set of columns describes the Invoice itself, and the last set of columns contains the
461+ * data of its Lines.
462+ *
463+ * @todo Implement Filters
464+ *
465+ * @return array
466+ */
467+ public function listInvoices ()
468+ {
469+ return $ this ->getExcelData ('list-excel-invoices ' );
274470 }
275471}
0 commit comments