SiraniApiServices.swift 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675
  1. //
  2. // SiraniApiServices.swift
  3. // Sirani
  4. //
  5. // Created by Anhar Solehudin on 27/03/19.
  6. // Copyright © 2019 Anhar Solehudin. All rights reserved.
  7. //
  8. import Foundation
  9. import Alamofire
  10. class SiraniApiServices {
  11. // DOWNLOAD
  12. func downloadFile(urlWeb: String, filename: String) -> DownloadRequest {
  13. let destination: DownloadRequest.Destination = { _, _ in
  14. let documentsURL = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)[0]
  15. let fileURL = documentsURL.appendingPathComponent(filename)
  16. return (fileURL, [.removePreviousFile, .createIntermediateDirectories])
  17. }
  18. return AF.download(urlWeb, to: destination).validate()
  19. }
  20. // AUTH
  21. func postAuthLogin(username: String, password: String) -> DataRequest {
  22. let headers: HTTPHeaders = ["Accept" : "Application/json; charset=utf-8"]
  23. let body: Parameters = ["username" : username, "password" : password]
  24. return AF.request(METHOD_LOGIN_NEW, method: .post, parameters: body, encoding: URLEncoding.default, headers: headers)
  25. }
  26. // Images Slider -> Home
  27. func postSlideShowImages(cursor: String, prev: String, search: String) -> DataRequest {
  28. let headers: HTTPHeaders = ["Accept" : "Application/json; charset=utf-8"]
  29. let body: Parameters = ["cursor" : cursor, "prev" : prev, "search" : search]
  30. return AF.request(METHOD_GET_SLIDE_IMAGE, method: .post, parameters: body, encoding: URLEncoding.default, headers: headers)
  31. }
  32. // News -> Home, NewsVC
  33. func postToGetNews(cursor: Int, prev: Int, jenis: String, columns: String, keyword: String) -> DataRequest {
  34. print("CEK 123")
  35. print("cursor \(cursor)")
  36. print("prev \(prev)")
  37. print("jenis \(jenis)")
  38. print("columns \(columns)")
  39. print("keyword \(keyword)")
  40. let headers: HTTPHeaders = ["Accept" : "Application/json; charset=utf-8"]
  41. let body: Parameters = [
  42. "limit" : String(cursor),
  43. "page" : String(prev),
  44. "jenis" : jenis,
  45. "columns" : columns,
  46. "keyword" : keyword
  47. ]
  48. return AF.request(METHOD_GET_NEWS_NEW, method: .post, parameters: body, encoding: URLEncoding.default, headers: headers)
  49. }
  50. // Notification Total -> Home
  51. func postToGetNotificationsTotal(user_id: Int, cust_id: Int, role_id: String) -> DataRequest {
  52. let headers: HTTPHeaders = ["Accept" : "Application/json; charset=utf-8"]
  53. let body: Parameters = [
  54. "user_id" : String(user_id),
  55. "cust_id" : String(cust_id),
  56. "role_id" : role_id
  57. ]
  58. return AF.request(METHOD_GET_TOTAL_NOTIFIKASI, method: .post, parameters: body, encoding: URLEncoding.default, headers: headers)
  59. }
  60. // Total Unread Notification -> Home
  61. func postToGetTotalUnreadNotif(user_id: Int, cust_id: Int, role_id: String) -> DataRequest {
  62. let headers: HTTPHeaders = ["Accept" : "Application/json; charset=utf-8"]
  63. let body: Parameters = [
  64. "user_id" : String(user_id),
  65. "cust_id" : String(cust_id),
  66. "role_id" : role_id
  67. ]
  68. return AF.request(METHOD_GET_TOTAL_UNREAD_NOTIF, method: .post, parameters: body, encoding: URLEncoding.default, headers: headers)
  69. }
  70. // Notification List
  71. func postToGetPushNotificationList(cursor: Int, prev: Int, user_id: Int, cust_id: Int, role_id: String) -> DataRequest {
  72. let headers: HTTPHeaders = ["Accept" : "Application/json; charset=utf-8"]
  73. let body: Parameters = [
  74. "cursor" : String(cursor),
  75. "prev" : String(prev),
  76. "user_id" : String(user_id),
  77. "cust_id" : String(cust_id),
  78. "role_id" : role_id
  79. ]
  80. return AF.request(METHOD_GET_PUSH_NOTIF_LIST, method: .post, parameters: body, encoding: URLEncoding.default, headers: headers)
  81. }
  82. // Notification Detail
  83. func postToGetPushNotificationDetail(notifId: Int) -> DataRequest {
  84. let headers: HTTPHeaders = ["Accept" : "Application/json; charset=utf-8"]
  85. let body: Parameters = [
  86. "id" : String(notifId)
  87. ]
  88. return AF.request(METHOD_GET_PUSH_NOTIF_DETAIL, method: .post, parameters: body, encoding: URLEncoding.default, headers: headers)
  89. }
  90. // Notification Read
  91. func postToGetPushNotificationRead(notifId: Int) -> DataRequest {
  92. let headers: HTTPHeaders = ["Accept" : "Application/json; charset=utf-8"]
  93. let body: Parameters = [
  94. "log_activity_id" : String(notifId)
  95. ]
  96. return AF.request(METHOD_GET_PUSH_NOTIF_READ, method: .post, parameters: body, encoding: URLEncoding.default, headers: headers)
  97. }
  98. // Notification : Save FCM Token
  99. func postFcmToken(user_id: Int, role_id: String, fcmToken: String) -> DataRequest {
  100. let headers: HTTPHeaders = ["Accept" : "Application/json; charset=utf-8"]
  101. let body: Parameters = [
  102. "role_id" : role_id,
  103. "user_id" : String(user_id),
  104. "token" : fcmToken
  105. ]
  106. return AF.request(METHOD_POST_FCM_TOKEN, method: .post, parameters: body, encoding: URLEncoding.default, headers: headers)
  107. }
  108. // News Detail -> NewsDetailVC
  109. func postToGetNewsDetail(newsId: Int) -> DataRequest {
  110. let headers: HTTPHeaders = ["Accept" : "Application/json; charset=utf-8"]
  111. let body: Parameters = [
  112. "id" : String(newsId)
  113. ]
  114. return AF.request(METHOD_GET_NEWS_DETAIL_NEW, method: .post, parameters: body, encoding: URLEncoding.default, headers: headers)
  115. }
  116. // QR Code Result
  117. func postToGetResultQrCode(code: String) -> DataRequest {
  118. let headers: HTTPHeaders = ["Accept" : "Application/json; charset=utf-8"]
  119. let body: Parameters = [
  120. "kode" : code
  121. ]
  122. return AF.request(METHOD_GET_RESULT_QR_CODE, method: .post, parameters: body, encoding: URLEncoding.default, headers: headers)
  123. }
  124. // List Sertifikat -> DaftarSertifikatVC
  125. func postToGetListSertifikat(jenis: String, columns: String, cursor: Int, prev: Int, search: String) -> DataRequest {
  126. let headers: HTTPHeaders = ["Accept" : "Application/json; charset=utf-8"]
  127. let body: Parameters = [
  128. "jenis" : jenis,
  129. "columns" : columns,
  130. "cursor" : String(cursor),
  131. "prev" : String(prev),
  132. "search" : search
  133. ]
  134. return AF.request(METHOD_GET_LIST_SERTIFIKAT, method: .post, parameters: body, encoding: URLEncoding.default, headers: headers)
  135. }
  136. // Tarif Sertifikat -> TarifSertifikatVC
  137. func postToGetTarifSertifikat(jenis: String, columns: String, cursor: Int, prev: Int, search: String) -> DataRequest {
  138. let headers: HTTPHeaders = ["Accept" : "Application/json; charset=utf-8"]
  139. let body: Parameters = [
  140. "jenis" : jenis,
  141. "columns" : columns,
  142. "cursor" : String(cursor),
  143. "prev" : String(prev),
  144. "search" : search
  145. ]
  146. return AF.request(METHOD_GET_TARIF_SERTIFIKAT, method: .post, parameters: body, encoding: URLEncoding.default, headers: headers)
  147. }
  148. // Balai Uji -> BalaiUjiVC
  149. func postToGetBalaiUji(cursor: Int, prev: Int, jenis: String, columns: String, search: String, cust_id: Int, role_id: String, user_id: Int) -> DataRequest {
  150. let headers: HTTPHeaders = ["Accept" : "Application/json; charset=utf-8"]
  151. let body: Parameters = [
  152. "cursor" : String(cursor),
  153. "prev" : String(prev),
  154. "jenis" : jenis,
  155. "columns" : columns,
  156. "search" : search,
  157. "cust_id" : String(cust_id),
  158. "role_id" : role_id,
  159. "user_id" : String(user_id)
  160. ]
  161. return AF.request(METHOD_GET_BALAI_UJI, method: .post, parameters: body, encoding: URLEncoding.default, headers: headers)
  162. }
  163. // ODS : Aplikasi Entry
  164. func postToGetOdsAplikasiEntry(cursor: Int, prev: Int, jenis: String, columns: String, search: String, cust_id: Int) -> DataRequest {
  165. let headers: HTTPHeaders = ["Accept" : "Application/json; charset=utf-8"]
  166. let body: Parameters = [
  167. "cursor" : String(cursor),
  168. "prev" : String(prev),
  169. "jenis" : jenis,
  170. "columns" : columns,
  171. "search" : search,
  172. "cust_id" : String(cust_id)
  173. ]
  174. return AF.request(METHOD_GET_ODS_APLIKASI_ENTRY, method: .post, parameters: body, encoding: URLEncoding.default, headers: headers)
  175. }
  176. // ODS : SP2 Baru
  177. func postToGetOdsSp2Baru(cursor: Int, prev: Int, jenis: String, columns: String, search: String, cust_id: Int, user_id: Int, role_id: String) -> DataRequest {
  178. let headers: HTTPHeaders = ["Accept" : "Application/json; charset=utf-8"]
  179. let body: Parameters = [
  180. "cursor" : String(cursor),
  181. "prev" : String(prev),
  182. "jenis" : jenis,
  183. "columns" : columns,
  184. "search" : search,
  185. "cust_id" : String(cust_id),
  186. "user_id" : String(user_id),
  187. "role_id" : role_id
  188. ]
  189. return AF.request(METHOD_GET_ODS_SP2_BARU, method: .post, parameters: body, encoding: URLEncoding.default, headers: headers)
  190. }
  191. // ODS : SP2 Otorasi
  192. func postToGetOdsSp2Otorasi(cursor: Int, prev: Int, jenis: String, columns: String, search: String, cust_id: Int, user_id: Int, role_id: String) -> DataRequest {
  193. let headers: HTTPHeaders = ["Accept" : "Application/json; charset=utf-8"]
  194. let body: Parameters = [
  195. "cursor" : String(cursor),
  196. "prev" : String(prev),
  197. "jenis" : jenis,
  198. "columns" : columns,
  199. "search" : search,
  200. "cust_id" : String(cust_id),
  201. "user_id" : String(user_id),
  202. "role_id" : role_id
  203. ]
  204. return AF.request(METHOD_GET_ODS_SP2_OTORASI, method: .post, parameters: body, encoding: URLEncoding.default, headers: headers)
  205. }
  206. // ODS : SP2 Print
  207. func postToGetOdsSp2Print(cursor: Int, prev: Int, jenis: String, columns: String, search: String, cust_id: Int, user_id: Int, role_id: String) -> DataRequest {
  208. let headers: HTTPHeaders = ["Accept" : "Application/json; charset=utf-8"]
  209. let body: Parameters = [
  210. "cursor" : String(cursor),
  211. "prev" : String(prev),
  212. "jenis" : jenis,
  213. "columns" : columns,
  214. "search" : search,
  215. "cust_id" : String(cust_id),
  216. "user_id" : String(user_id),
  217. "role_id" : role_id
  218. ]
  219. return AF.request(METHOD_GET_ODS_SP2_PRINT, method: .post, parameters: body, encoding: URLEncoding.default, headers: headers)
  220. }
  221. // ODS : Daftar RHU
  222. func postToGetOdsDaftarRhu(cursor: Int, prev: Int, jenis: String, columns: String, search: String, cust_id: Int, user_id: Int, role_id: String) -> DataRequest {
  223. let headers: HTTPHeaders = ["Accept" : "Application/json; charset=utf-8"]
  224. let body: Parameters = [
  225. "cursor" : String(cursor),
  226. "prev" : String(prev),
  227. "jenis" : jenis,
  228. "columns" : columns,
  229. "search" : search,
  230. "cust_id" : String(cust_id),
  231. "user_id" : String(user_id),
  232. "role_id" : role_id
  233. ]
  234. return AF.request(METHOD_GET_ODS_DAFTAR_RHU, method: .post, parameters: body, encoding: URLEncoding.default, headers: headers)
  235. }
  236. // ODS : SP2 Before
  237. func postToGetOdsSp2Before(cursor: Int, prev: Int, jenis: String, columns: String, search: String, cust_id: Int, user_id: Int, role_id: String) -> DataRequest {
  238. let headers: HTTPHeaders = ["Accept" : "Application/json; charset=utf-8"]
  239. let body: Parameters = [
  240. "cursor" : String(cursor),
  241. "prev" : String(prev),
  242. "jenis" : jenis,
  243. "columns" : columns,
  244. "search" : search,
  245. "cust_id" : String(cust_id),
  246. "user_id" : String(user_id),
  247. "role_id" : role_id
  248. ]
  249. return AF.request(METHOD_GET_ODS_SP2_BEFORE, method: .post, parameters: body, encoding: URLEncoding.default, headers: headers)
  250. }
  251. // ODS : SP2 After
  252. func postToGetOdsSp2After(cursor: Int, prev: Int, jenis: String, columns: String, search: String, cust_id: Int, user_id: Int, role_id: String) -> DataRequest {
  253. let headers: HTTPHeaders = ["Accept" : "Application/json; charset=utf-8"]
  254. let body: Parameters = [
  255. "cursor" : String(cursor),
  256. "prev" : String(prev),
  257. "jenis" : jenis,
  258. "columns" : columns,
  259. "search" : search,
  260. "cust_id" : String(cust_id),
  261. "user_id" : String(user_id),
  262. "role_id" : role_id
  263. ]
  264. return AF.request(METHOD_GET_ODS_SP2_AFTER, method: .post, parameters: body, encoding: URLEncoding.default, headers: headers)
  265. }
  266. // FOTO LABEL : Sertifikat Belum Upload
  267. func postToGetSurtifikatBelumUpload(cursor: Int, prev: Int, jenis: String, columns: String, search: String, cust_id: Int) -> DataRequest {
  268. let headers: HTTPHeaders = ["Accept" : "Application/json; charset=utf-8"]
  269. let body: Parameters = [
  270. "cursor" : String(cursor),
  271. "prev" : String(prev),
  272. "jenis" : jenis,
  273. "columns" : columns,
  274. "search" : search,
  275. "cust_id" : String(cust_id)
  276. ]
  277. return AF.request(METHOD_GET_SERTIFIKAT_BELUM_UPLOAD, method: .post, parameters: body, encoding: URLEncoding.default, headers: headers)
  278. }
  279. // FOTO LABEL : Sertifikat Belum Upload Detail
  280. func postToGetSurtifikatBelumUploadDetail(apl_id: Int) -> DataRequest {
  281. let headers: HTTPHeaders = ["Accept" : "Application/json; charset=utf-8"]
  282. let body: Parameters = [
  283. "apl_id" : String(apl_id)
  284. ]
  285. return AF.request(METHOD_GET_SERTIFIKAT_BELUM_UPLOAD_DETAIL, method: .post, parameters: body, encoding: URLEncoding.default, headers: headers)
  286. }
  287. // FOTO LABEL : Sertifikat Sudah Upload
  288. func postToGetSurtifikatSudahUpload(cursor: Int, prev: Int, jenis: String, columns: String, search: String, cust_id: Int) -> DataRequest {
  289. let headers: HTTPHeaders = ["Accept" : "Application/json; charset=utf-8"]
  290. let body: Parameters = [
  291. "cursor" : String(cursor),
  292. "prev" : String(prev),
  293. "jenis" : jenis,
  294. "columns" : columns,
  295. "search" : search,
  296. "cust_id" : String(cust_id)
  297. ]
  298. return AF.request(METHOD_GET_SERTIFIKAT_SUDAH_UPLOAD, method: .post, parameters: body, encoding: URLEncoding.default, headers: headers)
  299. }
  300. // FOTO LABEL : Sertifikasi Upload
  301. func uploadSertifikasi(plgId: String, aplId: String, qrCodeFileURL: URL, keteranganFileURL: URL, peringatanFileURL: URL, qrCodeExt: String, keteranganExt: String, peringatanExt: String) -> UploadRequest {
  302. var qrCodeMimeType = "*/*"
  303. var keteranganMimeType = "*/*"
  304. var peringatanMimeType = "*/*"
  305. if qrCodeExt == "pdf" {
  306. qrCodeMimeType = "application/pdf"
  307. } else if qrCodeExt == "jpg" {
  308. qrCodeMimeType = "image/jpg"
  309. } else if qrCodeExt == "jpeg" {
  310. qrCodeMimeType = "image/jpeg"
  311. } else if qrCodeExt == "png" {
  312. qrCodeMimeType = "image/png"
  313. }
  314. if keteranganExt == "pdf" {
  315. keteranganMimeType = "application/pdf"
  316. } else if keteranganExt == "jpg" {
  317. keteranganMimeType = "image/jpg"
  318. } else if keteranganExt == "jpeg" {
  319. keteranganMimeType = "image/jpeg"
  320. } else if keteranganExt == "png" {
  321. keteranganMimeType = "image/png"
  322. }
  323. if peringatanExt == "pdf" {
  324. peringatanMimeType = "application/pdf"
  325. } else if peringatanExt == "jpg" {
  326. peringatanMimeType = "image/jpg"
  327. } else if peringatanExt == "jpeg" {
  328. peringatanMimeType = "image/jpeg"
  329. } else if peringatanExt == "png" {
  330. peringatanMimeType = "image/png"
  331. }
  332. let plgIdData: Data = plgId.data(using: .utf8)!
  333. let aplIdData: Data = aplId.data(using: .utf8)!
  334. let qrCodeData: Data = try! Data(contentsOf: qrCodeFileURL)
  335. let qrCodeFilename = "\(aplId)-file-qrcode.\(qrCodeExt)"
  336. let keteranganData: Data = try! Data(contentsOf: keteranganFileURL)
  337. let keteranganFilename = "\(aplId)-file-label.\(keteranganExt)"
  338. let peringatanData: Data = try! Data(contentsOf: peringatanFileURL)
  339. let peringatanFilename = "\(aplId)-file-peringatan.\(peringatanExt)"
  340. let upload = AF.upload(
  341. multipartFormData: { multipartFormData in
  342. multipartFormData.append(plgIdData, withName: "plg_id")
  343. multipartFormData.append(aplIdData, withName: "apl_id")
  344. multipartFormData.append(qrCodeData, withName: "foto_qrcode", fileName: qrCodeFilename, mimeType: qrCodeMimeType)
  345. multipartFormData.append(keteranganData, withName: "foto_label", fileName: keteranganFilename, mimeType: keteranganMimeType)
  346. multipartFormData.append(peringatanData, withName: "foto_peringatan", fileName: peringatanFilename, mimeType: peringatanMimeType)
  347. },
  348. to: METHOD_UPLOAD_SERTIFIKASI)
  349. return upload
  350. }
  351. // APLIKASI : Aplikasi Ditolak
  352. func postToGetAplikasiDitolak(cursor: Int, prev: Int, jenis: String, columns: String, search: String, cust_id: Int, user_id: Int, role_id: String) -> DataRequest {
  353. let headers: HTTPHeaders = ["Accept" : "Application/json; charset=utf-8"]
  354. let body: Parameters = [
  355. "cursor" : String(cursor),
  356. "prev" : String(prev),
  357. "jenis" : jenis,
  358. "columns" : columns,
  359. "search" : search,
  360. "cust_id" : String(cust_id),
  361. "user_id" : String(user_id),
  362. "role_id" : role_id
  363. ]
  364. return AF.request(METHOD_GET_APLIKASI_DITOLAK, method: .post, parameters: body, encoding: URLEncoding.default, headers: headers)
  365. }
  366. // APLIKASI : Aplikasi Status
  367. func postToGetAplikasiStatus(cursor: Int, prev: Int, jenis: String, columns: String, search: String, cust_id: Int, user_id: Int, role_id: String) -> DataRequest {
  368. let headers: HTTPHeaders = ["Accept" : "Application/json; charset=utf-8"]
  369. let body: Parameters = [
  370. "cursor" : String(cursor),
  371. "prev" : String(prev),
  372. "jenis" : jenis,
  373. "columns" : columns,
  374. "search" : search,
  375. "cust_id" : String(cust_id),
  376. "user_id" : String(user_id),
  377. "role_id" : role_id
  378. ]
  379. return AF.request(METHOD_GET_APLIKASI_STATUS, method: .post, parameters: body, encoding: URLEncoding.default, headers: headers)
  380. }
  381. // SP2 SERTIFIKAT
  382. // SP2 TAMBAHAN
  383. // DAFTAR RHU
  384. // SERTIFIKAT : Sertifikat Sementara
  385. func postToGetSertifikatSementara(cursor: Int, prev: Int, jenis: String, columns: String, search: String, cust_id: Int, user_id: Int, role_id: String) -> DataRequest {
  386. let headers: HTTPHeaders = ["Accept" : "Application/json; charset=utf-8"]
  387. let body: Parameters = [
  388. "cursor" : String(cursor),
  389. "prev" : String(prev),
  390. "jenis" : jenis,
  391. "columns" : columns,
  392. "search" : search,
  393. "cust_id" : String(cust_id),
  394. "user_id" : String(user_id),
  395. "role_id" : role_id
  396. ]
  397. return AF.request(METHOD_GET_SERTIFIKAT_SEMENTARA, method: .post, parameters: body, encoding: URLEncoding.default, headers: headers)
  398. }
  399. // SERTIFIKAT : Sertifikat Berlaku
  400. func postToGetSertifikatBerlaku(cursor: Int, prev: Int, jenis: String, columns: String, search: String, cust_id: Int, user_id: Int, role_id: String) -> DataRequest {
  401. let headers: HTTPHeaders = ["Accept" : "Application/json; charset=utf-8"]
  402. let body: Parameters = [
  403. "cursor" : String(cursor),
  404. "prev" : String(prev),
  405. "jenis" : jenis,
  406. "columns" : columns,
  407. "search" : search,
  408. "cust_id" : String(cust_id),
  409. "user_id" : String(user_id),
  410. "role_id" : role_id
  411. ]
  412. return AF.request(METHOD_GET_SERTIFIKAT_BERLAKU, method: .post, parameters: body, encoding: URLEncoding.default, headers: headers)
  413. }
  414. // SERTIFIKAT : Sertifikat Tidak Berlaku
  415. func postToGetSertifikatTidakBerlaku(cursor: Int, prev: Int, jenis: String, columns: String, search: String, cust_id: Int, user_id: Int, role_id: String) -> DataRequest {
  416. let headers: HTTPHeaders = ["Accept" : "Application/json; charset=utf-8"]
  417. let body: Parameters = [
  418. "cursor" : String(cursor),
  419. "prev" : String(prev),
  420. "jenis" : jenis,
  421. "columns" : columns,
  422. "search" : search,
  423. "cust_id" : String(cust_id),
  424. "user_id" : String(user_id),
  425. "role_id" : role_id
  426. ]
  427. return AF.request(METHOD_GET_SERTIFIKAT_TIDAK_BERLAKU, method: .post, parameters: body, encoding: URLEncoding.default, headers: headers)
  428. }
  429. // SERTIFIKAT : Sertifikat Daftar Pencabutan
  430. func postToGetSertifikatDaftarPencabutan(cursor: Int, prev: Int, jenis: String, columns: String, search: String, cust_id: Int, user_id: Int, role_id: String) -> DataRequest {
  431. let headers: HTTPHeaders = ["Accept" : "Application/json; charset=utf-8"]
  432. let body: Parameters = [
  433. "cursor" : String(cursor),
  434. "prev" : String(prev),
  435. "jenis" : jenis,
  436. "columns" : columns,
  437. "search" : search,
  438. "cust_id" : String(cust_id),
  439. "user_id" : String(user_id),
  440. "role_id" : role_id
  441. ]
  442. return AF.request(METHOD_GET_SERTIFIKAT_DAFTAR_PENCABUTAN, method: .post, parameters: body, encoding: URLEncoding.default, headers: headers)
  443. }
  444. // SP2 Sertifikat
  445. func postToGetSp2Sertifikat(cursor: Int, prev: Int, jenis: String, columns: String, search: String, cust_id: Int, user_id: Int, role_id: String) -> DataRequest {
  446. let headers: HTTPHeaders = ["Accept" : "Application/json; charset=utf-8"]
  447. let body: Parameters = [
  448. "cursor" : String(cursor),
  449. "prev" : String(prev),
  450. "jenis" : jenis,
  451. "columns" : columns,
  452. "search" : search,
  453. "cust_id" : String(cust_id),
  454. "user_id" : String(user_id),
  455. "role_id" : role_id
  456. ]
  457. return AF.request(METHOD_GET_SP2_SERTIFIKAT, method: .post, parameters: body, encoding: URLEncoding.default, headers: headers)
  458. }
  459. // SP2 Tambahan
  460. func postToGetSp2Tambahan(cursor: Int, prev: Int, jenis: String, columns: String, search: String, cust_id: Int, user_id: Int, role_id: String) -> DataRequest {
  461. let headers: HTTPHeaders = ["Accept" : "Application/json; charset=utf-8"]
  462. let body: Parameters = [
  463. "cursor" : String(cursor),
  464. "prev" : String(prev),
  465. "jenis" : jenis,
  466. "columns" : columns,
  467. "search" : search,
  468. "cust_id" : String(cust_id),
  469. "user_id" : String(user_id),
  470. "role_id" : role_id
  471. ]
  472. return AF.request(METHOD_GET_SP2_TAMBAHAN, method: .post, parameters: body, encoding: URLEncoding.default, headers: headers)
  473. }
  474. // Daftar RHU
  475. func postToGetDaftarRhu(cursor: Int, prev: Int, jenis: String, columns: String, search: String, cust_id: Int, user_id: Int, role_id: String) -> DataRequest {
  476. let headers: HTTPHeaders = ["Accept" : "Application/json; charset=utf-8"]
  477. let body: Parameters = [
  478. "cursor" : String(cursor),
  479. "prev" : String(prev),
  480. "jenis" : jenis,
  481. "columns" : columns,
  482. "search" : search,
  483. "cust_id" : String(cust_id),
  484. "user_id" : String(user_id),
  485. "role_id" : role_id
  486. ]
  487. return AF.request(METHOD_GET_DAFTAR_RHU, method: .post, parameters: body, encoding: URLEncoding.default, headers: headers)
  488. }
  489. // Pertanyaan Survey -> SurveyVC
  490. func postToGetPertanyaanSurvey(cursor: Int, prev: Int, search: String) -> DataRequest {
  491. let headers: HTTPHeaders = ["Accept" : "Application/json; charset=utf-8"]
  492. let body: Parameters = [
  493. "cursor" : String(cursor),
  494. "prev" : String(prev),
  495. "search" : search
  496. ]
  497. return AF.request(METHOD_GET_PERTANYAAN_SURVEY, method: .post, parameters: body, encoding: URLEncoding.default, headers: headers)
  498. }
  499. // List Jawaban Survey -> SurveyVC
  500. func postToGetListJawabanSurvey(cursor: Int, prev: Int, search: String) -> DataRequest {
  501. let headers: HTTPHeaders = ["Accept" : "Application/json; charset=utf-8"]
  502. let body: Parameters = [
  503. "cursor" : String(cursor),
  504. "prev" : String(prev),
  505. "search" : search
  506. ]
  507. return AF.request(METHOD_GET_JAWABAN_SURVEY_LIST, method: .post, parameters: body, encoding: URLEncoding.default, headers: headers)
  508. }
  509. // Post Jawaban Survey -> SurveyVC
  510. func postJawabanSurvey(user_id: Int, cust_id: Int, survey_id: Int, jawaban: Int) -> DataRequest {
  511. let headers: HTTPHeaders = ["Accept" : "Application/json; charset=utf-8"]
  512. let body: Parameters = [
  513. "user_id" : String(user_id),
  514. "cust_id" : String(cust_id),
  515. "survey_id" : String(survey_id),
  516. "jawaban" : String(jawaban)
  517. ]
  518. return AF.request(METHOD_POST_JAWABAN_SURVEY, method: .post, parameters: body, encoding: URLEncoding.default, headers: headers)
  519. }
  520. // Hasil Survey -> HasilSurveyVC
  521. func postToGetHasilSurvey(jenis: String, columns: String, cursor: Int, prev: Int, search: String) -> DataRequest {
  522. let headers: HTTPHeaders = ["Accept" : "Application/json; charset=utf-8"]
  523. let body: Parameters = [
  524. "jenis" : jenis,
  525. "columns" : columns,
  526. "cursor" : String(cursor),
  527. "prev" : String(prev),
  528. "search" : search
  529. ]
  530. return AF.request(METHOD_GET_HASIL_SURVEY, method: .post, parameters: body, encoding: URLEncoding.default, headers: headers)
  531. }
  532. func postToGetFaqCategory() -> DataRequest {
  533. let headers: HTTPHeaders = ["Accept" : "Application/json; charset=utf-8"]
  534. return AF.request(METHOD_GET_FAQ_CATEGORY, method: .get, encoding: URLEncoding.default, headers: headers)
  535. }
  536. func postToGetFaqContent(faq_cat_id: Int) -> DataRequest {
  537. let headers: HTTPHeaders = ["Accept" : "Application/json; charset=utf-8"]
  538. let url = "\(METHOD_GET_FAQ_CONTENT)/\(faq_cat_id)"
  539. return AF.request(url, method: .get, encoding: URLEncoding.default, headers: headers)
  540. }
  541. }