Skip to content

Add support for requesting and retrieving SHARE_CODE resources and tasks#400

Merged
mehmet-yoti merged 3 commits intodevelopmentfrom
SDK-2757-php-add-support-for-requesting-and-retrieving-share-code-resources-tasks
Feb 25, 2026
Merged

Add support for requesting and retrieving SHARE_CODE resources and tasks#400
mehmet-yoti merged 3 commits intodevelopmentfrom
SDK-2757-php-add-support-for-requesting-and-retrieving-share-code-resources-tasks

Conversation

@mehmet-yoti
Copy link
Contributor

Add Support for Retrieving SHARE_CODE Resources in IDV Sessions

Overview

This PR implements support for retrieving the new SHARE_CODE resource type from IDV session data. Share codes are managed server-side by the API — the SDK provides read access to share code resources returned in session retrieval responses.

Changes

Session Retrieval (Response)

  • Resource Response: Created ShareCodeResourceResponse with support for:

    • Basic fields: id, source, created_at, last_updated
    • Media fields via ShareCodeMediaResponse wrapper: lookup_profile, returned_profile, id_photo, file
    • Source handling via parent ResourceResponse (parses {"type":"END_USER"} into AllowedSourceResponse subclasses)
    • Tasks array with automatic filtering for VERIFY_SHARE_CODE_TASK
  • Task Response: Added VerifyShareCodeTaskResponse for handling VERIFY_SHARE_CODE_TASK type

  • Resource Container: Updated to include shareCodes field (ShareCodeResourceResponse[]) with getShareCodes() getter

  • Task Dispatch: Updated ResourceResponse::createTaskFromArray() to recognise VERIFY_SHARE_CODE_TASK

Constants

  • Added VERIFY_SHARE_CODE_TASK = 'VERIFY_SHARE_CODE_TASK' to Constants.php

API Usage

Retrieving Share Codes from a Session

$result = $client->getSession($sessionId);

foreach ($result->getResources()->getShareCodes() as $shareCode) {
    echo 'ID: ' . $shareCode->getId() . PHP_EOL;
    echo 'Created: ' . $shareCode->getCreatedAt() . PHP_EOL;

    if ($shareCode->getIdPhoto() !== null && $shareCode->getIdPhoto()->getMedia() !== null) {
        echo 'ID Photo Media ID: ' . $shareCode->getIdPhoto()->getMedia()->getId() . PHP_EOL;
    }

    foreach ($shareCode->getVerifyShareCodeTasks() as $task) {
        echo 'Task: ' . $task->getId() . ' State: ' . $task->getState() . PHP_EOL;
    }
}

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds support for retrieving SHARE_CODE resources from IDV session responses in the Yoti PHP SDK. Share codes are server-side managed resources that can be retrieved through session data, with associated verification tasks and media fields.

Changes:

  • Added ShareCodeResourceResponse class to represent share code resources with fields for creation/update timestamps, media profiles (lookup, returned, ID photo, file), and associated verification tasks
  • Added ShareCodeMediaResponse wrapper class to encapsulate media responses for share code fields
  • Added VerifyShareCodeTaskResponse class to represent verification tasks for share codes
  • Updated ResourceContainer to include share codes collection and parsing logic
  • Updated ResourceResponse to dispatch VERIFY_SHARE_CODE_TASK type to appropriate handler
  • Added VERIFY_SHARE_CODE_TASK constant to centralize task type string

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
src/DocScan/Session/Retrieve/ShareCodeResourceResponse.php New resource response class for share code data with media fields and task filtering
src/DocScan/Session/Retrieve/ShareCodeMediaResponse.php New wrapper class for share code media responses
src/DocScan/Session/Retrieve/VerifyShareCodeTaskResponse.php New task response class extending TaskResponse for share code verification
src/DocScan/Session/Retrieve/ResourceContainer.php Added share codes field, getter, and parsing method
src/DocScan/Session/Retrieve/ResourceResponse.php Added case for VERIFY_SHARE_CODE_TASK in task dispatch
src/DocScan/Constants.php Added VERIFY_SHARE_CODE_TASK constant
tests/DocScan/Session/Retrieve/ShareCodeResourceResponseTest.php Comprehensive test coverage for ShareCodeResourceResponse
tests/DocScan/Session/Retrieve/ShareCodeMediaResponseTest.php Test coverage for ShareCodeMediaResponse
tests/DocScan/Session/Retrieve/VerifyShareCodeTaskResponseTest.php Test coverage for VerifyShareCodeTaskResponse
tests/DocScan/Session/Retrieve/ResourceContainerTest.php Updated tests to cover share code parsing

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

…eve and rename withAdvIdentityProfileReqs for consistency
@mehmet-yoti mehmet-yoti merged commit cae25cb into development Feb 25, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants