Class: Yoti::DocScan::Client
- Inherits:
-
Object
- Object
- Yoti::DocScan::Client
- Defined in:
- lib/yoti/doc_scan/client.rb
Class Method Summary collapse
-
.create_session(session_specification) ⇒ Yoti::DocScan::Session::Create::CreateSessionResult
Creates a Doc Scan session using the supplied session specification.
-
.delete_media_content(session_id, media_id) ⇒ Object
Deletes media related to a Yoti Doc Scan session based on the supplied media ID.
-
.delete_session(session_id) ⇒ Object
Deletes a previously created Yoti Doc Scan session and all of its related resources.
-
.get_media_content(session_id, media_id) ⇒ Yoti::Media
Retrieves media related to a Yoti Doc Scan session based on the supplied media ID.
-
.get_session(session_id) ⇒ Yoti::DocScan::Session::Retrieve::GetSessionResult
Retrieves the state of a previously created Yoti Doc Scan session.
-
.supported_documents ⇒ Yoti::DocScan::Support::SupportedDocumentsResponse
Gets a list of supported documents.
Class Method Details
.create_session(session_specification) ⇒ Yoti::DocScan::Session::Create::CreateSessionResult
Creates a Doc Scan session using the supplied session specification
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/yoti/doc_scan/client.rb', line 14 def create_session(session_specification) Validation.assert_is_a( Yoti::DocScan::Session::Create::SessionSpecification, session_specification, 'session_specification' ) response = create_request .with_http_method('POST') .with_endpoint('sessions') .with_payload(session_specification) .with_query_param('sdkId', Yoti.configuration.client_sdk_id) .build .execute Yoti::DocScan::Session::Create::CreateSessionResult.new(JSON.parse(response.body)) end |
.delete_media_content(session_id, media_id) ⇒ Object
Deletes media related to a Yoti Doc Scan session based on the supplied media ID
102 103 104 105 106 107 108 109 110 111 112 |
# File 'lib/yoti/doc_scan/client.rb', line 102 def delete_media_content(session_id, media_id) Validation.assert_is_a(String, session_id, 'session_id') Validation.assert_is_a(String, media_id, 'media_id') create_request .with_http_method('DELETE') .with_endpoint(media_path(session_id, media_id)) .with_query_param('sdkId', Yoti.configuration.client_sdk_id) .build .execute end |
.delete_session(session_id) ⇒ Object
Deletes a previously created Yoti Doc Scan session and all of its related resources
58 59 60 61 62 63 64 65 66 67 |
# File 'lib/yoti/doc_scan/client.rb', line 58 def delete_session(session_id) Validation.assert_is_a(String, session_id, 'session_id') create_request .with_http_method('DELETE') .with_endpoint(session_path(session_id)) .with_query_param('sdkId', Yoti.configuration.client_sdk_id) .build .execute end |
.get_media_content(session_id, media_id) ⇒ Yoti::Media
Retrieves media related to a Yoti Doc Scan session based on the supplied media ID
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/yoti/doc_scan/client.rb', line 78 def get_media_content(session_id, media_id) Validation.assert_is_a(String, session_id, 'session_id') Validation.assert_is_a(String, media_id, 'media_id') response = create_request .with_http_method('GET') .with_endpoint(media_path(session_id, media_id)) .with_query_param('sdkId', Yoti.configuration.client_sdk_id) .build .execute Yoti::Media.new( response.body, response.get_fields('content-type')[0] ) end |
.get_session(session_id) ⇒ Yoti::DocScan::Session::Retrieve::GetSessionResult
Retrieves the state of a previously created Yoti Doc Scan session
39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/yoti/doc_scan/client.rb', line 39 def get_session(session_id) Validation.assert_is_a(String, session_id, 'session_id') response = create_request .with_http_method('GET') .with_endpoint(session_path(session_id)) .with_query_param('sdkId', Yoti.configuration.client_sdk_id) .build .execute Yoti::DocScan::Session::Retrieve::GetSessionResult.new(JSON.parse(response.body)) end |
.supported_documents ⇒ Yoti::DocScan::Support::SupportedDocumentsResponse
Gets a list of supported documents.
119 120 121 122 123 124 125 126 127 |
# File 'lib/yoti/doc_scan/client.rb', line 119 def supported_documents response = create_request .with_http_method('GET') .with_endpoint('supported-documents') .build .execute Yoti::DocScan::Support::SupportedDocumentsResponse.new(JSON.parse(response.body)) end |