https://github.com/jwoertink/yoti-crystal-sdk
Crystal shard for integrating with Yoti
https://github.com/jwoertink/yoti-crystal-sdk
crystal-lang identification yoti
Last synced: 6 months ago
JSON representation
Crystal shard for integrating with Yoti
- Host: GitHub
- URL: https://github.com/jwoertink/yoti-crystal-sdk
- Owner: jwoertink
- License: mit
- Created: 2024-08-14T20:23:25.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-10-03T18:59:10.000Z (about 1 year ago)
- Last Synced: 2025-04-20T13:00:36.362Z (6 months ago)
- Topics: crystal-lang, identification, yoti
- Language: Crystal
- Homepage:
- Size: 34.2 KB
- Stars: 0
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# yoti-crystal-sdk
This is a Crystal shard for integrating with [Yoti](https://www.yoti.com/) for identification verification.
API documentation can be found on [Yoti Developers](https://developers.yoti.com/) guide.
## Installation
1. Add the dependency to your `shard.yml`:
```yaml
dependencies:
yoti:
github: jwoertink/yoti-crystal-sdk
```2. Run `shards install`
## Usage
```crystal
require "yoti"Yoti.configure do |config|
config.client_sdk_id = ENV["YOTI_CLIENT_SDK_ID"]
config.key_file_path = ENV['YOTI_KEY_FILE_PATH']
endpayload = Yoti::DocScan::SessionSpecification.build do |specification|
specification.with_user_tracking_id("")
.with_requested_checks {
Yoti::DocScan::SessionSpecification::RequestedCheck.build(specification.builder) do |requested_check|
requested_check.with_type("ID_DOCUMENT_AUTHENTICITY").with_config
end
Yoti::DocScan::SessionSpecification::RequestedCheck.build(specification.builder) do |requested_check|
requested_check.with_type("LIVENESS").with_config({liveness_type: "ZOOM", max_retries: 3})
end
}
endresponse = Yoti::DocScan::Client.new.create_session(payload)
if error = response.error
# Yoti::Errors::ErrorResponse
puts error.message
endsession = Yoti::DocScan::Client::Session.from_json(response.body)
# Render the form
iframe_url = "#{Yoti.doc_scan_api_endpoint}/web/index.html?sessionID=#{session.session_id}&sessionToken=#{session.client_session_token}"# Find an existing session
response = Yoti::DocScan::Client.new.get_session(session.session_id)
session = JSON.parse(response.body)
media_id = session.dig("resources", "id_documents").as_a[0].dig("document_id_photo", "media", "id").as_s# Fetch specific media content
media = Yoti::DocScan::Client.new.get_media_content(session.session_id, media_id)
File.write("/path/to/document.png", media.content)
```## Development
* write code
* write spec
* crystal tool format spec/ src/
* ./bin/ameba
* crystal spec
* repeat## Contributing
1. Fork it ()
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create a new Pull Request## Contributors
- [Jeremy Woertink](https://github.com/jwoertink) - creator and maintainer