From c495e975fe6d663bbfb2730eb2834b763bd908e8 Mon Sep 17 00:00:00 2001 From: dvacca-onfido <134616519+dvacca-onfido@users.noreply.github.com> Date: Fri, 20 Dec 2024 07:58:50 +0000 Subject: [PATCH 1/2] Upgrade after onfido-openapi-spec change 964fb43 --- .release.json | 8 ++++---- README.md | 2 +- lib/onfido/api_client.rb | 2 +- lib/onfido/models/task.rb | 2 +- lib/onfido/models/webhook_event_payload_resource.rb | 2 +- lib/onfido/models/webhook_event_resource_type.rb | 4 +++- lib/onfido/models/webhook_event_type.rb | 3 ++- lib/onfido/version.rb | 2 +- 8 files changed, 14 insertions(+), 11 deletions(-) diff --git a/.release.json b/.release.json index ed95788..ce6e50e 100644 --- a/.release.json +++ b/.release.json @@ -1,9 +1,9 @@ { "source": { "repo_url": "https://github.com/onfido/onfido-openapi-spec", - "short_sha": "8c793a1", - "long_sha": "8c793a1c8307dcd92fa657edb2a1e9b184c15278", - "version": "v4.3.0" + "short_sha": "964fb43", + "long_sha": "964fb43a1bf211197ef7a45c230771b8ba561b3c", + "version": "v4.4.0" }, - "release": "v4.3.0" + "release": "v4.4.0" } diff --git a/README.md b/README.md index 75bb63c..34f15c3 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ This version uses Onfido API v3.6. Refer to our [API versioning guide](https://d ### Installation ```ruby -gem onfido, '~> 4.3.0' +gem onfido, '~> 4.4.0' ``` Configure with your API token, region and optional timeout (default value is 30): diff --git a/lib/onfido/api_client.rb b/lib/onfido/api_client.rb index 13b62fe..b2983d1 100644 --- a/lib/onfido/api_client.rb +++ b/lib/onfido/api_client.rb @@ -34,7 +34,7 @@ class ApiClient # @option config [Configuration] Configuration for initializing the object, default to Configuration.default def initialize(config = Configuration.default) @config = config - @user_agent = "onfido-ruby/4.3.0" + @user_agent = "onfido-ruby/4.4.0" @default_headers = { 'Content-Type' => 'application/json', 'User-Agent' => @user_agent diff --git a/lib/onfido/models/task.rb b/lib/onfido/models/task.rb index 4d65760..b438e54 100644 --- a/lib/onfido/models/task.rb +++ b/lib/onfido/models/task.rb @@ -30,7 +30,7 @@ class Task # Input object with the fields used by the Task to execute. attr_accessor :input - # Output object with the fields produced by the Task execution. + # Value field (it can be an Object, List, etc.) with the fields produced by the Task execution. attr_accessor :output # The date and time when the Task was created. diff --git a/lib/onfido/models/webhook_event_payload_resource.rb b/lib/onfido/models/webhook_event_payload_resource.rb index ca2fb46..274b775 100644 --- a/lib/onfido/models/webhook_event_payload_resource.rb +++ b/lib/onfido/models/webhook_event_payload_resource.rb @@ -48,7 +48,7 @@ class WebhookEventPayloadResource # Input object with the fields used by the Task execution. attr_accessor :input - # Output object with the fields produced by the Task execution. + # Value field (it can be an Object, List, etc.) with the fields produced by the Task execution. attr_accessor :output # The reasons the Workflow Run outcome was reached. Configurable when creating the Workflow Version. diff --git a/lib/onfido/models/webhook_event_resource_type.rb b/lib/onfido/models/webhook_event_resource_type.rb index 03657d7..e497d94 100644 --- a/lib/onfido/models/webhook_event_resource_type.rb +++ b/lib/onfido/models/webhook_event_resource_type.rb @@ -21,10 +21,12 @@ class WebhookEventResourceType WORKFLOW_RUN = "workflow_run".freeze WORKFLOW_TASK = "workflow_task".freeze WATCHLIST_MONITOR = "watchlist_monitor".freeze + WORKFLOW_TIMELINE_FILE = "workflow_timeline_file".freeze + WORKFLOW_RUN_EVIDENCE_FOLDER = "workflow_run_evidence_folder".freeze UNKNOWN_DEFAULT_OPEN_API = "unknown_default_open_api".freeze def self.all_vars - @all_vars ||= [CHECK, REPORT, AUDIT_LOG, WORKFLOW_RUN, WORKFLOW_TASK, WATCHLIST_MONITOR, UNKNOWN_DEFAULT_OPEN_API].freeze + @all_vars ||= [CHECK, REPORT, AUDIT_LOG, WORKFLOW_RUN, WORKFLOW_TASK, WATCHLIST_MONITOR, WORKFLOW_TIMELINE_FILE, WORKFLOW_RUN_EVIDENCE_FOLDER, UNKNOWN_DEFAULT_OPEN_API].freeze end # Builds the enum from string diff --git a/lib/onfido/models/webhook_event_type.rb b/lib/onfido/models/webhook_event_type.rb index a673789..cae29bb 100644 --- a/lib/onfido/models/webhook_event_type.rb +++ b/lib/onfido/models/webhook_event_type.rb @@ -32,10 +32,11 @@ class WebhookEventType REPORT_COMPLETED = "report.completed".freeze WORKFLOW_TIMELINE_FILE_CREATED = "workflow_timeline_file.created".freeze WORKFLOW_SIGNED_EVIDENCE_FILE_CREATED = "workflow_signed_evidence_file.created".freeze + WORKFLOW_RUN_EVIDENCE_FOLDER_CREATED = "workflow_run_evidence_folder.created".freeze UNKNOWN_DEFAULT_OPEN_API = "unknown_default_open_api".freeze def self.all_vars - @all_vars ||= [AUDIT_LOG_CREATED, WATCHLIST_MONITOR_MATCHES_UPDATED, WORKFLOW_RUN_COMPLETED, WORKFLOW_TASK_STARTED, WORKFLOW_TASK_COMPLETED, CHECK_STARTED, CHECK_REOPENED, CHECK_WITHDRAWN, CHECK_COMPLETED, CHECK_FORM_COMPLETED, REPORT_WITHDRAWN, REPORT_RESUMED, REPORT_CANCELLED, REPORT_AWAITING_APPROVAL, REPORT_COMPLETED, WORKFLOW_TIMELINE_FILE_CREATED, WORKFLOW_SIGNED_EVIDENCE_FILE_CREATED, UNKNOWN_DEFAULT_OPEN_API].freeze + @all_vars ||= [AUDIT_LOG_CREATED, WATCHLIST_MONITOR_MATCHES_UPDATED, WORKFLOW_RUN_COMPLETED, WORKFLOW_TASK_STARTED, WORKFLOW_TASK_COMPLETED, CHECK_STARTED, CHECK_REOPENED, CHECK_WITHDRAWN, CHECK_COMPLETED, CHECK_FORM_COMPLETED, REPORT_WITHDRAWN, REPORT_RESUMED, REPORT_CANCELLED, REPORT_AWAITING_APPROVAL, REPORT_COMPLETED, WORKFLOW_TIMELINE_FILE_CREATED, WORKFLOW_SIGNED_EVIDENCE_FILE_CREATED, WORKFLOW_RUN_EVIDENCE_FOLDER_CREATED, UNKNOWN_DEFAULT_OPEN_API].freeze end # Builds the enum from string diff --git a/lib/onfido/version.rb b/lib/onfido/version.rb index 9f264ab..a746678 100644 --- a/lib/onfido/version.rb +++ b/lib/onfido/version.rb @@ -11,5 +11,5 @@ =end module Onfido - VERSION = '4.3.0' + VERSION = '4.4.0' end From aaea2378e04add3556dbf5e9f4d04021d318c498 Mon Sep 17 00:00:00 2001 From: Davide Vacca Date: Fri, 20 Dec 2024 11:55:11 +0100 Subject: [PATCH 2/2] Update tests after library refresh --- ...dio_webhook_event_with_list_in_output.json | 31 ++ ...o_webhook_event_with_object_in_output.json | 264 ++++++++++++++++++ spec/studio_webhook_event_verifier_spec.rb | 39 +++ 3 files changed, 334 insertions(+) create mode 100644 spec/media/studio_webhook_event_with_list_in_output.json create mode 100644 spec/media/studio_webhook_event_with_object_in_output.json diff --git a/spec/media/studio_webhook_event_with_list_in_output.json b/spec/media/studio_webhook_event_with_list_in_output.json new file mode 100644 index 0000000..b0f0d94 --- /dev/null +++ b/spec/media/studio_webhook_event_with_list_in_output.json @@ -0,0 +1,31 @@ +{ + "payload": { + "resource_type": "workflow_task", + "action": "workflow_task.completed", + "object": { + "id": "document_photo_5c229", + "task_spec_id": "document_photo_5c229", + "task_def_id": "upload_document_photo", + "workflow_run_id": "b48fdff9-66a1-405d-9912-54780799bd68", + "status": "completed", + "completed_at_iso8601": "2024-12-18T18:13:10Z", + "href": "https://api.eu.onfido.com/v3.6/workflow_runs/b48fdff9-66a1-405d-9912-54780799bd68/tasks/document_photo_5c229" + }, + "resource": { + "updated_at": "2024-12-18T18:13:10Z", + "output": [ + { + "type": "document_photo", + "id": "7af75a3a-ba34-4aa5-9e3e-096c9f56256b", + "checksum_sha256": "hiwV2PLmeQZzeySPGGwVL48sxVXcyfpXy9LDl1u3lWU=" + } + ], + "created_at": "2024-12-18T18:12:44Z", + "task_def_id": "upload_document_photo", + "input": {}, + "workflow_run_id": "b48fdff9-66a1-405d-9912-54780799bd68", + "task_def_version": null, + "id": "document_photo_5c229" + } + } +} diff --git a/spec/media/studio_webhook_event_with_object_in_output.json b/spec/media/studio_webhook_event_with_object_in_output.json new file mode 100644 index 0000000..7591a15 --- /dev/null +++ b/spec/media/studio_webhook_event_with_object_in_output.json @@ -0,0 +1,264 @@ +{ + "payload": { + "resource_type": "workflow_task", + "action": "workflow_task.completed", + "object": { + "id": "document_check_75329", + "task_spec_id": "document_check_75329", + "task_def_id": "document_check", + "workflow_run_id": "b48fdff9-66a1-405d-9912-54780799bd68", + "status": "completed", + "completed_at_iso8601": "2024-12-18T18:13:13Z", + "href": "https://api.eu.onfido.com/v3.6/workflow_runs/b48fdff9-66a1-405d-9912-54780799bd68/tasks/document_check_75329" + }, + "resource": { + "task_def_version": null, + "task_def_id": "document_check", + "updated_at": "2024-12-18T18:13:13Z", + "id": "document_check_75329", + "output": { + "status": "complete", + "result": "clear", + "sub_result": "clear", + "uuid": "95c8cc09-db72-42ff-85ef-ee6c82020a24", + "properties": { + "date_of_birth": "1990-01-01", + "date_of_expiry": "2031-05-28", + "document_numbers": [ + { + "type": "document_number", + "value": "999999999" + } + ], + "document_type": "passport", + "first_name": "Jane", + "issuing_country": "GBR", + "last_name": "Doe", + "document_number": "999999999" + }, + "breakdown": { + "data_validation": { + "result": "clear", + "breakdown": { + "mrz": { + "result": "clear", + "properties": {} + }, + "expiry_date": { + "result": "clear", + "properties": {} + }, + "document_expiration": { + "result": "clear", + "properties": {} + }, + "document_numbers": { + "result": "clear", + "properties": {} + }, + "date_of_birth": { + "result": "clear", + "properties": {} + }, + "gender": { + "result": "clear", + "properties": {} + } + } + }, + "visual_authenticity": { + "result": "clear", + "breakdown": { + "face_detection": { + "result": "clear", + "properties": {} + }, + "other": { + "result": "clear", + "properties": {} + }, + "digital_tampering": { + "result": "clear", + "properties": {} + }, + "original_document_present": { + "result": "clear", + "properties": {} + }, + "security_features": { + "result": "clear", + "properties": {} + }, + "template": { + "result": "clear", + "properties": {} + }, + "picture_face_integrity": { + "result": "clear", + "properties": {} + }, + "fonts": { + "result": "clear", + "properties": {} + } + } + }, + "compromised_document": { + "result": "clear", + "breakdown": { + "repeat_attempts": { + "result": "clear", + "properties": {} + }, + "document_database": { + "result": "clear", + "properties": {} + } + } + }, + "data_consistency": { + "result": "clear", + "breakdown": { + "nationality": { + "result": "clear", + "properties": {} + }, + "last_name": { + "result": "clear", + "properties": {} + }, + "first_name": { + "result": "clear", + "properties": {} + }, + "multiple_data_sources_present": { + "result": "clear", + "properties": {} + }, + "gender": { + "result": "clear", + "properties": {} + }, + "date_of_birth": { + "result": "clear", + "properties": {} + }, + "document_type": { + "result": "clear", + "properties": {} + }, + "issuing_country": { + "result": "clear", + "properties": {} + }, + "document_numbers": { + "result": "clear", + "properties": {} + }, + "date_of_expiry": { + "result": "clear", + "properties": {} + } + } + }, + "data_comparison": { + "result": "clear", + "breakdown": { + "date_of_birth": { + "result": "clear", + "properties": {} + }, + "first_name": { + "result": "clear", + "properties": {} + }, + "document_numbers": { + "result": "clear", + "properties": {} + }, + "document_type": { + "result": "clear", + "properties": {} + }, + "last_name": { + "result": "clear", + "properties": {} + }, + "date_of_expiry": { + "result": "clear", + "properties": {} + }, + "gender": { + "result": "clear", + "properties": {} + }, + "issuing_country": { + "result": "clear", + "properties": {} + } + } + }, + "image_integrity": { + "result": "clear", + "breakdown": { + "colour_picture": { + "result": "clear", + "properties": {} + }, + "supported_document": { + "result": "clear", + "properties": {} + }, + "conclusive_document_quality": { + "result": "clear", + "properties": {} + }, + "image_quality": { + "result": "clear", + "properties": {} + } + } + }, + "police_record": { + "result": "clear", + "breakdown": { + "document_has_not_been_recorded_as_lost,_stolen_or_compromised": { + "result": "clear", + "properties": {} + } + } + }, + "age_validation": { + "result": "clear", + "breakdown": { + "minimum_accepted_age": { + "result": "clear", + "properties": {} + } + } + } + }, + "repeat_attempts": { + "report_id": "00000000-0000-0000-0000-000000000000", + "repeat_attempts": [], + "attempts_count": 1, + "attempts_clear_rate": 0, + "unique_mismatches_count": 0 + } + }, + "workflow_run_id": "b48fdff9-66a1-405d-9912-54780799bd68", + "input": { + "document_ids": [ + { + "checksum_sha256": "hiwV2PLmeQZzeySPGGwVL48sxVXcyfpXy9LDl1u3lWU=", + "id": "7af75a3a-ba34-4aa5-9e3e-096c9f56256b", + "type": "document_photo" + } + ], + "first_name": "Jane", + "last_name": "Doe" + }, + "created_at": "2024-12-18T18:13:11Z" + } + } +} diff --git a/spec/studio_webhook_event_verifier_spec.rb b/spec/studio_webhook_event_verifier_spec.rb index fc83096..cad7e42 100644 --- a/spec/studio_webhook_event_verifier_spec.rb +++ b/spec/studio_webhook_event_verifier_spec.rb @@ -35,5 +35,44 @@ expect(webhook_event.payload.resource.task_def_id).to eq('profile_data') expect(webhook_event.payload.resource.output).to eq(nil) end + + context "when webhook event output is an object" do + it "is able to decode and read the output field" do + signature = "e3e5565647f5ccf07b2fd8ac22eab94a0a0619413d981fb768295c820523f7d7" + + event = subject.read_payload(File.read('spec/media/studio_webhook_event_with_object_in_output.json'), signature) + + expect(event.payload.resource.output['properties']).to eq({ + "date_of_birth" => "1990-01-01", + "date_of_expiry" => "2031-05-28", + "document_number" => "999999999", + "document_numbers" => [ + { + "type"=>"document_number", + "value"=>"999999999" + } + ], + "document_type" => "passport", + "first_name" => "Jane", + "issuing_country" => "GBR", + "last_name" => "Doe", + }) + end + end + + context "when webhook event output is an array" do + it "is able to decode and read the output field" do + signature = "f3a5170acfcecf8c1bf6d9cb9995c0d9dec941af83056a721530f8de7af2c293" + event = subject.read_payload(File.read('spec/media/studio_webhook_event_with_list_in_output.json'), signature) + + expect(event.payload.resource.output).to eq([ + { + "checksum_sha256"=>"hiwV2PLmeQZzeySPGGwVL48sxVXcyfpXy9LDl1u3lWU=", + "id"=>"7af75a3a-ba34-4aa5-9e3e-096c9f56256b", + "type"=>"document_photo" + } + ]) + end + end end end