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,25 +0,0 @@
1
- name: Ruby
2
-
3
- on:
4
- push:
5
- branches: [ master ]
6
- pull_request:
7
- branches: [ master ]
8
-
9
- jobs:
10
- test:
11
-
12
- runs-on: ubuntu-latest
13
- strategy:
14
- matrix:
15
- ruby-version: ['2.4', '2.5', '2.6', '2.7', '3.0', '3.1']
16
-
17
- steps:
18
- - uses: actions/checkout@v2
19
- - name: Set up Ruby
20
- uses: ruby/setup-ruby@v1
21
- with:
22
- ruby-version: ${{ matrix.ruby-version }}
23
- bundler-cache: true
24
- - name: Run tests
25
- run: bundle exec rspec spec
data/.gitignore DELETED
@@ -1,19 +0,0 @@
1
- *.gem
2
- *.rbc
3
- .bundle
4
- .config
5
- .DS_Store
6
- .rspec
7
- .yardoc
8
- Gemfile.lock
9
- InstalledFiles
10
- _yardoc
11
- coverage
12
- doc/
13
- lib/bundler/man
14
- pkg
15
- rdoc
16
- spec/reports
17
- test/tmp
18
- test/version_tmp
19
- tmp
data/.rspec DELETED
@@ -1,2 +0,0 @@
1
- --color
2
- --require spec_helper
data/.rubocop.yml DELETED
@@ -1,13 +0,0 @@
1
- AllCops:
2
- NewCops: enable
3
- TargetRubyVersion: 2.4.0
4
-
5
- Layout/LineLength:
6
- Max: 100
7
-
8
- Metrics/BlockLength:
9
- Exclude:
10
- - spec/**/*
11
-
12
- Style/Documentation:
13
- Enabled: false
data/lib/onfido/api.rb DELETED
@@ -1,65 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Onfido
4
- class API
5
- def initialize(api_key:, region:, **extra_options)
6
- @options = Onfido::Options.new(api_key: api_key, region: region, **extra_options)
7
- end
8
-
9
- def applicant
10
- @applicant ||= Onfido::Applicant.new(options)
11
- end
12
-
13
- def check
14
- @check ||= Onfido::Check.new(options)
15
- end
16
-
17
- def document
18
- @document ||= Onfido::Document.new(options)
19
- end
20
-
21
- def live_photo
22
- @live_photo ||= Onfido::LivePhoto.new(options)
23
- end
24
-
25
- def live_video
26
- @live_video ||= Onfido::LiveVideo.new(options)
27
- end
28
-
29
- def monitor
30
- @monitor ||= Onfido::Monitor.new(options)
31
- end
32
-
33
- def motion_capture
34
- @motion_capture ||= Onfido::MotionCapture.new(options)
35
- end
36
-
37
- def report
38
- @report ||= Onfido::Report.new(options)
39
- end
40
-
41
- def sdk_token
42
- @sdk_token ||= Onfido::SdkToken.new(options)
43
- end
44
-
45
- def webhook
46
- @webhook ||= Onfido::Webhook.new(options)
47
- end
48
-
49
- def address
50
- @address ||= Onfido::Address.new(options)
51
- end
52
-
53
- def extraction
54
- @extraction ||= Onfido::Extraction.new(options)
55
- end
56
-
57
- def workflow_run
58
- @workflow_run ||= Onfido::WorkflowRun.new(options)
59
- end
60
-
61
- private
62
-
63
- attr_reader :options
64
- end
65
- end
@@ -1,6 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Onfido
4
- class ConnectionError < OnfidoError
5
- end
6
- end
@@ -1,30 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Onfido
4
- class OnfidoError < StandardError
5
- attr_accessor :response_code, :response_body
6
-
7
- def initialize(message = nil,
8
- response_code: nil,
9
- response_body: nil)
10
- @response_code = response_code
11
- @response_body = response_body
12
-
13
- super(message)
14
- end
15
-
16
- def json_body
17
- JSON.parse(response_body.to_s)
18
- rescue JSON::ParserError
19
- nil
20
- end
21
-
22
- def type
23
- json_body && json_body['error'] && json_body['error']['type']
24
- end
25
-
26
- def fields
27
- json_body && json_body['error'] && json_body['error']['fields']
28
- end
29
- end
30
- end
@@ -1,6 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Onfido
4
- class RequestError < OnfidoError
5
- end
6
- end
@@ -1,6 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Onfido
4
- class ServerError < OnfidoError
5
- end
6
- end
@@ -1,38 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Onfido
4
- class Options
5
- REGIONS = %w[eu us ca].freeze
6
-
7
- def initialize(api_key:, region:, open_timeout: 10, read_timeout: 30, unknown_api_url: nil)
8
- @api_key = api_key
9
- @region = region.to_s.downcase
10
- @open_timeout = open_timeout
11
- @read_timeout = read_timeout
12
- @unknown_api_url = unknown_api_url
13
-
14
- raise "Unknown region #{@region}" unless REGIONS.include?(@region)
15
- end
16
-
17
- def rest_client
18
- @rest_client ||= RestClient::Resource.new(
19
- base_url,
20
- read_timeout: read_timeout,
21
- open_timeout: open_timeout,
22
- headers: {
23
- 'Authorization' => "Token token=#{api_key}",
24
- 'Accept' => 'application/json',
25
- 'User-Agent' => "onfido-ruby/#{Onfido::VERSION}"
26
- }
27
- )
28
- end
29
-
30
- private
31
-
32
- attr_reader :api_key, :open_timeout, :read_timeout
33
-
34
- def base_url
35
- @unknown_api_url || "https://api.#{@region}.onfido.com/v3.6/"
36
- end
37
- end
38
- end
@@ -1,153 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Onfido
4
- class Resource # rubocop:todo Metrics/ClassLength
5
- VALID_HTTP_METHODS = %i[get post put delete].freeze
6
- REQUEST_TIMEOUT_HTTP_CODE = 408
7
- ADDITIONAL_HEADERS = { 'Content-Type' => 'application/json; charset=utf-8' }.freeze
8
-
9
- def initialize(options)
10
- @rest_client = options.rest_client
11
- end
12
-
13
- private
14
-
15
- attr_reader :rest_client
16
-
17
- def get(path:)
18
- handle_request { rest_client[path].get(ADDITIONAL_HEADERS) }
19
- end
20
-
21
- def post(path:, payload: nil, send_json: true)
22
- parsed_payload = send_json ? payload.to_json : payload
23
- additional_headers = send_json ? ADDITIONAL_HEADERS : {}
24
-
25
- handle_request { rest_client[path].post(parsed_payload, additional_headers) }
26
- end
27
-
28
- def put(path:, payload: nil)
29
- handle_request { rest_client[path].put(payload.to_json, ADDITIONAL_HEADERS) }
30
- end
31
-
32
- def patch(path:, payload: nil)
33
- handle_request { rest_client[path].patch(payload.to_json, ADDITIONAL_HEADERS) }
34
- end
35
-
36
- def delete(path:)
37
- handle_request { rest_client[path].delete(ADDITIONAL_HEADERS) }
38
- end
39
-
40
- def handle_request
41
- response = yield
42
-
43
- # response should be parsed only when there is a response expected
44
- parse(response) unless response.code == 204 # no_content
45
- rescue RestClient::ExceptionWithResponse => e
46
- if e.response && !timeout_response?(e.response)
47
- handle_api_error(e.response)
48
- else
49
- handle_restclient_error(e)
50
- end
51
- rescue RestClient::Exception, Errno::ECONNREFUSED => e
52
- handle_restclient_error(e)
53
- end
54
-
55
- def parse(response)
56
- content_type = response.headers[:content_type]
57
- if content_type&.include?('application/json')
58
- JSON.parse(response.body.to_s)
59
- else
60
- response.body
61
- end
62
- rescue JSON::ParserError
63
- general_api_error(response.code, response.body)
64
- end
65
-
66
- def timeout_response?(response)
67
- response.code.to_i == REQUEST_TIMEOUT_HTTP_CODE
68
- end
69
-
70
- # There seems to be a serialization issue with the HTTP client
71
- # which does not serialize the payload properly.
72
- # Have a look here https://gist.github.com/PericlesTheo/cb35139c57107ab3c84a
73
-
74
- def build_query(payload)
75
- if payload[:file]
76
- payload
77
- else
78
- Rack::Utils.build_nested_query(payload)
79
- end
80
- end
81
-
82
- def handle_api_error(response)
83
- parsed_response = parse(response)
84
-
85
- general_api_error(response.code, response.body) unless parsed_response['error']
86
-
87
- error_class = response.code.to_i >= 500 ? ServerError : RequestError
88
-
89
- raise error_class.new(
90
- parsed_response['error']['message'],
91
- response_code: response.code,
92
- response_body: response.body
93
- )
94
- end
95
-
96
- def general_api_error(response_code, response_body)
97
- error_class = response_code.to_i >= 500 ? ServerError : RequestError
98
-
99
- raise error_class.new(
100
- "Invalid response object from API: #{response_body} " \
101
- "(HTTP response code was #{response_code})",
102
- response_code: response_code,
103
- response_body: response_body
104
- )
105
- end
106
-
107
- def handle_restclient_error(error) # rubocop:todo Metrics/MethodLength
108
- connection_message =
109
- 'Please check your internet connection and try again. ' \
110
- 'If this problem persists, you should let us know at info@onfido.com.'
111
-
112
- message =
113
- case error
114
- when RestClient::RequestTimeout
115
- "Could not connect to Onfido . #{connection_message}"
116
-
117
- when RestClient::ServerBrokeConnection
118
- "The connection to the server broke before the request completed. #{connection_message}"
119
-
120
- when RestClient::SSLCertificateNotVerified
121
- "Could not verify Onfido's SSL certificate. Please make sure " \
122
- 'that your network is not intercepting certificates. '
123
-
124
- when RestClient::BadGateway
125
- "Could not connect to Onfido. Server may be overloaded." \
126
-
127
- when SocketError
128
- 'Unexpected error when trying to connect to Onfido. ' \
129
- 'You may be seeing this message because your DNS is not working. ' \
130
- "To check, try running 'host onfido.com' from the command line."
131
-
132
- else
133
- 'Unexpected error communicating with Onfido. ' \
134
- 'If this problem persists, let us know at info@onfido.com.'
135
- end
136
-
137
- full_message = message + "\n\n(Network error: #{error.message})"
138
-
139
- raise ConnectionError, full_message
140
- end
141
-
142
- def validate_file!(file)
143
- return if file.respond_to?(:read) && file.respond_to?(:path)
144
-
145
- raise ArgumentError, 'File must be a `File`-like object which responds to ' \
146
- '`#read` and `#path`'
147
- end
148
-
149
- def stringify_query_params(hashed_params)
150
- URI.encode_www_form_component(hashed_params.map{ |k,v| "#{k}=#{v}" }.join("&"))
151
- end
152
- end
153
- end
@@ -1,9 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Onfido
4
- class Address < Resource
5
- def all(postcode)
6
- get(path: "addresses/pick?postcode=#{postcode.delete(' ')}")
7
- end
8
- end
9
- end
@@ -1,29 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Onfido
4
- class Applicant < Resource
5
- def create(payload)
6
- post(path: 'applicants', payload: payload)
7
- end
8
-
9
- def update(applicant_id, payload)
10
- put(path: "applicants/#{applicant_id}", payload: payload)
11
- end
12
-
13
- def destroy(applicant_id)
14
- delete(path: "applicants/#{applicant_id}")
15
- end
16
-
17
- def find(applicant_id)
18
- get(path: "applicants/#{applicant_id}")
19
- end
20
-
21
- def all(page: 1, per_page: 20)
22
- get(path: "applicants?page=#{page}&per_page=#{per_page}")
23
- end
24
-
25
- def restore(applicant_id)
26
- post(path: "applicants/#{applicant_id}/restore")
27
- end
28
- end
29
- end
@@ -1,28 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Onfido
4
- class Check < Resource
5
- def create(applicant_id:, report_names:, **payload)
6
- payload[:applicant_id] = applicant_id
7
- payload[:report_names] = report_names
8
-
9
- post(path: 'checks', payload: payload)
10
- end
11
-
12
- def find(check_id)
13
- get(path: "checks/#{check_id}")
14
- end
15
-
16
- def all(applicant_id)
17
- get(path: "checks?applicant_id=#{applicant_id}")
18
- end
19
-
20
- def resume(check_id)
21
- post(path: "checks/#{check_id}/resume")
22
- end
23
-
24
- def download(check_id)
25
- get(path: "checks/#{check_id}/download")
26
- end
27
- end
28
- end
@@ -1,28 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Onfido
4
- class Document < Resource
5
- # with open-uri the file can be a link or an actual file
6
-
7
- def create(applicant_id:, file:, type:, **payload)
8
- validate_file!(file)
9
- payload[:applicant_id] = applicant_id
10
- payload[:file] = file
11
- payload[:type] = type
12
-
13
- post(path: 'documents', payload: payload, send_json: false)
14
- end
15
-
16
- def find(document_id)
17
- get(path: "documents/#{document_id}")
18
- end
19
-
20
- def download(document_id)
21
- get(path: "documents/#{document_id}/download")
22
- end
23
-
24
- def all(applicant_id)
25
- get(path: "documents?applicant_id=#{applicant_id}")
26
- end
27
- end
28
- end
@@ -1,11 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Onfido
4
- class Extraction < Resource
5
- def create(document_id:)
6
- payload = { document_id: document_id }
7
-
8
- post(path: 'extractions', payload: payload)
9
- end
10
- end
11
- end
@@ -1,27 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Onfido
4
- class LivePhoto < Resource
5
- # with open-uri the file can be a link or an actual file
6
-
7
- def create(applicant_id:, file:, **payload)
8
- validate_file!(file)
9
- payload[:applicant_id] = applicant_id
10
- payload[:file] = file
11
-
12
- post(path: 'live_photos', payload: payload, send_json: false)
13
- end
14
-
15
- def find(live_photo_id)
16
- get(path: "live_photos/#{live_photo_id}")
17
- end
18
-
19
- def download(live_photo_id)
20
- get(path: "live_photos/#{live_photo_id}/download")
21
- end
22
-
23
- def all(applicant_id)
24
- get(path: "live_photos?applicant_id=#{applicant_id}")
25
- end
26
- end
27
- end
@@ -1,17 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Onfido
4
- class LiveVideo < Resource
5
- def find(live_video_id)
6
- get(path: "live_videos/#{live_video_id}")
7
- end
8
-
9
- def download(live_video_id)
10
- get(path: "live_videos/#{live_video_id}/download")
11
- end
12
-
13
- def all(applicant_id)
14
- get(path: "live_videos?applicant_id=#{applicant_id}")
15
- end
16
- end
17
- end
@@ -1,32 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Onfido
4
- class Monitor < Resource
5
- def create(applicant_id:, report_name:, **payload)
6
- payload[:applicant_id] = applicant_id
7
- payload[:report_name] = report_name
8
-
9
- post(path: 'watchlist_monitors', payload: payload)
10
- end
11
-
12
- def find(monitor_id)
13
- get(path: "watchlist_monitors/#{monitor_id}")
14
- end
15
-
16
- def all(applicant_id)
17
- get(path: "watchlist_monitors?applicant_id=#{applicant_id}")
18
- end
19
-
20
- def destroy(monitor_id)
21
- delete(path: "watchlist_monitors/#{monitor_id}")
22
- end
23
-
24
- def list_matches(monitor_id)
25
- get(path: "watchlist_monitors/#{monitor_id}/matches")
26
- end
27
-
28
- def set_match_status(monitor_id, **payload)
29
- patch(path: "watchlist_monitors/#{monitor_id}/matches", payload: payload)
30
- end
31
- end
32
- end
@@ -1,21 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Onfido
4
- class MotionCapture < Resource
5
- def find(motion_capture_id)
6
- get(path: "motion_captures/#{motion_capture_id}")
7
- end
8
-
9
- def download(motion_capture_id)
10
- get(path: "motion_captures/#{motion_capture_id}/download")
11
- end
12
-
13
- def frame(motion_capture_id)
14
- get(path: "motion_captures/#{motion_capture_id}/frame")
15
- end
16
-
17
- def all(applicant_id)
18
- get(path: "motion_captures?applicant_id=#{applicant_id}")
19
- end
20
- end
21
- end
@@ -1,21 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Onfido
4
- class Report < Resource
5
- def find(report_id)
6
- get(path: "reports/#{report_id}")
7
- end
8
-
9
- def all(check_id)
10
- get(path: "reports?check_id=#{check_id}")
11
- end
12
-
13
- def resume(report_id)
14
- post(path: "reports/#{report_id}/resume")
15
- end
16
-
17
- def cancel(report_id)
18
- post(path: "reports/#{report_id}/cancel")
19
- end
20
- end
21
- end
@@ -1,10 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Onfido
4
- class SdkToken < Resource
5
- def create(applicant_id:, **payload)
6
- payload[:applicant_id] = applicant_id
7
- post(path: 'sdk_token', payload: payload)
8
- end
9
- end
10
- end
@@ -1,40 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Onfido
4
- class Webhook < Resource
5
- def create(url:, **payload)
6
- payload[:url] = url
7
- post(path: 'webhooks', payload: payload)
8
- end
9
-
10
- def find(webhooks_id)
11
- get(path: "webhooks/#{webhooks_id}")
12
- end
13
-
14
- def all
15
- get(path: 'webhooks')
16
- end
17
-
18
- def destroy(webhook_id)
19
- delete(path: "webhooks/#{webhook_id}")
20
- end
21
-
22
- # As well as being a normal resource, Onfido::Webhook also supports
23
- # verifying the authenticity of a webhook by comparing the signature on the
24
- # request to one computed from the body
25
- def self.valid?(request_body, request_signature, token)
26
- if [request_body, request_signature, token].any?(&:nil?)
27
- raise ArgumentError, 'A request body, request signature and token ' \
28
- 'must be provided'
29
- end
30
-
31
- computed_signature = generate_signature(request_body, token)
32
- Rack::Utils.secure_compare(request_signature, computed_signature)
33
- end
34
-
35
- def self.generate_signature(request_body, token)
36
- OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new('sha256'), token, request_body)
37
- end
38
- private_class_method :generate_signature
39
- end
40
- end
@@ -1,21 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Onfido
4
- class WorkflowRun < Resource
5
- def create(payload)
6
- post(path: 'workflow_runs', payload: payload)
7
- end
8
-
9
- def find(workflow_run_id)
10
- get(path: "workflow_runs/#{workflow_run_id}")
11
- end
12
-
13
- def all(query_params = {})
14
- get(path: "workflow_runs?#{stringify_query_params(query_params)}")
15
- end
16
-
17
- def evidence(workflow_run_id)
18
- get(path: "workflow_runs/#{workflow_run_id}/signed_evidence_file")
19
- end
20
- end
21
- end