PageSourceSearch

https://kagoafrica.com/transporter/assets/js/api_calls.js?version=3.0.9.1

js kagoafrica.com collected 2026-09-24 14:15:55 UTC 16,362 bytes, 722 lines download raw bytes

1// LOGIN
2async function login(user_data) {
3  const res = await fetch(`${transporterJsonUrl}`, {
4    headers: { "Content-Type": "application/json" },
5    method: "POST",
6    body: JSON.stringify(user_data),
7  });
8
9  const data = await res.json();
10
11  if (data.status == "failed") {
12    let messages = data.message;
13    let messageString = "";
14    if (typeof messages == "object") {
15      messages.forEach((message) => {
16        messageString += `${message}\n`;
17      });
18      swal("Failed to log in", messageString, "warning");
19      return false;
20    } else if (typeof messages == "string") {
21      swal("Failed to log in", messages, "warning");
22      return false;
23    }
24  }
25
26  console.debug("Passed");
27
28  return data;
29}
30
31// REGISTER
32async function register(user_data) {
33  const res = await fetch(`${TRANSPORTER_URL_FORMDATA}`, {
34    method: "POST",
35    body: user_data,
36  });
37
38  const data = await res.json();
39
40  return data;
41}
42
43// Forgot password
44
45// GET AVAILABLE CARGO
46async function getAvailableCargo(week = null) {
47  const res = await fetch(
48    `${transporterJsonUrl}?appType=getAvailableCargo${
49      week == 1 ? `&week=1` : `&week=2`
50    }`,
51    {
52      headers: { Authorization: `Bearer ${token}` },
53    }
54  );
55  const data = await res.json();
56
57  return data;
58}
59
60// GET APPLICATIONS
61async function getApplications(parentId) {
62  const res = await fetch(
63    `${transporterJsonUrl}?appType=getApplication&parentId=${parentId}`,
64    {
65      headers: { Authorization: `Bearer ${token}` },
66    }
67  );
68  const data = await res.json();
69
70  return data;
71}
72
73// GET CARGO
74async function getCargos(status) {
75  const res = await fetch(
76    `${transporterJsonUrl}?appType=getCargo&status=${status}`,
77    {
78      headers: { Authorization: `Bearer ${token}` },
79    }
80  );
81  const data = await res.json();
82
83  return data;
84}
85
86// GET VEHICLES
87async function getVehicles(status) {
88  const res = await fetch(
89    `${transporterJsonUrl}?appType=getVehicles&status=${status}`,
90    {
91      headers: { Authorization: `Bearer ${token}` },
92    }
93  );
94  const data = await res.json();
95
96  return data;
97}
98// ADD VEHICLE
99async function addVehicle(vehicle_data) {
100  const res = await fetch(`${TRANSPORTER_URL_FORMDATA}`, {
101    headers: { Authorization: `Bearer ${token}` },
102    method: "POST",
103    body: vehicle_data,
104  });
105  const data = await res.json();
106
107  return data;
108}
109// TOGGLE VEHICLE
110async function toggleVehicle(vehicleData) {
111  const res = await fetch(`${transporterJsonUrl}`, {
112    headers: {
113      "Content-Type": "application/json",
114      Authorization: `Bearer ${token}`,
115    },
116    method: "POST",
117    body: JSON.stringify(vehicleData),
118  });
119
120  const data = await res.json();
121
122  return data;
123}
124
125// GET TRAILER
126async function getTrailers(parentId) {
127  const res = await fetch(
128    `${transporterJsonUrl}?appType=getTrailers&parentId=${parentId}`,
129    {
130      headers: { Authorization: `Bearer ${token}` },
131    }
132  );
133  const data = await res.json();
134
135  return data;
136}
137// ADD TRAILER
138async function getVehicleType() {
139  const res = await fetch(`${transporterJsonUrl}?appType=getVehicleType`, {
140    headers: { Authorization: `Bearer ${token}` },
141  });
142  const data = await res.json();
143
144  return data;
145}
146
147async function getTrailerType() {
148  const res = await fetch(`${transporterJsonUrl}?appType=getTrailerType`, {
149    headers: { Authorization: `Bearer ${token}` },
150  });
151  const data = await res.json();
152
153  return data;
154}
155
156async function startTrip(cargoId) {
157  const res = await fetch(`${transporterJsonUrl}`, {
158    headers: {
159      "Content-Type": "application/json",
160      Authorization: `Bearer ${token}`,
161    },
162    method: "POST",
163    body: JSON.stringify({
164      appType: "startTrip",
165      createdBy: USER_DATA.userId,
166      userId: USER_DATA.userId,
167      transporterId: USER_DATA.parentId,
168      allocatedId: cargoId,
169    }),
170  });
171  const data = await res.json();
172
173  return data;
174}
175
176// GET USERS
177async function getUsers(status) {
178  const res = await fetch(`${transporterJsonUrl}?appType=getUsers`, {
179    headers: { Authorization: `Bearer ${token}` },
180  });
181  const data = await res.json();
182
183  return data;
184}
185
186// ROLES
187async function getRoles() {
188  const res = await fetch(`${transporterJsonUrl}?appType=getRole`, {
189    headers: { Authorization: `Bearer ${token}` },
190  });
191  const data = await res.json();
192
193  return data;
194}
195
196// REGISTER USER
197async function addUser(user_data) {
198  const res = await fetch(`${transporterJsonUrl}`, {
199    headers: {
200      "Content-Type": "application/json",
201      Authorization: `Bearer ${token}`,
202    },
203    method: "POST",
204    body: JSON.stringify(user_data),
205  });
206
207  const data = await res.json();
208
209  return data;
210}
211
212// TOGGLE USER
213async function toggleUser(toggledUserId, parentId, userId, status) {
214  const res = await fetch(`${transporterJsonUrl}`, {
215    headers: {
216      "Content-Type": "application/json",
217      Authorization: `Bearer ${token}`,
218    },
219    method: "POST",
220    body: JSON.stringify({
221      appType: "toggleUser",
222      userId: parseInt(toggledUserId),
223      parentId: parentId,
224      createdBy: userId,
225      status: status,
226    }),
227  });
228  const data = await res.json();
229
230  return data;
231}
232
233async function getDrivers(parentId) {
234  const res = await fetch(
235    `${transporterJsonUrl}?appType=getDrivers&parentId=${parentId}`,
236    {
237      headers: { Authorization: `Bearer ${token}` },
238    }
239  );
240
241  const data = await res.json();
242
243  return data;
244}
245
246async function getDashboard(parentId) {
247  const res = await fetch(
248    `${transporterJsonUrl}?appType=getDashboard&parentId=${parentId}`,
249    {
250      headers: { Authorization: `Bearer ${token}` },
251    }
252  );
253  const data = await res.json();
254
255  return data;
256}
257
258async function toggleTrailer(trailerData) {
259  const res = await fetch(`${transporterJsonUrl}`, {
260    headers: {
261      "Content-Type": "application/json",
262      Authorization: `Bearer ${token}`,
263    },
264    method: "POST",
265    body: JSON.stringify(trailerData),
266  });
267  const data = await res.json();
268
269  return data;
270}
271
272async function addTrailer(trailerFormData) {
273  const res = await fetch(`${TRANSPORTER_URL_FORMDATA}`, {
274    headers: { Authorization: `Bearer ${token}` },
275    method: "POST",
276    body: trailerFormData,
277  });
278
279  const data = await res.json();
280
281  return data;
282}
283
284async function addDriver(driverFormData) {
285  const res = await fetch(`${TRANSPORTER_URL_FORMDATA}`, {
286    headers: { Authorization: `Bearer ${token}` },
287    method: "POST",
288    body: driverFormData,
289  });
290  const data = await res.json();
291
292  return data;
293}
294
295async function bookCargo(cargoId, parentId, userId, vehicleId, bookedWeight) {
296  const res = await fetch(`${transporterJsonUrl}`, {
297    headers: {
298      "Content-Type": "application/json",
299      Authorization: `Bearer ${token}`,
300    },
301    method: "POST",
302    body: JSON.stringify({
303      appType: "bookCargo",
304      transporterId: parentId,
305      createdBy: userId,
306      cargoId: cargoId,
307      vehicleId: vehicleId,
308      bookedWeight: bookedWeight,
309    }),
310  });
311
312  const data = await res.json();
313
314  return data;
315}
316
317async function endTrip(cargoData) {
318  const res = await fetch(`${transporterJsonUrl}`, {
319    headers: {
320      "Content-Type": "application/json",
321      Authorization: `Bearer ${token}`,
322    },
323    method: "POST",
324    body: JSON.stringify(cargoData),
325  });
326  const data = await res.json();
327
328  return data;
329}
330
331async function getAuditLogs(parentId) {
332  const res = await fetch(
333    `${transporterJsonUrl}?appType=getAudit&parentId=${parentId}`,
334    {
335      headers: { Authorization: `Bearer ${token}` },
336    }
337  );
338  const data = await res.json();
339
340  return data;
341}
342
343async function getProducts() {
344  const res = await fetch(`${transporterJsonUrl}?appType=getProducts`, {
345    headers: { Authorization: `Bearer ${token}` },
346  });
347  const data = await res.json();
348
349  return data;
350}
351
352async function getPermissions() {
353  const res = await fetch(
354    `${transporterJsonUrl}?appType=getPermission&userType=3`,
355    {
356      headers: { Authorization: `Bearer ${token}` },
357    }
358  );
359
360  const data = await res.json();
361
362  return data;
363}
364
365async function addRole(roleData) {
366  const res = await fetch(`${transporterJsonUrl}`, {
367    headers: {
368      "Content-Type": "application/json",
369      Authorization: `Bearer ${token}`,
370    },
371    method: "POST",
372    body: JSON.stringify(roleData),
373  });
374
375  const data = await res.json();
376
377  return data;
378}
379
380async function editRole(roleData) {
381  const res = await fetch(`${transporterJsonUrl}`, {
382    headers: {
383      "Content-Type": "application/json",
384      Authorization: `Bearer ${token}`,
385    },
386    method: "POST",
387    body: JSON.stringify(roleData),
388  });
389
390  const data = await res.json();
391
392  return data;
393}
394
395async function editUser(userData) {
396  const res = await fetch(`${transporterJsonUrl}`, {
397    headers: {
398      "Content-Type": "application/json",
399      Authorization: `Bearer ${token}`,
400    },
401    method: "POST",
402    body: JSON.stringify(userData),
403  });
404
405  const data = await res.json();
406
407  return data;
408}
409
410async function getSecurityQuestions() {
411  const res = await fetch(`${transporterJsonUrl}?appType=getUserSecurity`, {
412    headers: { Authorization: `Bearer ${token}` },
413  });
414
415  const data = await res.json();
416
417  return data;
418}
419
420async function confirmSecurityQuestion(questionData) {
421  const res = await fetch(`${transporterJsonUrl}`, {
422    headers: {
423      "Content-Type": "application/json",
424      Authorization: `Bearer ${token}`,
425    },
426    method: "POST",
427    body: JSON.stringify(questionData),
428  });
429
430  const data = await res.json();
431
432  return data;
433}
434
435async function changePw(pwData) {
436  const res = await fetch(`${transporterJsonUrl}`, {
437    headers: {
438      "Content-Type": "application/json",
439      Authorization: `Bearer ${token}`,
440    },
441    method: "POST",
442    body: JSON.stringify(pwData),
443  });
444
445  const data = await res.json();
446
447  return data;
448}
449
450async function getLocations() {
451  const res = await fetch(`${transporterJsonUrl}?appType=getLocation`, {
452    headers: { Authorization: `Bearer ${token}` },
453  });
454  const data = await res.json();
455
456  return data;
457}
458
459async function editDriver(driverData) {
460  const res = await fetch(`${TRANSPORTER_URL_FORMDATA}`, {
461    headers: { Authorization: `Bearer ${token}` },
462    method: "POST",
463    body: driverData,
464  });
465  const data = await res.json();
466
467  return data;
468}
469
470async function editVehicle(vehicleData) {
471  const res = await fetch(`${transporterJsonUrl}`, {
472    headers: {
473      Authorization: `Bearer ${token}`,
474      "Content-Type": "application/json",
475    },
476    method: "POST",
477    body: JSON.stringify(vehicleData),
478  });
479  const data = await res.json();
480
481  return data;
482}
483
484async function getAttachments(type = "Invoice") {
485  const res = await fetch(
486    `${transporterJsonUrl}?appType=getAttachment&type=${type}`,
487    {
488      headers: { Authorization: `Bearer ${token}` },
489    }
490  );
491  const data = await res.json();
492
493  return data;
494}
495
496async function updateTrip(commentData) {
497  const res = await fetch(`${transporterJsonUrl}`, {
498    headers: {
499      Authorization: `Bearer ${token}`,
500      "Content-Type": "application/json",
501    },
502    method: "POST",
503    body: JSON.stringify(commentData),
504  });
505  const data = await res.json();
506
507  return data;
508}
509
510async function getTrip(tripId) {
511  const res = await fetch(
512    `${transporterJsonUrl}
512?appType=getTrip&tripId=${tripId}`,
513    {
514      headers: { Authorization: `Bearer ${token}` },
515    }
516  );
517  const data = await res.json();
518
519  return data;
520}
521
522// async function getCurrency() {
523//     const res = await fetch(`${transporterJsonUrl}?appType=getCurrency`, {
524//         headers: {'Authorization': `Bearer ${token}`}
525//     })
526//     const data = await res.json()
527
528//     return data
529// }
530
531async function getVehicleCategory() {
532  const res = await fetch(
533    `${transporterJsonUrl}?appType=getVehicleCategory`,
534    {
535      headers: { Authorization: `Bearer ${token}` },
536    }
537  );
538  const data = await res.json();
539
540  return data;
541}
542
543async function getVasLimit() {
544  const res = await fetch(`${transporterJsonUrl}?appType=getVasPercentage`, {
545    headers: { Authorization: `Bearer ${token}` },
546  });
547  const data = await res.json();
548
549  return data;
550}
551
552async function getProductCategories() {
553  const res = await fetch(
554    `${transporterJsonUrl}?appType=getProductCategories`,
555    {
556      headers: { Authorization: `Bearer ${token}` },
557    }
558  );
559  const data = await res.json();
560
561  return data;
562}
563
564// async function toggleCurrency(currencyId) {
565//     const res = await fetch(`${transporterJsonUrl}`, {
566//         headers: {'Authorization': `Bearer ${token}`},
567//         method: 'POST',
568//         body: JSON.stringify({currencyId: currencyId, appType: 'toggleCurrency'})
569//     })
570//     const data = await res.json()
571
572//     return data
573// }
574
575async function getDocuments() {
576  const res = await fetch(`${transporterJsonUrl}?appType=getDocuments`, {
577    headers: { Authorization: `Bearer ${token}` },
578  });
579  const data = await res.json();
580
581  return data;
582}
583
584async function addDocument(documentFormData) {
585  const res = await fetch(`${TRANSPORTER_URL_FORMDATA}`, {
586    headers: { Authorization: `Bearer ${token}` },
587    method: "POST",
588    body: documentFormData,
589  });
590  const data = await res.json();
591
592  return data;
593}
594
595async function arriveBorder(allocatedId) {
596  const res = await fetch(`${transporterJsonUrl}`, {
597    headers: { Authorization: `Bearer ${token}` },
598    method: "POST",
599    body: JSON.stringify({ appType: "arriveBorder", allocatedId: allocatedId }),
600  });
601  const data = await res.json();
602
603  return data;
604}
605
606async function init_session(payload) {
607  try {
608      let formData = new FormData();
609      for (key in payload) {
610          formData.append(key, payload[key])
611      }
612
613      const res = await fetch(`${transporterUrl}/sessions.php`, {
614          method: "POST",
615          body: formData
616      })
617
618      const data = await res.json();
619
620      return data;
621  }
622
623  catch(error) {
624      return {"status": "failed", "message": error.message}
625  }
626}
627
628async function getData(filterParams) {
629  try {
630
631      if (!filterParams["appType"]) {
632          throw new Error("appType is a required parameter");
633      }
634
635      let queryParams = new URLSearchParams(filterParams).toString()
636
637      const res = await fetch(`${transporterJsonUrl}?${queryParams}`, {
638          credentials: "include"
639      })
640      const data = await res.json()
641
642      return data;
643  }
644
645  catch(error) {
646      return {"status": "failed", "message": error.message}
647  }
648}
649
650async function postData(payload, json=true) {
651  try {
652      if (!payload['appType']) {
653          throw new Error("appType is a required parameter");
654      }
655      let fetchParams = {
656          headers: {'Content-Type': 'application/json'},
657          method: 'POST',
658          body: JSON.stringify(payload)
659      };
660
661      if (!json) {
662          let formdata = new FormData();
663          for (key in payload) {
664              formdata.append(key, payload[key]);
665          }
666
667          fetchParams = {
668              method: 'POST',
669              body: formdata
670          }
671      }
672
673      const res = await fetch(`${json ? transporterJsonUrl : transporterFormDataUrl}`, fetchParams)
674  
675      const data = await res.json();
676
677      return data;
678  }
679
680  catch(error) {
681      return {"status": "failed", "message": error.message}
682  }
683}
684
685async function exportAsPdf(fileName, params) {
686  try {
687      let exportFormData = new FormData()
688      let time = new Date().toISOString();
689      for (field in params) {
690        exportFormData.append(field, params[field])
691      }
692    
693      const res = await fetch(`${transporterPdfExportUrl}`, {
694      //   headers: {'Authorization': `Bearer ${token}`},
695        method: 'POST',
696        credentials: "include",
697        body: exportFormData
698      })
699
700      // const jsonRes = await res.json();
701      // console.log("Json: ", jsonRes);
702      // const data = await jsonRes;
703      // console.log("Data: ", data)
704
705      const blob = await res.blob();
706
707      const file = new File([blob], `${fileName}_${time}.pdf`, { type: 'application/pdf' });
708      let fileUrl = URL.createObjectURL(file);
709      const popup = window.open(fileUrl, '_blank')
710
711      if (!popup) {
712          return {"status": "failed", "message": "Please disable your pop-up blocker and export again"}
713      }
714
715      return {"status": "success"}
716
717  }
718
719  catch(error) {
720      return {"status": "failed", "message": error.message}
721  }
722}

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.