onfido 2.9.0 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (378) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +11 -4
  3. data/Gemfile +5 -4
  4. data/LICENSE +5 -7
  5. data/README.md +69 -51
  6. data/Rakefile +10 -0
  7. data/lib/onfido/api/default_api.rb +4233 -0
  8. data/lib/onfido/api_client.rb +431 -0
  9. data/lib/onfido/api_error.rb +58 -0
  10. data/lib/onfido/configuration.rb +420 -0
  11. data/lib/onfido/models/address.rb +422 -0
  12. data/lib/onfido/models/address_builder.rb +422 -0
  13. data/lib/onfido/models/address_shared.rb +415 -0
  14. data/lib/onfido/models/addresses_list.rb +216 -0
  15. data/lib/onfido/models/applicant.rb +390 -0
  16. data/lib/onfido/models/applicant_builder.rb +358 -0
  17. data/lib/onfido/models/applicant_create.rb +281 -0
  18. data/lib/onfido/models/applicant_request.rb +232 -0
  19. data/lib/onfido/models/applicant_response.rb +341 -0
  20. data/lib/onfido/models/applicant_shared.rb +246 -0
  21. data/lib/onfido/models/applicant_update.rb +267 -0
  22. data/lib/onfido/models/applicant_updater.rb +344 -0
  23. data/lib/onfido/models/applicants_list.rb +223 -0
  24. data/lib/onfido/models/check.rb +419 -0
  25. data/lib/onfido/models/check_builder.rb +360 -0
  26. data/lib/onfido/models/check_request.rb +301 -0
  27. data/lib/onfido/models/check_response.rb +350 -0
  28. data/lib/onfido/models/check_shared.rb +266 -0
  29. data/lib/onfido/models/checks_list.rb +223 -0
  30. data/lib/onfido/models/complete_task_builder.rb +221 -0
  31. data/lib/onfido/models/complete_task_data_builder.rb +106 -0
  32. data/lib/onfido/models/consent_item.rb +272 -0
  33. data/lib/onfido/models/consents_builder.rb +205 -0
  34. data/lib/onfido/models/country_codes.rb +289 -0
  35. data/lib/onfido/models/device_intelligence_breakdown.rb +223 -0
  36. data/lib/onfido/models/device_intelligence_breakdown_breakdown.rb +214 -0
  37. data/lib/onfido/models/device_intelligence_breakdown_breakdown_device.rb +215 -0
  38. data/lib/onfido/models/device_intelligence_breakdown_breakdown_device_breakdown.rb +232 -0
  39. data/lib/onfido/models/device_intelligence_breakdown_properties.rb +232 -0
  40. data/lib/onfido/models/device_intelligence_breakdown_properties_device.rb +468 -0
  41. data/lib/onfido/models/device_intelligence_breakdown_properties_geolocation.rb +257 -0
  42. data/lib/onfido/models/device_intelligence_breakdown_properties_ip.rb +245 -0
  43. data/lib/onfido/models/device_intelligence_report.rb +345 -0
  44. data/lib/onfido/models/document.rb +376 -0
  45. data/lib/onfido/models/document_breakdown.rb +286 -0
  46. data/lib/onfido/models/document_breakdown_age_validation.rb +224 -0
  47. data/lib/onfido/models/document_breakdown_age_validation_breakdown.rb +214 -0
  48. data/lib/onfido/models/document_breakdown_compromised_document.rb +224 -0
  49. data/lib/onfido/models/document_breakdown_compromised_document_breakdown.rb +223 -0
  50. data/lib/onfido/models/document_breakdown_data_comparison.rb +224 -0
  51. data/lib/onfido/models/document_breakdown_data_comparison_breakdown.rb +277 -0
  52. data/lib/onfido/models/document_breakdown_data_comparison_breakdown_issuing_country.rb +223 -0
  53. data/lib/onfido/models/document_breakdown_data_consistency.rb +224 -0
  54. data/lib/onfido/models/document_breakdown_data_consistency_breakdown.rb +295 -0
  55. data/lib/onfido/models/document_breakdown_data_validation.rb +224 -0
  56. data/lib/onfido/models/document_breakdown_data_validation_breakdown.rb +268 -0
  57. data/lib/onfido/models/document_breakdown_data_validation_breakdown_document_expiration.rb +224 -0
  58. data/lib/onfido/models/document_breakdown_data_validation_breakdown_expiry_date.rb +224 -0
  59. data/lib/onfido/models/document_breakdown_image_integrity.rb +224 -0
  60. data/lib/onfido/models/document_breakdown_image_integrity_breakdown.rb +241 -0
  61. data/lib/onfido/models/document_breakdown_image_integrity_breakdown_colour_picture.rb +224 -0
  62. data/lib/onfido/models/document_breakdown_image_integrity_breakdown_conclusive_document_quality.rb +224 -0
  63. data/lib/onfido/models/document_breakdown_image_integrity_breakdown_image_quality.rb +224 -0
  64. data/lib/onfido/models/document_breakdown_image_integrity_breakdown_supported_document.rb +224 -0
  65. data/lib/onfido/models/document_breakdown_issuing_authority.rb +224 -0
  66. data/lib/onfido/models/document_breakdown_issuing_authority_breakdown.rb +223 -0
  67. data/lib/onfido/models/document_breakdown_issuing_authority_breakdown_nfc_active_authentication.rb +224 -0
  68. data/lib/onfido/models/document_breakdown_issuing_authority_breakdown_nfc_passive_authentication.rb +224 -0
  69. data/lib/onfido/models/document_breakdown_police_record.rb +215 -0
  70. data/lib/onfido/models/document_breakdown_visual_authenticity.rb +224 -0
  71. data/lib/onfido/models/document_breakdown_visual_authenticity_breakdown.rb +277 -0
  72. data/lib/onfido/models/document_breakdown_visual_authenticity_breakdown_digital_tampering.rb +224 -0
  73. data/lib/onfido/models/document_breakdown_visual_authenticity_breakdown_face_detection.rb +224 -0
  74. data/lib/onfido/models/document_breakdown_visual_authenticity_breakdown_fonts.rb +224 -0
  75. data/lib/onfido/models/document_breakdown_visual_authenticity_breakdown_original_document_present.rb +224 -0
  76. data/lib/onfido/models/document_breakdown_visual_authenticity_breakdown_other.rb +224 -0
  77. data/lib/onfido/models/document_breakdown_visual_authenticity_breakdown_picture_face_integrity.rb +224 -0
  78. data/lib/onfido/models/document_breakdown_visual_authenticity_breakdown_security_features.rb +224 -0
  79. data/lib/onfido/models/document_breakdown_visual_authenticity_breakdown_template.rb +224 -0
  80. data/lib/onfido/models/document_cdq_reasons.rb +285 -0
  81. data/lib/onfido/models/document_iq_reasons.rb +305 -0
  82. data/lib/onfido/models/document_odp_reasons.rb +245 -0
  83. data/lib/onfido/models/document_properties.rb +461 -0
  84. data/lib/onfido/models/document_properties_address_lines.rb +259 -0
  85. data/lib/onfido/models/document_properties_barcode_inner.rb +367 -0
  86. data/lib/onfido/models/document_properties_document_classification.rb +232 -0
  87. data/lib/onfido/models/document_properties_document_numbers_inner.rb +223 -0
  88. data/lib/onfido/models/document_properties_driving_licence_information.rb +241 -0
  89. data/lib/onfido/models/document_properties_extracted_data.rb +394 -0
  90. data/lib/onfido/models/document_properties_nfc.rb +322 -0
  91. data/lib/onfido/models/document_report.rb +354 -0
  92. data/lib/onfido/models/document_response.rb +272 -0
  93. data/lib/onfido/models/document_shared.rb +301 -0
  94. data/lib/onfido/models/document_types.rb +64 -0
  95. data/lib/onfido/models/document_video_report.rb +354 -0
  96. data/lib/onfido/models/document_video_with_address_information_report.rb +354 -0
  97. data/lib/onfido/models/document_with_address_information_report.rb +354 -0
  98. data/lib/onfido/models/document_with_driver_verification_report.rb +354 -0
  99. data/lib/onfido/models/document_with_driver_verification_report_all_of_properties.rb +529 -0
  100. data/lib/onfido/models/document_with_driver_verification_report_all_of_properties_all_of_passenger_vehicle.rb +236 -0
  101. data/lib/onfido/models/document_with_driver_verification_report_all_of_properties_all_of_vehicle_class_details_inner.rb +245 -0
  102. data/lib/onfido/models/document_with_driving_licence_information_report.rb +354 -0
  103. data/lib/onfido/models/documents_list.rb +223 -0
  104. data/lib/onfido/models/error.rb +214 -0
  105. data/lib/onfido/models/error1.rb +224 -0
  106. data/lib/onfido/models/error_properties.rb +234 -0
  107. data/lib/onfido/models/error_properties1.rb +223 -0
  108. data/lib/onfido/models/extract_request.rb +222 -0
  109. data/lib/onfido/models/extraction.rb +233 -0
  110. data/lib/onfido/models/extraction_document_classification.rb +289 -0
  111. data/lib/onfido/models/extraction_extracted_data.rb +530 -0
  112. data/lib/onfido/models/facial_similarity_motion_breakdown.rb +232 -0
  113. data/lib/onfido/models/facial_similarity_motion_breakdown_face_comparison.rb +224 -0
  114. data/lib/onfido/models/facial_similarity_motion_breakdown_image_integrity.rb +224 -0
  115. data/lib/onfido/models/facial_similarity_motion_breakdown_image_integrity_breakdown.rb +223 -0
  116. data/lib/onfido/models/facial_similarity_motion_breakdown_image_integrity_breakdown_face_detected.rb +224 -0
  117. data/lib/onfido/models/facial_similarity_motion_breakdown_image_integrity_breakdown_source_integrity.rb +224 -0
  118. data/lib/onfido/models/facial_similarity_motion_breakdown_visual_authenticity.rb +224 -0
  119. data/lib/onfido/models/facial_similarity_motion_breakdown_visual_authenticity_breakdown.rb +223 -0
  120. data/lib/onfido/models/facial_similarity_motion_breakdown_visual_authenticity_breakdown_spoofing_detection.rb +224 -0
  121. data/lib/onfido/models/facial_similarity_motion_properties.rb +215 -0
  122. data/lib/onfido/models/facial_similarity_motion_report.rb +354 -0
  123. data/lib/onfido/models/facial_similarity_photo_breakdown.rb +232 -0
  124. data/lib/onfido/models/facial_similarity_photo_breakdown_face_comparison.rb +224 -0
  125. data/lib/onfido/models/facial_similarity_photo_breakdown_face_comparison_breakdown.rb +214 -0
  126. data/lib/onfido/models/facial_similarity_photo_breakdown_face_comparison_breakdown_face_match.rb +224 -0
  127. data/lib/onfido/models/facial_similarity_photo_breakdown_face_comparison_breakdown_face_match_properties.rb +225 -0
  128. data/lib/onfido/models/facial_similarity_photo_breakdown_image_integrity.rb +224 -0
  129. data/lib/onfido/models/facial_similarity_photo_breakdown_image_integrity_breakdown.rb +223 -0
  130. data/lib/onfido/models/facial_similarity_photo_breakdown_image_integrity_breakdown_face_detected.rb +224 -0
  131. data/lib/onfido/models/facial_similarity_photo_breakdown_image_integrity_breakdown_source_integrity.rb +224 -0
  132. data/lib/onfido/models/facial_similarity_photo_breakdown_visual_authenticity.rb +224 -0
  133. data/lib/onfido/models/facial_similarity_photo_breakdown_visual_authenticity_breakdown.rb +214 -0
  134. data/lib/onfido/models/facial_similarity_photo_breakdown_visual_authenticity_breakdown_spoofing_detection.rb +224 -0
  135. data/lib/onfido/models/facial_similarity_photo_breakdown_visual_authenticity_breakdown_spoofing_detection_properties.rb +215 -0
  136. data/lib/onfido/models/facial_similarity_photo_fully_auto_breakdown.rb +232 -0
  137. data/lib/onfido/models/facial_similarity_photo_fully_auto_breakdown_image_integrity.rb +224 -0
  138. data/lib/onfido/models/facial_similarity_photo_fully_auto_breakdown_image_integrity_breakdown.rb +223 -0
  139. data/lib/onfido/models/facial_similarity_photo_fully_auto_breakdown_image_integrity_breakdown_source_integrity.rb +224 -0
  140. data/lib/onfido/models/facial_similarity_photo_fully_auto_properties.rb +215 -0
  141. data/lib/onfido/models/facial_similarity_photo_fully_auto_report.rb +354 -0
  142. data/lib/onfido/models/facial_similarity_photo_properties.rb +215 -0
  143. data/lib/onfido/models/facial_similarity_photo_report.rb +354 -0
  144. data/lib/onfido/models/facial_similarity_video_breakdown.rb +232 -0
  145. data/lib/onfido/models/facial_similarity_video_breakdown_face_comparison.rb +224 -0
  146. data/lib/onfido/models/facial_similarity_video_breakdown_image_integrity.rb +224 -0
  147. data/lib/onfido/models/facial_similarity_video_breakdown_image_integrity_breakdown.rb +223 -0
  148. data/lib/onfido/models/facial_similarity_video_breakdown_image_integrity_breakdown_face_detected.rb +224 -0
  149. data/lib/onfido/models/facial_similarity_video_breakdown_image_integrity_breakdown_source_integrity.rb +224 -0
  150. data/lib/onfido/models/facial_similarity_video_breakdown_visual_authenticity.rb +224 -0
  151. data/lib/onfido/models/facial_similarity_video_breakdown_visual_authenticity_breakdown.rb +223 -0
  152. data/lib/onfido/models/facial_similarity_video_breakdown_visual_authenticity_breakdown_liveness_detected.rb +224 -0
  153. data/lib/onfido/models/facial_similarity_video_breakdown_visual_authenticity_breakdown_spoofing_detection.rb +224 -0
  154. data/lib/onfido/models/facial_similarity_video_properties.rb +215 -0
  155. data/lib/onfido/models/facial_similarity_video_report.rb +354 -0
  156. data/lib/onfido/models/id_number.rb +269 -0
  157. data/lib/onfido/models/id_photo.rb +289 -0
  158. data/lib/onfido/models/id_photo_response.rb +282 -0
  159. data/lib/onfido/models/id_photos_list.rb +223 -0
  160. data/lib/onfido/models/identity_enhanced_breakdown.rb +241 -0
  161. data/lib/onfido/models/identity_enhanced_breakdown_address.rb +224 -0
  162. data/lib/onfido/models/identity_enhanced_breakdown_address_breakdown.rb +232 -0
  163. data/lib/onfido/models/identity_enhanced_breakdown_address_breakdown_credit_agencies.rb +224 -0
  164. data/lib/onfido/models/identity_enhanced_breakdown_address_breakdown_credit_agencies_properties.rb +214 -0
  165. data/lib/onfido/models/identity_enhanced_breakdown_address_breakdown_telephone_database.rb +224 -0
  166. data/lib/onfido/models/identity_enhanced_breakdown_address_breakdown_voting_register.rb +224 -0
  167. data/lib/onfido/models/identity_enhanced_breakdown_date_of_birth.rb +224 -0
  168. data/lib/onfido/models/identity_enhanced_breakdown_date_of_birth_breakdown.rb +223 -0
  169. data/lib/onfido/models/identity_enhanced_breakdown_date_of_birth_breakdown_credit_agencies.rb +224 -0
  170. data/lib/onfido/models/identity_enhanced_breakdown_date_of_birth_breakdown_voting_register.rb +224 -0
  171. data/lib/onfido/models/identity_enhanced_breakdown_mortality.rb +215 -0
  172. data/lib/onfido/models/identity_enhanced_breakdown_sources.rb +224 -0
  173. data/lib/onfido/models/identity_enhanced_breakdown_sources_breakdown.rb +214 -0
  174. data/lib/onfido/models/identity_enhanced_breakdown_sources_breakdown_total_sources.rb +224 -0
  175. data/lib/onfido/models/identity_enhanced_breakdown_sources_breakdown_total_sources_properties.rb +214 -0
  176. data/lib/onfido/models/identity_enhanced_properties.rb +227 -0
  177. data/lib/onfido/models/identity_enhanced_properties_matched_addresses_inner.rb +227 -0
  178. data/lib/onfido/models/identity_enhanced_report.rb +354 -0
  179. data/lib/onfido/models/india_pan_report.rb +354 -0
  180. data/lib/onfido/models/india_pan_report_all_of_breakdown.rb +214 -0
  181. data/lib/onfido/models/india_pan_report_all_of_breakdown_device.rb +214 -0
  182. data/lib/onfido/models/india_pan_report_all_of_breakdown_device_breakdown.rb +223 -0
  183. data/lib/onfido/models/india_pan_report_all_of_breakdown_device_breakdown_pan_valid.rb +214 -0
  184. data/lib/onfido/models/india_pan_report_all_of_properties.rb +214 -0
  185. data/lib/onfido/models/india_pan_report_all_of_properties_device.rb +225 -0
  186. data/lib/onfido/models/known_faces_breakdown.rb +223 -0
  187. data/lib/onfido/models/known_faces_breakdown_image_integrity.rb +215 -0
  188. data/lib/onfido/models/known_faces_breakdown_previously_seen_faces.rb +215 -0
  189. data/lib/onfido/models/known_faces_properties.rb +217 -0
  190. data/lib/onfido/models/known_faces_properties_matches_inner.rb +255 -0
  191. data/lib/onfido/models/known_faces_report.rb +354 -0
  192. data/lib/onfido/models/live_photo.rb +289 -0
  193. data/lib/onfido/models/live_photo_response.rb +282 -0
  194. data/lib/onfido/models/live_photos_list.rb +223 -0
  195. data/lib/onfido/models/live_video.rb +287 -0
  196. data/lib/onfido/models/live_videos_list.rb +223 -0
  197. data/lib/onfido/models/location.rb +254 -0
  198. data/lib/onfido/models/location_builder.rb +254 -0
  199. data/lib/onfido/models/location_shared.rb +247 -0
  200. data/lib/onfido/models/motion_capture.rb +275 -0
  201. data/lib/onfido/models/motion_captures_list.rb +223 -0
  202. data/lib/onfido/models/photo_auto_reasons.rb +255 -0
  203. data/lib/onfido/models/photo_reasons.rb +255 -0
  204. data/lib/onfido/models/proof_of_address_breakdown.rb +232 -0
  205. data/lib/onfido/models/proof_of_address_breakdown_data_comparison.rb +224 -0
  206. data/lib/onfido/models/proof_of_address_breakdown_data_comparison_breakdown.rb +232 -0
  207. data/lib/onfido/models/proof_of_address_breakdown_document_classification.rb +224 -0
  208. data/lib/onfido/models/proof_of_address_breakdown_document_classification_breakdown.rb +214 -0
  209. data/lib/onfido/models/proof_of_address_breakdown_image_integrity.rb +224 -0
  210. data/lib/onfido/models/proof_of_address_breakdown_image_integrity_breakdown.rb +214 -0
  211. data/lib/onfido/models/proof_of_address_properties.rb +319 -0
  212. data/lib/onfido/models/proof_of_address_report.rb +354 -0
  213. data/lib/onfido/models/repeat_attempts_list.rb +292 -0
  214. data/lib/onfido/models/repeat_attempts_list_repeat_attempts_inner.rb +333 -0
  215. data/lib/onfido/models/report.rb +93 -0
  216. data/lib/onfido/models/report_document.rb +222 -0
  217. data/lib/onfido/models/report_name.rb +60 -0
  218. data/lib/onfido/models/report_result.rb +42 -0
  219. data/lib/onfido/models/report_shared.rb +329 -0
  220. data/lib/onfido/models/report_status.rb +44 -0
  221. data/lib/onfido/models/report_sub_result.rb +43 -0
  222. data/lib/onfido/models/reports_list.rb +223 -0
  223. data/lib/onfido/models/results_feedback.rb +279 -0
  224. data/lib/onfido/models/sdk_token.rb +229 -0
  225. data/lib/onfido/models/sdk_token_builder.rb +259 -0
  226. data/lib/onfido/models/sdk_token_request.rb +252 -0
  227. data/lib/onfido/models/sdk_token_response.rb +222 -0
  228. data/lib/onfido/models/task.rb +329 -0
  229. data/lib/onfido/models/task_item.rb +287 -0
  230. data/lib/onfido/models/timeline_file_reference.rb +239 -0
  231. data/lib/onfido/models/us_driving_licence_breakdown.rb +232 -0
  232. data/lib/onfido/models/us_driving_licence_breakdown_address.rb +224 -0
  233. data/lib/onfido/models/us_driving_licence_breakdown_address_breakdown.rb +259 -0
  234. data/lib/onfido/models/us_driving_licence_breakdown_document.rb +224 -0
  235. data/lib/onfido/models/us_driving_licence_breakdown_document_breakdown.rb +241 -0
  236. data/lib/onfido/models/us_driving_licence_breakdown_personal.rb +224 -0
  237. data/lib/onfido/models/us_driving_licence_breakdown_personal_breakdown.rb +322 -0
  238. data/lib/onfido/models/us_driving_licence_builder.rb +505 -0
  239. data/lib/onfido/models/us_driving_licence_report.rb +354 -0
  240. data/lib/onfido/models/us_driving_licence_shared.rb +499 -0
  241. data/lib/onfido/models/video_reasons.rb +245 -0
  242. data/lib/onfido/models/watchlist_aml_breakdown.rb +241 -0
  243. data/lib/onfido/models/watchlist_aml_breakdown_adverse_media.rb +215 -0
  244. data/lib/onfido/models/watchlist_aml_breakdown_legal_and_regulatory_warnings.rb +215 -0
  245. data/lib/onfido/models/watchlist_aml_breakdown_politically_exposed_person.rb +215 -0
  246. data/lib/onfido/models/watchlist_aml_breakdown_sanction.rb +215 -0
  247. data/lib/onfido/models/watchlist_aml_properties.rb +217 -0
  248. data/lib/onfido/models/watchlist_aml_report.rb +354 -0
  249. data/lib/onfido/models/watchlist_enhanced_breakdown.rb +241 -0
  250. data/lib/onfido/models/watchlist_enhanced_properties.rb +217 -0
  251. data/lib/onfido/models/watchlist_enhanced_report.rb +354 -0
  252. data/lib/onfido/models/watchlist_monitor.rb +342 -0
  253. data/lib/onfido/models/watchlist_monitor_builder.rb +292 -0
  254. data/lib/onfido/models/watchlist_monitor_match.rb +225 -0
  255. data/lib/onfido/models/watchlist_monitor_matches_list.rb +223 -0
  256. data/lib/onfido/models/watchlist_monitor_matches_updater.rb +227 -0
  257. data/lib/onfido/models/watchlist_monitor_response.rb +254 -0
  258. data/lib/onfido/models/watchlist_monitor_shared.rb +285 -0
  259. data/lib/onfido/models/watchlist_monitors_list.rb +223 -0
  260. data/lib/onfido/models/watchlist_peps_only_report.rb +354 -0
  261. data/lib/onfido/models/watchlist_sanctions_only_report.rb +354 -0
  262. data/lib/onfido/models/watchlist_standard_breakdown.rb +232 -0
  263. data/lib/onfido/models/watchlist_standard_properties.rb +217 -0
  264. data/lib/onfido/models/watchlist_standard_report.rb +354 -0
  265. data/lib/onfido/models/webhook.rb +304 -0
  266. data/lib/onfido/models/webhook_builder.rb +274 -0
  267. data/lib/onfido/models/webhook_create.rb +222 -0
  268. data/lib/onfido/models/webhook_event.rb +214 -0
  269. data/lib/onfido/models/webhook_event_payload.rb +273 -0
  270. data/lib/onfido/models/webhook_event_payload_object.rb +260 -0
  271. data/lib/onfido/models/webhook_event_type.rb +56 -0
  272. data/lib/onfido/models/webhook_resend.rb +216 -0
  273. data/lib/onfido/models/webhook_response.rb +252 -0
  274. data/lib/onfido/models/webhook_shared.rb +249 -0
  275. data/lib/onfido/models/webhook_update.rb +215 -0
  276. data/lib/onfido/models/webhook_updater.rb +267 -0
  277. data/lib/onfido/models/webhooks_list.rb +223 -0
  278. data/lib/onfido/models/webhooks_resend_item.rb +261 -0
  279. data/lib/onfido/models/workflow_run.rb +416 -0
  280. data/lib/onfido/models/workflow_run_builder.rb +316 -0
  281. data/lib/onfido/models/workflow_run_request.rb +217 -0
  282. data/lib/onfido/models/workflow_run_response.rb +317 -0
  283. data/lib/onfido/models/workflow_run_response_error.rb +226 -0
  284. data/lib/onfido/models/workflow_run_shared.rb +296 -0
  285. data/lib/onfido/models/workflow_run_shared_link.rb +290 -0
  286. data/lib/onfido/version.rb +12 -2
  287. data/lib/onfido/webhook_event_verifier.rb +20 -0
  288. data/lib/onfido.rb +309 -25
  289. data/onfido.gemspec +42 -33
  290. data/spec/integrations/address_picker_spec.rb +16 -0
  291. data/spec/integrations/applicant_spec.rb +73 -95
  292. data/spec/integrations/check_spec.rb +60 -41
  293. data/spec/integrations/document_spec.rb +28 -57
  294. data/spec/integrations/extraction_spec.rb +27 -12
  295. data/spec/integrations/id_photo_spec.rb +55 -0
  296. data/spec/integrations/live_photo_spec.rb +28 -45
  297. data/spec/integrations/live_video_spec.rb +33 -19
  298. data/spec/integrations/media/sample_driving_licence.png +0 -0
  299. data/spec/integrations/media/sample_photo.png +0 -0
  300. data/spec/integrations/motion_capture_spec.rb +30 -24
  301. data/spec/integrations/report_schema_spec.rb +45 -0
  302. data/spec/integrations/report_spec.rb +34 -25
  303. data/spec/integrations/sdk_token_spec.rb +12 -10
  304. data/spec/integrations/tasks_spec.rb +45 -0
  305. data/spec/integrations/watchlist_monitor_spec.rb +73 -0
  306. data/spec/integrations/webhook_spec.rb +40 -88
  307. data/spec/integrations/workflow_run_output_spec.rb +117 -0
  308. data/spec/integrations/workflow_run_spec.rb +64 -34
  309. data/spec/shared_contexts/with_applicant.rb +24 -0
  310. data/spec/shared_contexts/with_check.rb +18 -0
  311. data/spec/shared_contexts/with_document.rb +13 -0
  312. data/spec/shared_contexts/with_live_photo.rb +18 -0
  313. data/spec/shared_contexts/with_onfido.rb +14 -0
  314. data/spec/shared_contexts/with_workflow_run.rb +19 -0
  315. data/spec/spec_helper.rb +73 -11
  316. data/spec/webhook_event_verifier_spec.rb +29 -0
  317. metadata +367 -157
  318. data/.github/workflows/gem-push.yml +0 -31
  319. data/.github/workflows/ruby.yml +0 -25
  320. data/.gitignore +0 -19
  321. data/.rspec +0 -2
  322. data/.rubocop.yml +0 -13
  323. data/lib/onfido/api.rb +0 -65
  324. data/lib/onfido/errors/connection_error.rb +0 -6
  325. data/lib/onfido/errors/onfido_error.rb +0 -30
  326. data/lib/onfido/errors/request_error.rb +0 -6
  327. data/lib/onfido/errors/server_error.rb +0 -6
  328. data/lib/onfido/options.rb +0 -38
  329. data/lib/onfido/resource.rb +0 -153
  330. data/lib/onfido/resources/address.rb +0 -9
  331. data/lib/onfido/resources/applicant.rb +0 -29
  332. data/lib/onfido/resources/check.rb +0 -28
  333. data/lib/onfido/resources/document.rb +0 -28
  334. data/lib/onfido/resources/extraction.rb +0 -11
  335. data/lib/onfido/resources/live_photo.rb +0 -27
  336. data/lib/onfido/resources/live_video.rb +0 -17
  337. data/lib/onfido/resources/monitor.rb +0 -32
  338. data/lib/onfido/resources/motion_capture.rb +0 -21
  339. data/lib/onfido/resources/report.rb +0 -21
  340. data/lib/onfido/resources/sdk_token.rb +0 -10
  341. data/lib/onfido/resources/webhook.rb +0 -40
  342. data/lib/onfido/resources/workflow_run.rb +0 -21
  343. data/spec/integrations/address_spec.rb +0 -13
  344. data/spec/integrations/monitor_spec.rb +0 -100
  345. data/spec/integrations/resource_spec.rb +0 -106
  346. data/spec/onfido/api_spec.rb +0 -22
  347. data/spec/onfido/connection_error_spec.rb +0 -20
  348. data/spec/onfido/options_spec.rb +0 -39
  349. data/spec/onfido/request_error_spec.rb +0 -36
  350. data/spec/support/fake_onfido_api.rb +0 -295
  351. data/spec/support/fixtures/4xx_response.json +0 -14
  352. data/spec/support/fixtures/addresses.json +0 -24
  353. data/spec/support/fixtures/applicant.json +0 -28
  354. data/spec/support/fixtures/applicants.json +0 -12
  355. data/spec/support/fixtures/check.json +0 -12
  356. data/spec/support/fixtures/checks.json +0 -16
  357. data/spec/support/fixtures/document.json +0 -10
  358. data/spec/support/fixtures/documents.json +0 -23
  359. data/spec/support/fixtures/extraction.json +0 -23
  360. data/spec/support/fixtures/live_photo.json +0 -9
  361. data/spec/support/fixtures/live_photos.json +0 -22
  362. data/spec/support/fixtures/live_video.json +0 -23
  363. data/spec/support/fixtures/live_videos.json +0 -27
  364. data/spec/support/fixtures/monitor.json +0 -8
  365. data/spec/support/fixtures/monitor_matches.json +0 -12
  366. data/spec/support/fixtures/monitors.json +0 -12
  367. data/spec/support/fixtures/motion_capture.json +0 -9
  368. data/spec/support/fixtures/motion_captures.json +0 -13
  369. data/spec/support/fixtures/not_scheduled_for_deletion_error.json +0 -7
  370. data/spec/support/fixtures/report.json +0 -10
  371. data/spec/support/fixtures/reports.json +0 -24
  372. data/spec/support/fixtures/sdk_token.json +0 -3
  373. data/spec/support/fixtures/signed_workflow_run.pdf +0 -0
  374. data/spec/support/fixtures/unexpected_error_format.json +0 -3
  375. data/spec/support/fixtures/webhook.json +0 -14
  376. data/spec/support/fixtures/webhooks.json +0 -31
  377. data/spec/support/fixtures/workflow_run.json +0 -20
  378. data/spec/support/fixtures/workflow_runs.json +0 -42
@@ -1,41 +1,50 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- describe Onfido::Report do
4
- include_context 'fake onfido api'
5
-
6
- subject(:report) { onfido.report }
3
+ require_relative '../shared_contexts/with_check'
7
4
 
8
- describe '#find' do
9
- it 'returns a report for an existing check' do
10
- report_id = '6951786-123123-422221'
11
- response = report.find(report_id)
5
+ describe Onfido::Report do
6
+ describe 'Report' do
7
+ include_context 'with check'
12
8
 
13
- expect(response['id']).to eq(report_id)
9
+ let(:sorted_reports) do
10
+ sort_reports(onfido_api.list_reports(check.id).reports)
14
11
  end
15
- end
12
+ let(:document_report_id) { sorted_reports[0].id }
13
+ let(:identity_report_id) { sorted_reports[1].id }
16
14
 
17
- describe '#all' do
18
- it 'lists all reports for an existing check' do
19
- check_id = '8546921-123123-123123'
20
- response = report.all(check_id)
21
15
 
22
- expect(response['reports'].count).to eq(2)
16
+ def sort_reports(reports_list)
17
+ reports_list.sort_by { |report| report.name }
23
18
  end
24
- end
25
19
 
26
- describe '#resume' do
27
- it 'returns a success response' do
28
- report_id = '6951786-123123-422221'
20
+ it 'lists reports' do
21
+ expect(sorted_reports[0].name).to eq Onfido::ReportName::DOCUMENT
22
+ expect(sorted_reports[1].name).to eq Onfido::ReportName::IDENTITY_ENHANCED
23
+ end
29
24
 
30
- expect { report.resume(report_id) }.not_to raise_error
25
+ it 'finds a report' do
26
+ get_document_report = onfido_api.find_report(document_report_id)
27
+ get_identity_report = onfido_api.find_report(identity_report_id)
28
+
29
+ expect(get_document_report).to be_an_instance_of Onfido::DocumentReport
30
+ expect(get_document_report.id).to eq document_report_id
31
+ expect(get_document_report.name).to eq Onfido::ReportName::DOCUMENT
32
+ expect(get_document_report.status).to eq Onfido::ReportStatus::AWAITING_DATA
33
+
34
+ expect(get_identity_report).to be_an_instance_of Onfido::IdentityEnhancedReport
35
+ expect(get_identity_report.id).to eq identity_report_id
36
+ expect(get_identity_report.name).to eq Onfido::ReportName::IDENTITY_ENHANCED
37
+ expect(get_identity_report.status).to eq Onfido::ReportStatus::COMPLETE
38
+ expect(get_identity_report.breakdown.date_of_birth).to be_nil
39
+ expect(get_identity_report.breakdown.address).to be_nil
31
40
  end
32
- end
33
41
 
34
- describe '#cancel' do
35
- it 'returns a success response' do
36
- report_id = '6951786-123123-422221'
42
+ it 'resumes a report' do
43
+ onfido_api.resume_report(document_report_id)
44
+ end
37
45
 
38
- expect { report.cancel(report_id) }.not_to raise_error
46
+ it 'cancels a report' do
47
+ onfido_api.cancel_report(document_report_id)
39
48
  end
40
49
  end
41
50
  end
@@ -1,18 +1,20 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- describe Onfido::SdkToken do
4
- include_context 'fake onfido api'
5
-
6
- subject(:sdk_token) { onfido.sdk_token }
3
+ require_relative '../shared_contexts/with_applicant'
7
4
 
8
- describe '#create' do
9
- it 'creates a new SDK token for the applicant' do
10
- applicant_id = '61f659cb-c90b-4067-808a-6136b5c01351'
11
- referrer = 'http://*.mywebsite.com/*'
5
+ describe Onfido::SdkToken do
6
+ describe 'SDK token' do
7
+ include_context 'with applicant'
12
8
 
13
- response = sdk_token.create(applicant_id: applicant_id, referrer: referrer)
9
+ it 'generates a SDK token' do
10
+ token_builder = Onfido::SdkTokenBuilder.new({
11
+ applicant_id: applicant_id,
12
+ referrer: 'https://*.example.com/example_page/*',
13
+ })
14
+ token = onfido_api.generate_sdk_token(token_builder)
14
15
 
15
- expect(response['token']).not_to be_nil
16
+ expect(token).to be_an_instance_of Onfido::SdkToken
17
+ expect(token.token.size).to be > 0
16
18
  end
17
19
  end
18
20
  end
@@ -0,0 +1,45 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../shared_contexts/with_workflow_run'
4
+
5
+ describe Onfido::Task do
6
+ describe 'Tasks' do
7
+ include_context 'with workflow run'
8
+
9
+ it 'lists tasks' do
10
+ list_of_tasks = onfido_api.list_tasks(workflow_run_id)
11
+
12
+ expect(list_of_tasks).to_not be_nil
13
+ expect(list_of_tasks[0]).to be_an_instance_of Onfido::TaskItem
14
+ expect(list_of_tasks.size).to eq 2
15
+ end
16
+
17
+ it 'finds a task' do
18
+ task = onfido_api.list_tasks(workflow_run_id)[0]
19
+ get_task = onfido_api.find_task(workflow_run_id, task.id)
20
+
21
+ expect(get_task).to_not be_nil
22
+ expect(get_task).to be_an_instance_of Onfido::Task
23
+ expect(get_task.id).to eq task.id
24
+ expect(get_task.task_def_id).to eq task.task_def_id
25
+ end
26
+
27
+ it 'completes a task' do
28
+ tasks = onfido_api.list_tasks(workflow_run_id)
29
+ profile_data_task_id = (tasks.select { |task| task.id.include? 'profile' })[0].id
30
+
31
+ complete_task_builder = Onfido::CompleteTaskBuilder.new({
32
+ data: Onfido::CompleteTaskDataBuilder.build({
33
+ first_name: 'Jane',
34
+ last_name: 'Doe',
35
+ })
36
+ })
37
+
38
+ onfido_api.complete_task(workflow_run_id, profile_data_task_id, complete_task_builder)
39
+ task_outputs = onfido_api.find_task(workflow_run_id, profile_data_task_id).output
40
+
41
+ expect(task_outputs[:first_name]).to eq 'Jane'
42
+ expect(task_outputs[:last_name]).to eq 'Doe'
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,73 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../shared_contexts/with_applicant'
4
+
5
+ describe Onfido::WatchlistMonitor do
6
+ describe 'Watchlist monitor' do
7
+ include_context 'with applicant'
8
+
9
+ let(:watchlist_monitor_builder) do
10
+ Onfido::WatchlistMonitorBuilder.new({
11
+ applicant_id: applicant_id,
12
+ report_name: Onfido::ReportName::WATCHLIST_STANDARD
13
+ })
14
+ end
15
+ let(:watchlist_monitor) do
16
+ onfido_api.create_watchlist_monitor(watchlist_monitor_builder)
17
+ end
18
+ let!(:watchlist_monitor_id) { watchlist_monitor.id }
19
+
20
+
21
+ it 'creates a watchlist standard monitor' do
22
+ expect(watchlist_monitor).to be_an_instance_of Onfido::WatchlistMonitor
23
+ expect(watchlist_monitor.applicant_id).to eq applicant_id
24
+ expect(watchlist_monitor.report_name).to eq Onfido::ReportName::WATCHLIST_STANDARD
25
+ end
26
+
27
+ context 'AML monitor' do
28
+ let(:watchlist_monitor_builder) do
29
+ Onfido::WatchlistMonitorBuilder.new({
30
+ applicant_id: applicant_id,
31
+ report_name: Onfido::ReportName::WATCHLIST_AML
32
+ })
33
+ end
34
+
35
+ it 'creates a watchlist AML monitor' do
36
+ expect(watchlist_monitor).to be_an_instance_of Onfido::WatchlistMonitor
37
+ expect(watchlist_monitor.applicant_id).to eq applicant_id
38
+ expect(watchlist_monitor.report_name).to eq Onfido::ReportName::WATCHLIST_AML
39
+ end
40
+ end
41
+
42
+ it 'lists watchlist monitors' do
43
+ list_of_monitors = onfido_api.list_watchlist_monitors(applicant_id)
44
+
45
+ expect(list_of_monitors).to be_an_instance_of Onfido::WatchlistMonitorsList
46
+ expect(list_of_monitors.monitors.size).to be > 0
47
+ end
48
+
49
+ it 'finds a watchlist monitor' do
50
+ get_watchlist_monitor = onfido_api.find_watchlist_monitor(watchlist_monitor_id)
51
+
52
+ expect(get_watchlist_monitor.id).to eq watchlist_monitor_id
53
+ end
54
+
55
+ it 'deletes a watchlist monitor' do
56
+ onfido_api.delete_watchlist_monitor(watchlist_monitor_id)
57
+ end
58
+
59
+ it 'lists watchlist monitor matches' do
60
+ matches_list = onfido_api.list_watchlist_monitor_matches(watchlist_monitor_id)
61
+
62
+ expect(matches_list).to be_an_instance_of Onfido::WatchlistMonitorMatchesList
63
+ expect(matches_list.matches.size).to eq 0
64
+ end
65
+
66
+ it 'forces report creation' do
67
+ onfido_api.force_report_creation_from_watchlist_monitor(watchlist_monitor_id)
68
+
69
+ checks = onfido_api.list_checks(applicant_id).checks
70
+ expect(checks.size).to eq 2
71
+ end
72
+ end
73
+ end
@@ -1,110 +1,62 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- describe Onfido::Webhook do
4
- include_context 'fake onfido api'
5
-
6
- subject(:webhook) { onfido.webhook }
7
-
8
- describe '#create' do
9
- let(:params) do
10
- {
11
- url: 'https://webhookendpoint.url',
12
- enabled: true,
13
- events: [
14
- 'report.completed',
15
- 'check.completed'
16
- ]
17
- }
18
- end
19
-
20
- it 'creates the webhook' do
21
- response = webhook.create(**params)
22
-
23
- expect(response['id']).to_not be_nil
24
- end
25
-
26
- it 'responds with the right url' do
27
- response = webhook.create(**params)
28
-
29
- expect(response['url']).to eq params[:url]
30
- end
31
- end
32
-
33
- describe '#find' do
34
- it 'returns the webhook' do
35
- webhook_id = 'fcb73186-0733-4f6f-9c57-d9d5ef979443'
36
-
37
- response = webhook.find(webhook_id)
3
+ require_relative '../shared_contexts/with_onfido'
38
4
 
39
- expect(response['id']).to eq(webhook_id)
40
- end
41
- end
42
-
43
- describe '#destroy' do
44
- it 'removes the webhook' do
45
- webhook_id = 'fcb73186-0733-4f6f-9c57-d9d5ef979443'
46
- expect { webhook.destroy(webhook_id) }.not_to raise_error
47
- end
48
- end
49
-
50
- describe '#all' do
51
- it 'returns all the registered webhooks' do
52
- response = webhook.all
5
+ describe Onfido::Webhook do
6
+ describe 'Webhook' do
7
+ include_context 'with onfido'
53
8
 
54
- expect(response['webhooks'].count).to eq 2
9
+ let(:webhook_builder) do
10
+ Onfido::WebhookBuilder.new({
11
+ url: 'https://example.com',
12
+ events: ['check.completed', 'report.completed'],
13
+ })
55
14
  end
56
15
 
57
- it 'returns with id' do
58
- response = webhook.all
16
+ let(:webhook) { onfido_api.create_webhook(webhook_builder) }
17
+ let(:webhook_id) { webhook.id }
59
18
 
60
- expect(response['webhooks'][0]['id']).to_not be_nil
61
- expect(response['webhooks'][1]['id']).to_not be_nil
19
+ it 'creates a webhook' do
20
+ expect(webhook).to be_an_instance_of Onfido::Webhook
21
+ expect(webhook_id).to_not be_nil
22
+ expect(webhook.url).to eq 'https://example.com'
23
+ expect(webhook.events).to eq ['check.completed', 'report.completed']
62
24
  end
63
- end
64
25
 
65
- describe '.valid?' do
66
- subject(:valid?) do
67
- described_class.valid?(request_body, request_signature, token)
68
- end
26
+ it 'updates a webhook' do
27
+ webhook_updater = Onfido::WebhookUpdater.new({
28
+ url: 'https://example.co.uk',
29
+ events: ['check.completed'],
30
+ })
69
31
 
70
- let(:request_body) { '{"foo":"bar"}' }
71
- let(:request_signature) do
72
- '89e60408fec20bfb26bb0f993d5e88307818982f50f23b361a00d679bae8b1dc'
32
+ updated_webhook = onfido_api.update_webhook(webhook_id, webhook_updater)
33
+ expect(updated_webhook.id).to eq webhook_id
34
+ expect(updated_webhook.url).to eq 'https://example.co.uk'
35
+ expect(updated_webhook.events).to eq ['check.completed']
73
36
  end
74
- let(:token) { 'very_secret_token' }
75
37
 
76
- it { is_expected.to be(true) }
38
+ it 'lists webhooks' do
39
+ list_of_webhooks = onfido_api.list_webhooks()
77
40
 
78
- context 'with an invalid signature' do
79
- let(:request_signature) do
80
- 's21fd54ew2w1f5d15642132f3d7727ff9a32a7c87072ce514df1f6d3228bec'
81
- end
82
- it { is_expected.to be(false) }
41
+ expect(list_of_webhooks).to be_an_instance_of Onfido::WebhooksList
42
+ expect(list_of_webhooks.webhooks.size).to be > 0
83
43
  end
84
44
 
85
- context 'with a nil request signature' do
86
- let(:request_signature) { nil }
87
- specify { expect { valid? }.to raise_error(ArgumentError) }
88
- end
45
+ it 'finds a webhook' do
46
+ get_webhook = onfido_api.find_webhook(webhook_id)
89
47
 
90
- context 'with a token other than the one used to sign the request' do
91
- let(:token) { 'quite_secret_token' }
92
- it { is_expected.to be(false) }
48
+ expect(get_webhook).to be_an_instance_of(Onfido::Webhook)
49
+ expect(get_webhook.id).to eq webhook_id
93
50
  end
94
51
 
95
- context 'with a nil token' do
96
- let(:token) { nil }
97
- specify { expect { valid? }.to raise_error(ArgumentError) }
98
- end
52
+ it 'deletes a webhook' do
53
+ onfido_api.delete_webhook(webhook_id)
99
54
 
100
- context 'with a modified request body' do
101
- let(:request_body) { '{"bar":"baz"}' }
102
- it { is_expected.to be(false) }
103
- end
104
-
105
- context 'with a nil request body' do
106
- let(:request_body) { nil }
107
- specify { expect { valid? }.to raise_error(ArgumentError) }
55
+ expect {
56
+ onfido_api.find_webhook(webhook_id)
57
+ }.to raise_error(Onfido::ApiError) { |e|
58
+ expect(e.code).to eq(404)
59
+ }
108
60
  end
109
61
  end
110
62
  end
@@ -0,0 +1,117 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../shared_contexts/with_document'
4
+ require_relative '../shared_contexts/with_live_photo'
5
+ require_relative '../shared_contexts/with_workflow_run'
6
+
7
+ describe Onfido::WorkflowRun do
8
+ describe 'Workflow run outputs' do
9
+ include_context 'with workflow run'
10
+
11
+ context 'workflow with profile data as output' do
12
+ let(:workflow_id) { 'd27e510b-27a8-44c3-a3cc-bf4c0648a4ba' }
13
+
14
+ let(:profile_data) do
15
+ {
16
+ country_residence: 'GBR',
17
+ first_name: 'First',
18
+ last_name: 'Last',
19
+ dob: '2000-01-01',
20
+ email: 'first.last@gmail.com',
21
+ phone_number: '+351911111111',
22
+ nationality: 'GBR',
23
+ phone_number_consent_granted: true,
24
+ address: {
25
+ country: 'GBR',
26
+ line1: '123rd Street',
27
+ line2: '2nd Floor',
28
+ line3: '23',
29
+ town: 'London',
30
+ postcode: 'S2 2DF',
31
+ }
32
+ }
33
+ end
34
+
35
+ it 'returns profile data as output' do
36
+ tasks = onfido_api.list_tasks(workflow_run_id)
37
+ profile_data_task_id = (tasks.select { |task| task.id.include? 'profile' })[0].id
38
+
39
+ complete_task_builder = Onfido::CompleteTaskBuilder.new({
40
+ data: Onfido::CompleteTaskDataBuilder.build(profile_data)
41
+ })
42
+ onfido_api.complete_task(workflow_run_id, profile_data_task_id, complete_task_builder)
43
+
44
+ workflow_run_outputs = onfido_api.find_workflow_run(workflow_run_id).output
45
+
46
+ expect(workflow_run_outputs[:profile_capture_data]).to eq profile_data
47
+ end
48
+ end
49
+
50
+ context 'workflow run with document and facial similarity reports as output' do
51
+ include_context 'with document'
52
+ include_context 'with live photo'
53
+
54
+ let(:workflow_id) { '5025d9fd-7842-4805-bce1-a7bfd7131b4e' }
55
+ let(:profile_data) { { first_name: 'Jane', last_name: 'Doe' } }
56
+
57
+ it 'returns document and facial similarity reports' do
58
+ tasks = onfido_api.list_tasks(workflow_run_id)
59
+ profile_data_task_id = (tasks.select { |task| task.id.include? 'profile' })[0].id
60
+
61
+ complete_profile_task_builder = Onfido::CompleteTaskBuilder.new({
62
+ data: Onfido::CompleteTaskDataBuilder.build(profile_data)
63
+ })
64
+ onfido_api.complete_task(
65
+ workflow_run_id,
66
+ profile_data_task_id,
67
+ complete_profile_task_builder,
68
+ )
69
+
70
+ tasks = onfido_api.list_tasks(workflow_run_id)
71
+ document_capture_task_id = (tasks.select { |task| task.id.include? 'document_photo' })[0].id
72
+
73
+ complete_document_capture_task_builder = Onfido::CompleteTaskBuilder.new(
74
+ data: Onfido::CompleteTaskDataBuilder.build([{ id: document_id }])
75
+ )
76
+ onfido_api.complete_task(
77
+ workflow_run_id,
78
+ document_capture_task_id,
79
+ complete_document_capture_task_builder,
80
+ )
81
+
82
+ tasks = onfido_api.list_tasks(workflow_run_id)
83
+ live_photo_capture_task_id = (tasks.select { |task| task.id.include? 'face_photo' })[0].id
84
+
85
+ complete_live_photo_capture_task_request = Onfido::CompleteTaskBuilder.new(
86
+ data: Onfido::CompleteTaskDataBuilder.build([{ id: live_photo_id }])
87
+ )
88
+ onfido_api.complete_task(
89
+ workflow_run_id,
90
+ live_photo_capture_task_id,
91
+ complete_live_photo_capture_task_request,
92
+ )
93
+
94
+ workflow_run = repeat_request_until_status_changes('approved') do
95
+ onfido_api.find_workflow_run(workflow_run_id)
96
+ end
97
+
98
+ document_report_output = workflow_run.output[:doc]
99
+ facial_similarity_report_output = workflow_run.output[:selfie]
100
+
101
+ expect(document_report_output[:breakdown]).to_not be_nil
102
+ expect(document_report_output[:properties]).to_not be_nil
103
+ expect(document_report_output[:repeat_attempts]).to_not be_nil
104
+ expect(document_report_output[:result]).to_not be_nil
105
+ expect(document_report_output[:status]).to_not be_nil
106
+ expect(document_report_output[:sub_result]).to_not be_nil
107
+ expect(document_report_output[:uuid]).to_not be_nil
108
+
109
+ expect(facial_similarity_report_output[:breakdown]).to_not be_nil
110
+ expect(facial_similarity_report_output[:properties]).to_not be_nil
111
+ expect(facial_similarity_report_output[:result]).to_not be_nil
112
+ expect(facial_similarity_report_output[:status]).to_not be_nil
113
+ expect(facial_similarity_report_output[:uuid]).to_not be_nil
114
+ end
115
+ end
116
+ end
117
+ end
@@ -1,54 +1,84 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- describe Onfido::WorkflowRun do
4
- include_context 'fake onfido api'
3
+ require_relative '../shared_contexts/with_workflow_run'
5
4
 
6
- subject(:workflow_run) { onfido.workflow_run }
5
+ describe Onfido::WorkflowRun do
6
+ describe 'Workflow run' do
7
+ include_context 'with workflow run'
7
8
 
8
- let(:workflow_run_id) { 'fcb73186-0733-4f6f-9c57-d9d5ef979443' }
9
- let(:params) do
10
- {
11
- 'a' => 'b'
12
- }
13
- end
9
+ it 'creates a workflow run' do
10
+ expect(workflow_run).to be_an_instance_of Onfido::WorkflowRun
11
+ expect(workflow_run.applicant_id).to eq applicant_id
12
+ expect(workflow_run.status).to eq 'awaiting_input'
13
+ end
14
14
 
15
- describe '#create' do
16
- it 'serializes the payload correctly' do
17
- WebMock.after_request do |request_signature, _response|
18
- if request_signature.uri.path == 'v3.6/workflow_run'
19
- expect(Rack::Utils.parse_nested_query(request_signature.body))
20
- .to eq(params)
21
- end
15
+ context 'workflow run with custom inputs' do
16
+ let(:workflow_id) { '45092b29-f220-479e-aa6f-a6f989baac4c' }
17
+ let(:workflow_run_builder) do
18
+ Onfido::WorkflowRunBuilder.new({
19
+ applicant_id: applicant_id,
20
+ workflow_id: workflow_id,
21
+ custom_data: {
22
+ age: 18,
23
+ is_employed: false
24
+ }
25
+ })
26
+ end
27
+
28
+ it 'creates a workflow run with custom inputs' do
29
+ expect(workflow_run).to be_an_instance_of Onfido::WorkflowRun
30
+ expect(workflow_run.workflow_id).to eq workflow_id
31
+ expect(workflow_run.status).to eq 'approved'
22
32
  end
23
33
  end
24
34
 
25
- it 'creates a workflow run' do
26
- response = workflow_run.create(params)
27
- expect(response['id']).not_to be_nil
35
+ it 'lists workflow runs' do
36
+ list_of_workflow_runs = onfido_api.list_workflow_runs()
37
+
38
+ expect(list_of_workflow_runs[0]).to be_an_instance_of Onfido::WorkflowRun
39
+ expect(list_of_workflow_runs.size).to be > 0
28
40
  end
29
- end
30
41
 
31
- describe '#find' do
32
- it 'returns the workflow run' do
33
- response = workflow_run.find(workflow_run_id)
42
+ it 'finds a workflow run' do
43
+ get_workflow_run = onfido_api.find_workflow_run(workflow_run_id)
34
44
 
35
- expect(response['id']).to eq(workflow_run_id)
45
+ expect(get_workflow_run).to be_an_instance_of Onfido::WorkflowRun
46
+ expect(get_workflow_run.id).to eq workflow_run_id
36
47
  end
37
- end
38
48
 
39
- describe '#all' do
40
- it 'returns the workflow runs' do
41
- response = workflow_run.all({ page: 1, sort: 'asc' })
49
+ it 'downloads evidence file' do
50
+ file = onfido_api.download_signed_evidence_file(workflow_run_id)
42
51
 
43
- expect(response.count).to eq(2)
52
+ expect(file.size).to be > 0
44
53
  end
45
- end
46
54
 
47
- describe '#evidence' do
48
- it 'returns the signed PDF' do
49
- response = workflow_run.evidence(workflow_run_id)
55
+ context 'with start -> approved workflow' do
56
+ let(:workflow_id) { '221f9d24-cf72-4762-ac4a-01bf3ccc09dd' }
57
+
58
+ it 'generates a timeline file' do
59
+ repeat_request_until_status_changes('approved') do
60
+ onfido_api.find_workflow_run(workflow_run_id)
61
+ end
62
+
63
+ workflow_timeline_file_data = onfido_api.create_timeline_file(workflow_run_id)
64
+
65
+ expect(workflow_timeline_file_data).to be_an_instance_of Onfido::TimelineFileReference
66
+ expect(workflow_timeline_file_data.workflow_timeline_file_id).to_not be_nil
67
+ expect(workflow_timeline_file_data.href).to_not be_nil
68
+ end
50
69
 
51
- expect(response[0..4]).to eq('%PDF-')
70
+ it 'finds a timeline file' do
71
+ repeat_request_until_status_changes('approved') do
72
+ onfido_api.find_workflow_run(workflow_run_id)
73
+ end
74
+
75
+ timeline_file_id = onfido_api.create_timeline_file(workflow_run_id).workflow_timeline_file_id
76
+ file = repeat_request_unti_http_code_changes do
77
+ onfido_api.find_timeline_file(workflow_run_id, timeline_file_id)
78
+ end
79
+
80
+ expect(file.size).to be > 0
81
+ end
52
82
  end
53
83
  end
54
84
  end
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../shared_contexts/with_onfido'
4
+
5
+ RSpec.shared_context 'with applicant', shared_context: :metadata do
6
+ include_context 'with onfido'
7
+
8
+ let(:applicant_id) do
9
+ applicant = onfido_api.create_applicant(default_applicant_body)
10
+
11
+ applicant.id
12
+ end
13
+
14
+ let(:default_applicant_body) do
15
+ {
16
+ 'first_name' => 'Test',
17
+ 'last_name' => 'Applicant',
18
+ 'location' => {
19
+ 'ip_address' => '127.0.0.1',
20
+ 'country_of_residence' => 'GBR'
21
+ }
22
+ }
23
+ end
24
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../shared_contexts/with_document'
4
+
5
+ RSpec.shared_context 'with check', shared_context: :metadata do
6
+ include_context 'with document'
7
+
8
+ let(:check_builder) do
9
+ Onfido::CheckBuilder.new({
10
+ applicant_id: applicant_id,
11
+ document_ids: [document_id],
12
+ report_names: [Onfido::ReportName::DOCUMENT, Onfido::ReportName::IDENTITY_ENHANCED],
13
+ })
14
+ end
15
+
16
+ let(:check) { onfido_api.create_check(check_builder) }
17
+ let!(:check_id) { check.id }
18
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../shared_contexts/with_applicant'
4
+
5
+ RSpec.shared_context 'with document', shared_context: :metadata do
6
+ include_context 'with applicant'
7
+
8
+ let(:document_file_name) { 'sample_driving_licence.png' }
9
+ let(:document_file) { File.open("spec/integrations/media/#{document_file_name}") }
10
+
11
+ let(:document) { onfido_api.upload_document('passport', applicant_id, document_file) }
12
+ let!(:document_id) { document.id }
13
+ end