pax_global_header00006660000000000000000000000064151542737520014525gustar00rootroot0000000000000052 comment=cfcf76f4d2b8100d69aa0f632d70a42a0ab8fdd2 TeleSign-ruby_telesign_enterprise-cfcf76f/000077500000000000000000000000001515427375200211365ustar00rootroot00000000000000TeleSign-ruby_telesign_enterprise-cfcf76f/.DS_Store000066400000000000000000000140041515427375200226200ustar00rootroot00000000000000Bud1†plesdsclexamplesdsclboollibdsclbool  @€ @€ @€ @ E†DSDB `Ŕ @€ @€ @TeleSign-ruby_telesign_enterprise-cfcf76f/.gitignore000066400000000000000000000002111515427375200231200ustar00rootroot00000000000000*.gem # RubyMine IDE .idea # Visual Studio Code IDE .vscode/ # Other .DS_Store .dockerignore .bundle Dockerfile Gemfile Gemfile.lock TeleSign-ruby_telesign_enterprise-cfcf76f/.travis.yml000066400000000000000000000002611515427375200232460ustar00rootroot00000000000000language: ruby rvm: - "2.4.6" - "2.5.5" - "2.6.3" install: - gem build telesignenterprise.gemspec - gem install telesignenterprise-*.gem --development script: - rakeTeleSign-ruby_telesign_enterprise-cfcf76f/LICENSE000066400000000000000000000020421515427375200221410ustar00rootroot00000000000000Copyright (c) 2023 Telesign Corp. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. TeleSign-ruby_telesign_enterprise-cfcf76f/README.md000066400000000000000000000040501515427375200224140ustar00rootroot00000000000000# Telesign Full-service Ruby SDK [Telesign](https://telesign.com) connects, protects, and defends the customer experience with intelligence from billions of digital interactions and mobile signals. Through developer-friendly APIs that deliver user verification, digital identity, and omnichannel communications, we help the world's largest brands secure onboarding, maintain account integrity, prevent fraud, and streamline omnichannel engagement. ## Requirements * **Ruby 2+**. > **NOTE:** > > These instructions are for MacOS. They will need to be adapted if you are installing on Windows. ## Installation Follow these steps to add this SDK as a dependency to your project. 1. *(Optional)* Create a new directory for your Ruby project. Skip this step if you already have created a project. If you plan to create multiple Ruby projects that use Telesign, we recommend that you group them within a `telesign_integrations` directory. ``` cd ~/code/local mkdir telesign_integrations cd telesign_integrations mkdir {your project name} cd {your project name} ``` 2. Install the SDK as a dependency in the top-level directory of your project using the command below. Once the SDK is installed, you should see a message in the terminal notifying you that you have successfully installed the SDK. `gem install telesignenterprise` ## Authentication If you use a Telesign SDK to make your request, authentication is handled behind-the-scenes for you. All you need to provide is your Customer ID and API Key. The SDKs apply Digest authentication whenever they make a request to a Telesign service where it is supported. When Digest authentication is not supported, the SDKs apply Basic authentication. ## What's next * Learn to send a request to Telesign with code with one of our [tutorials](https://developer.telesign.com/enterprise/docs/tutorials). * Browse our [Developer Portal](https://developer.telesign.com) for tutorials, how-to guides, reference content, and more. * Check out our [sample code](https://github.com/TeleSign/sample_code) on GitHub. TeleSign-ruby_telesign_enterprise-cfcf76f/RELEASE000066400000000000000000000036501515427375200221450ustar00rootroot000000000000006.0.0 - Removed the create_event method for Telebureau. 5.0.1 - Fix missing runtime dependency. 5.0.0 - Added support for Intelligence Cloud to use new endpoint. - Removed Legacy PID Score. 4.0.0 - Added full support for App Verify API. 3.0.0 - Added full support for latest version of Phone ID via POST requests. - Removed Legacy PID Contact. - Removed Legacy PID Number Deactivation. 2.6.0 - Added method to update verification process. - Added method to retrieve verification process. - Added unit test for update verification process. - Added unit test for retrieve verification process. 2.5.0 - Added tracking to request 2.4.0 - Added new method to send requests to Telesign Messaging. - Added new method to send requests to the Telesign Verify API. - Added new assert unit test for requests to Telesign Messaging. - Added new assert unit test for requests to the Telesign Verify API. 2.3.1 - Removed VERIFY_PUSH_RESOURCE variable in VerifyClient class. 2.3.0 - Removed push method in VerifyClient class 2.2.2 - Permits use of net-http-persistent 4.x.x 2.2.1 - Prepare to publish to gem 2.2.0 - Added support for phoneid addons and json content-type 2.1.2 - Added completion endpoint to VerifyClient 2.1.1 - bumped telesign version to include fix 2.1.0 - updated and improved README - secret_key refactored to api_key to align with docs and portal - api_host is now known as rest_endpoint to align with docs and portal 2.0.0 - Major refactor and simplification into generic REST client. - API parameters are now passed as kwargs to endpoint handlers. - UserAgent is now set to track client usage and help debug issues. - generate_telesign_headers is now static and easily extracted from the SDK if custom behavior/implementation is required. 1.0.2 - Fixed gem imports - Added number_deactivation and telebureau create, retrieve and delete endpoints. 1.0.0 - Initial version supporting commonly used Telesign endpoints. TeleSign-ruby_telesign_enterprise-cfcf76f/Rakefile000066400000000000000000000002501515427375200226000ustar00rootroot00000000000000require 'rake/testtask' Rake::TestTask.new do |t| t.libs << 'lib' << 'test' t.test_files = FileList['test/test*.rb'] t.verbose = true end task :default => :testTeleSign-ruby_telesign_enterprise-cfcf76f/examples/000077500000000000000000000000001515427375200227545ustar00rootroot00000000000000TeleSign-ruby_telesign_enterprise-cfcf76f/examples/app_verify/000077500000000000000000000000001515427375200251205ustar00rootroot00000000000000TeleSign-ruby_telesign_enterprise-cfcf76f/examples/app_verify/1_send_initiate_verification_call.rb000066400000000000000000000012611515427375200342410ustar00rootroot00000000000000require 'telesign' require 'telesignenterprise' customer_id = 'FFFFFFFF-EEEE-DDDD-1234-AB1234567890' api_key = 'ABC12345yusumoN6BYsBVkh+yRJ5czgsnCehZaOYldPJdmFh6NeX8kunZ2zU1YWaUw/0wV6xfw==' phone_number = '11234567890' verify = TelesignEnterprise::AppVerifyClient.new(customer_id, api_key) initiate_response = verify.initiate(phone_number) puts "initiate response: #{initiate_response.body}\n" reference_id = JSON.parse(initiate_response.body)['reference_id'] puts "Reference ID: #{reference_id}" status_response = verify.get_transaction_status(reference_id) puts "Status Code: #{status_response.status_code}" puts "Status: #{JSON.parse(status_response.body)['status']['description']}"2_send_finalize_verification_after_receiving_appverify_call.rb000066400000000000000000000016621515427375200414640ustar00rootroot00000000000000TeleSign-ruby_telesign_enterprise-cfcf76f/examples/app_verifyrequire 'telesign' require 'telesignenterprise' customer_id = 'FFFFFFFF-EEEE-DDDD-1234-AB1234567890' api_key = 'ABC12345yusumoN6BYsBVkh+yRJ5czgsnCehZaOYldPJdmFh6NeX8kunZ2zU1YWaUw/0wV6xfw==' phone_number = '11234567890' app_verify = TelesignEnterprise::AppVerifyClient.new(customer_id, api_key) initiate_response = app_verify.initiate(phone_number) reference_id = JSON.parse(initiate_response.body)['reference_id'] unless reference_id puts "No reference ID returned from initiate call. Cannot finalize." exit 1 end puts "Verification call initiated. Reference ID: #{reference_id}" print "Please enter the verification code from the caller ID: " verify_code = gets.chomp finalize_response = app_verify.finalize(reference_id, verify_code: verify_code) puts "Finalize response: #{finalize_response.body}" puts "Status Code: #{finalize_response.status_code}" puts "Status: #{JSON.parse(finalize_response.body)['status']['description']}"3_report_timeout_based_on_call_receipt.rb000066400000000000000000000014421515427375200352320ustar00rootroot00000000000000TeleSign-ruby_telesign_enterprise-cfcf76f/examples/app_verifyrequire 'telesign' require 'telesignenterprise' customer_id = 'FFFFFFFF-EEEE-DDDD-1234-AB1234567890' api_key = 'ABC12345yusumoN6BYsBVkh+yRJ5czgsnCehZaOYldPJdmFh6NeX8kunZ2zU1YWaUw/0wV6xfw==' phone_number = '11234567890' verify = TelesignEnterprise::AppVerifyClient.new(customer_id, api_key) initiate_response = verify.initiate(phone_number) puts "initiate response: #{initiate_response.body}\n" reference_id = JSON.parse(initiate_response.body)['reference_id'] unless reference_id puts "No reference ID returned. Exiting." exit 1 end timeout_response = verify.report_timeout(reference_id) puts "Timeout response status code: #{timeout_response.status_code}\n" puts "Timeout response body: #{timeout_response.body}\n" puts "Status: #{JSON.parse(timeout_response.body)['status']['description']}"TeleSign-ruby_telesign_enterprise-cfcf76f/examples/app_verify/4_report_unknown_caller_id.rb000066400000000000000000000017411515427375200327630ustar00rootroot00000000000000require 'telesign' require 'telesignenterprise' customer_id = 'FFFFFFFF-EEEE-DDDD-1234-AB1234567890' api_key = 'ABC12345yusumoN6BYsBVkh+yRJ5czgsnCehZaOYldPJdmFh6NeX8kunZ2zU1YWaUw/0wV6xfw==' phone_number = '11234567890' verify = TelesignEnterprise::AppVerifyClient.new(customer_id, api_key) initiate_response = verify.initiate(phone_number) puts "initiate response: #{initiate_response.body}\n" reference_id = JSON.parse(initiate_response.body)['reference_id'] prefix = JSON.parse(initiate_response.body)['prefix'] unless reference_id && prefix puts "Missing reference ID or prefix. Exiting." exit 1 end unknown_caller_id = "#{prefix}99999" # simulate Unknown caller ID unknown_response = verify.report_unknown_caller_id(reference_id, unknown_caller_id) puts "Unknown caller ID report status code: #{unknown_response.status_code}\n" puts "Unknown caller ID report response body: #{unknown_response.body}\n" puts "Status: #{JSON.parse(unknown_response.body)['status']['description']}"5_check_transaction_status_for_the_reference_id.rb000066400000000000000000000014661515427375200371060ustar00rootroot00000000000000TeleSign-ruby_telesign_enterprise-cfcf76f/examples/app_verifyrequire 'telesign' require 'telesignenterprise' customer_id = 'FFFFFFFF-EEEE-DDDD-1234-AB1234567890' api_key = 'ABC12345yusumoN6BYsBVkh+yRJ5czgsnCehZaOYldPJdmFh6NeX8kunZ2zU1YWaUw/0wV6xfw==' phone_number = '11234567890' verify = TelesignEnterprise::AppVerifyClient.new(customer_id, api_key) initiate_response = verify.initiate(phone_number) puts "initiate response: #{initiate_response.body}\n" reference_id = JSON.parse(initiate_response.body)['reference_id'] unless reference_id puts "No reference ID returned. Exiting." exit 1 end status_response = verify.get_transaction_status(reference_id) puts "transaction status response code: #{status_response.status_code}\n" puts "transaction status response body: #{status_response.body}\n" puts "Status: #{JSON.parse(status_response.body)['status']['description']}"TeleSign-ruby_telesign_enterprise-cfcf76f/examples/phone_id/000077500000000000000000000000001515427375200245415ustar00rootroot00000000000000TeleSign-ruby_telesign_enterprise-cfcf76f/examples/phone_id/1_check_phone_number_body.rb000066400000000000000000000011561515427375200321440ustar00rootroot00000000000000require 'telesign' require 'telesignenterprise' customer_id = 'FFFFFFFF-EEEE-DDDD-1234-AB1234567890' api_key = 'ABC12345yusumoN6BYsBVkh+yRJ5czgsnCehZaOYldPJdmFh6NeX8kunZ2zU1YWaUw/0wV6xfw==' phone_number = '11234567890' phoneid_client = TelesignEnterprise::PhoneIdClient.new(customer_id, api_key) response = phoneid_client.phone_id_body(phone_number) puts "status_code=#{response.status_code}, ok=#{response.ok}, responsebody=#{response.body}" if response.ok puts "Phone number %s carrier: '%s'" % [phone_number, response.json['carrier']['name']] else puts "ERROR: #{response.status_code} - #{response.body}" end TeleSign-ruby_telesign_enterprise-cfcf76f/examples/phone_id/1_check_phone_number_path.rb000066400000000000000000000011541515427375200321410ustar00rootroot00000000000000require 'telesign' require 'telesignenterprise' customer_id = 'FFFFFFFF-EEEE-DDDD-1234-AB1234567890' api_key = 'ABC12345yusumoN6BYsBVkh+yRJ5czgsnCehZaOYldPJdmFh6NeX8kunZ2zU1YWaUw/0wV6xfw==' phone_number = '11234567890' phoneid_client = TelesignEnterprise::PhoneIdClient.new(customer_id, api_key) response = phoneid_client.phone_id_path(phone_number) puts "status_code=#{response.status_code}, ok=#{response.ok}, responsebody=#{response.body}" if response.ok puts "Phone number %s carrier: '%s'" % [phone_number, response.json['carrier']['name']] else puts "ERROR: #{response.status_code} - #{response.body}" end TeleSign-ruby_telesign_enterprise-cfcf76f/examples/score/000077500000000000000000000000001515427375200240675ustar00rootroot00000000000000TeleSign-ruby_telesign_enterprise-cfcf76f/examples/score/1_check_phone_number_risk_level.rb000066400000000000000000000013351515427375200326730ustar00rootroot00000000000000require 'telesignenterprise' customer_id = 'FFFFFFFF-EEEE-DDDD-1234-AB1234567890' api_key = 'ABC12345yusumoN6BYsBVkh+yRJ5czgsnCehZaOYldPJdmFh6NeX8kunZ2zU1YWaUw/0wV6xfw==' phone_number = '11234567890' account_lifecycle_event = 'create' score_client = TelesignEnterprise::ScoreClient.new(customer_id, api_key) response = score_client.score(phone_number, account_lifecycle_event) if response.ok puts format("Phone number %s has a '%s' risk level and the recommendation is to '%s' the transaction.", phone_number, response.json['risk']['level'], response.json['risk']['recommendation']) else puts "Request failed with status code: #{response.status_code}. Details: #{response.json}" end TeleSign-ruby_telesign_enterprise-cfcf76f/examples/verify_completion/000077500000000000000000000000001515427375200265115ustar00rootroot000000000000001_report_completion_after_receiving_sms.rb000066400000000000000000000016111515427375200370400ustar00rootroot00000000000000TeleSign-ruby_telesign_enterprise-cfcf76f/examples/verify_completionrequire 'telesign' require 'telesignenterprise' customer_id = 'FFFFFFFF-EEEE-DDDD-1234-AB1234567890' api_key = 'EXAMPLE----TE8sTgg45yusumoN6BYsBVkh+yRJ5czgsnCehZaOYldPJdmFh6NeX8kunZ2zU1YWaUw/0wV6xfw==' phone_number = 'phone_number' verify_code = Telesign::Util.random_with_n_digits(5) verify_client = TelesignEnterprise::VerifyClient.new(customer_id, api_key) response = verify_client.sms(phone_number, verify_code: verify_code) reference_id = response.json['reference_id'] print 'Please enter the verification code you were sent: ' user_entered_verify_code = gets.strip if verify_code == user_entered_verify_code puts 'Your code is correct.' response = verify_client.completion(reference_id) if response.ok and response.json['status']['code'] == 1900 puts 'Completion successfully reported.' else puts 'Error reporting completion.' end else puts 'Your code is incorrect.' end 2_report_completion_after_receiving_voice_call.rb000066400000000000000000000016131515427375200403410ustar00rootroot00000000000000TeleSign-ruby_telesign_enterprise-cfcf76f/examples/verify_completionrequire 'telesign' require 'telesignenterprise' customer_id = 'FFFFFFFF-EEEE-DDDD-1234-AB1234567890' api_key = 'EXAMPLE----TE8sTgg45yusumoN6BYsBVkh+yRJ5czgsnCehZaOYldPJdmFh6NeX8kunZ2zU1YWaUw/0wV6xfw==' phone_number = 'phone_number' verify_code = Telesign::Util.random_with_n_digits(5) verify_client = TelesignEnterprise::VerifyClient.new(customer_id, api_key) response = verify_client.voice(phone_number, verify_code: verify_code) reference_id = response.json['reference_id'] print 'Please enter the verification code you were sent: ' user_entered_verify_code = gets.strip if verify_code == user_entered_verify_code puts 'Your code is correct.' response = verify_client.completion(reference_id) if response.ok and response.json['status']['code'] == 1900 puts 'Completion successfully reported.' else puts 'Error reporting completion.' end else puts 'Your code is incorrect.' end TeleSign-ruby_telesign_enterprise-cfcf76f/examples/verify_sms/000077500000000000000000000000001515427375200251425ustar00rootroot00000000000000TeleSign-ruby_telesign_enterprise-cfcf76f/examples/verify_sms/1_send_sms_with_verification_code.rb000066400000000000000000000012071515427375200343110ustar00rootroot00000000000000require 'telesign' require 'telesignenterprise' customer_id = 'FFFFFFFF-EEEE-DDDD-1234-AB1234567890' api_key = 'EXAMPLE----TE8sTgg45yusumoN6BYsBVkh+yRJ5czgsnCehZaOYldPJdmFh6NeX8kunZ2zU1YWaUw/0wV6xfw==' phone_number = 'phone_number' verify_code = Telesign::Util.random_with_n_digits(5) verify_client = TelesignEnterprise::VerifyClient.new(customer_id, api_key) response = verify_client.sms(phone_number, verify_code: verify_code) print 'Please enter the verification code you were sent: ' user_entered_verify_code = gets.strip if verify_code == user_entered_verify_code puts 'Your code is correct.' else puts 'Your code is incorrect.' end TeleSign-ruby_telesign_enterprise-cfcf76f/examples/verify_sms/2_send_custom_sms.rb000066400000000000000000000006461515427375200311230ustar00rootroot00000000000000require 'telesignenterprise' customer_id = 'FFFFFFFF-EEEE-DDDD-1234-AB1234567890' api_key = 'EXAMPLE----TE8sTgg45yusumoN6BYsBVkh+yRJ5czgsnCehZaOYldPJdmFh6NeX8kunZ2zU1YWaUw/0wV6xfw==' phone_number = 'phone_number' template = 'Your Widgets \'n\' More verification code is $$CODE$$.' verify_client = TelesignEnterprise::VerifyClient.new(customer_id, api_key) response = verify_client.sms(phone_number, template: template) 3_send_custom_sms_in_different_language.rb000066400000000000000000000007241515427375200354210ustar00rootroot00000000000000TeleSign-ruby_telesign_enterprise-cfcf76f/examples/verify_sms# encoding: UTF-8 require 'telesignenterprise' customer_id = 'FFFFFFFF-EEEE-DDDD-1234-AB1234567890' api_key = 'EXAMPLE----TE8sTgg45yusumoN6BYsBVkh+yRJ5czgsnCehZaOYldPJdmFh6NeX8kunZ2zU1YWaUw/0wV6xfw==' phone_number = 'phone_number' language = 'fr-FR' tts_message = 'Votre code de vĂ©rification Widgets \'n\' More est $$CODE$$.' verify_client = TelesignEnterprise::VerifyClient.new(customer_id, api_key) response = verify_client.sms(phone_number, template: template) TeleSign-ruby_telesign_enterprise-cfcf76f/examples/verify_voice/000077500000000000000000000000001515427375200254455ustar00rootroot000000000000001_send_voice_call_with_verification_code.rb000066400000000000000000000012111515427375200360260ustar00rootroot00000000000000TeleSign-ruby_telesign_enterprise-cfcf76f/examples/verify_voicerequire 'telesign' require 'telesignenterprise' customer_id = 'FFFFFFFF-EEEE-DDDD-1234-AB1234567890' api_key = 'EXAMPLE----TE8sTgg45yusumoN6BYsBVkh+yRJ5czgsnCehZaOYldPJdmFh6NeX8kunZ2zU1YWaUw/0wV6xfw==' phone_number = 'phone_number' verify_code = Telesign::Util.random_with_n_digits(5) verify_client = TelesignEnterprise::VerifyClient.new(customer_id, api_key) response = verify_client.voice(phone_number, verify_code: verify_code) print 'Please enter the verification code you were sent: ' user_entered_verify_code = gets.strip if verify_code == user_entered_verify_code puts 'Your code is correct.' else puts 'Your code is incorrect.' end 2_send_custom_voice_call_with_text_to_speech.rb000066400000000000000000000014761515427375200367770ustar00rootroot00000000000000TeleSign-ruby_telesign_enterprise-cfcf76f/examples/verify_voicerequire 'telesign' require 'telesignenterprise' customer_id = 'FFFFFFFF-EEEE-DDDD-1234-AB1234567890' api_key = 'EXAMPLE----TE8sTgg45yusumoN6BYsBVkh+yRJ5czgsnCehZaOYldPJdmFh6NeX8kunZ2zU1YWaUw/0wV6xfw==' phone_number = 'phone_number' verify_code = Telesign::Util.random_with_n_digits(5) verify_code_with_commas = verify_code.chars.join(', ') tts_message = "Hello, your code is #{verify_code_with_commas}. Once again, your code is #{verify_code_with_commas}. Goodbye." verify_client = TelesignEnterprise::VerifyClient.new(customer_id, api_key) response = verify_client.voice(phone_number, tts_message: tts_message) print 'Please enter the verification code you were sent: ' user_entered_verify_code = gets.strip if verify_code == user_entered_verify_code puts 'Your code is correct.' else puts 'Your code is incorrect.' end 3_send_custom_voice_call_in_different_language.rb000066400000000000000000000007601515427375200372220ustar00rootroot00000000000000TeleSign-ruby_telesign_enterprise-cfcf76f/examples/verify_voice# encoding: UTF-8 require 'telesignenterprise' customer_id = 'FFFFFFFF-EEEE-DDDD-1234-AB1234567890' api_key = 'EXAMPLE----TE8sTgg45yusumoN6BYsBVkh+yRJ5czgsnCehZaOYldPJdmFh6NeX8kunZ2zU1YWaUw/0wV6xfw==' phone_number = 'phone_number' language = 'fr-FR' tts_message = 'Votre code de vĂ©rification Widgets \'n\' More est $$CODE$$.' verify_client = TelesignEnterprise::VerifyClient.new(customer_id, api_key) response = verify_client.voice(phone_number, language: language, tts_message: tts_message) TeleSign-ruby_telesign_enterprise-cfcf76f/lib/000077500000000000000000000000001515427375200217045ustar00rootroot00000000000000TeleSign-ruby_telesign_enterprise-cfcf76f/lib/telesignenterprise.rb000066400000000000000000000004551515427375200261500ustar00rootroot00000000000000require 'telesignenterprise/phoneid' require 'telesignenterprise/telebureau' require 'telesignenterprise/verify' require 'telesignenterprise/omniverify' require 'telesignenterprise/score' require 'telesignenterprise/messaging' require 'telesignenterprise/voice' require 'telesignenterprise/appverify' TeleSign-ruby_telesign_enterprise-cfcf76f/lib/telesignenterprise/000077500000000000000000000000001515427375200256175ustar00rootroot00000000000000TeleSign-ruby_telesign_enterprise-cfcf76f/lib/telesignenterprise/appverify.rb000066400000000000000000000047011515427375200301530ustar00rootroot00000000000000require 'telesign' require_relative 'constants' module TelesignEnterprise # App Verify is a secure, lightweight SDK that integrates a frictionless user verification process into existing # native mobile applications. class AppVerifyClient < Telesign::RestClient APP_VERIFY_BASE_RESOURCE = "/v1/verify/auto/voice" INITIATE_RESOURCE = "#{APP_VERIFY_BASE_RESOURCE}/initiate" FINALIZE_RESOURCE = "#{APP_VERIFY_BASE_RESOURCE}/finalize" FINALIZE_CALLERID_RESOURCE = "#{APP_VERIFY_BASE_RESOURCE}/finalize/callerid" FINALIZE_TIMEOUT_RESOURCE = "#{APP_VERIFY_BASE_RESOURCE}/finalize/timeout" def initialize(customer_id, api_key, rest_endpoint: 'https://rest-ww.telesign.com', timeout: nil, source: 'ruby_telesign_enterprise', sdk_version_origin: TelesignEnterprise::SDK_VERSION, sdk_version_dependency: Gem.loaded_specs['telesign'].version) super(customer_id, api_key, rest_endpoint: rest_endpoint, timeout: timeout, source: source, sdk_version_origin: sdk_version_origin, sdk_version_dependency: sdk_version_dependency) end # Send call with verification code (Initiate) # See https://developer.telesign.com/enterprise/reference/sendappverifycode def initiate(phone_number, params = {}) post(INITIATE_RESOURCE, phone_number: phone_number, **params) end # End call (Finalize) # See https://developer.telesign.com/enterprise/reference/endappverifycall def finalize(reference_id, params = {}) post(FINALIZE_RESOURCE, reference_id: reference_id, **params) end # Report unknown caller ID # See https://developer.telesign.com/enterprise/reference/reportappverifycallerid def report_unknown_caller_id(reference_id, unknown_caller_id, params = {}) post(FINALIZE_CALLERID_RESOURCE, reference_id: reference_id, unknown_caller_id: unknown_caller_id, **params) end # Report timeout # See https://developer.telesign.com/enterprise/reference/reportappverifytimeout def report_timeout(reference_id) post(FINALIZE_TIMEOUT_RESOURCE, reference_id: reference_id) end # Get transaction status # See https://developer.telesign.com/enterprise/reference/getappverifystatus def get_transaction_status(reference_id) get("#{APP_VERIFY_BASE_RESOURCE}/#{reference_id}") end end endTeleSign-ruby_telesign_enterprise-cfcf76f/lib/telesignenterprise/constants.rb000066400000000000000000000000671515427375200301630ustar00rootroot00000000000000module TelesignEnterprise SDK_VERSION = '6.0.0' endTeleSign-ruby_telesign_enterprise-cfcf76f/lib/telesignenterprise/messaging.rb000066400000000000000000000033261515427375200301250ustar00rootroot00000000000000require 'telesign' require_relative 'constants' OMNI_MESSAGING_RESOURCE = '/v1/omnichannel' module TelesignEnterprise # TeleSign's Messaging API allows you to easily send SMS messages. You can send alerts, reminders, and notifications, # or you can send verification messages containing one-time passcodes (OTP). class MessagingClient < Telesign::MessagingClient def initialize(customer_id, api_key, rest_endpoint: 'https://rest-ww.telesign.com', timeout: nil, source: 'ruby_telesign_enterprise', sdk_version_origin: TelesignEnterprise::SDK_VERSION, sdk_version_dependency: Gem.loaded_specs['telesign'].version) super(customer_id, api_key, rest_endpoint: rest_endpoint, timeout: timeout, source: source, sdk_version_origin: sdk_version_origin, sdk_version_dependency: sdk_version_dependency) end # Telesign Messaging allows you to easily send a message to the target recipient using any of Telesign's supported channels. class OmniMessagingClient < Telesign::RestClient def initialize(customer_id, api_key, rest_endpoint, timeout: nil) super(customer_id, api_key, rest_endpoint: rest_endpoint, timeout: timeout) end def omni_message(**params) self.post(OMNI_MESSAGING_RESOURCE, **params) end private def content_type "application/json" end end def omni_message (**params) omni_msg = OmniMessagingClient.new(@customer_id, @api_key, @rest_endpoint) omni_msg.omni_message(**params) end end endTeleSign-ruby_telesign_enterprise-cfcf76f/lib/telesignenterprise/omniverify.rb000066400000000000000000000050051515427375200303330ustar00rootroot00000000000000 require 'telesign/rest' require_relative 'constants' PATH_CREATE_VERIFICATION_PROCESS = '/verification' PATH_UPDATE_VERIFICATION_PROCESS = '/verification/%{reference_id}/state' PATH_RETRIEVE_VERIFICATION_PROCESS = '/verification/%{reference_id}' module TelesignEnterprise # The Telesign Verify API makes it easy for you to set up phone-based, multi-factor authentication (MFA) using multiple channels and methods. # See https://developer.telesign.com/enterprise/docs/verify-api-overview for detailed product documentation. class OmniVerifyClient < Telesign::RestClient def initialize(customer_id, api_key, rest_endpoint: 'https://verify.telesign.com', timeout: nil, source: 'ruby_telesign_enterprise', sdk_version_origin: TelesignEnterprise::SDK_VERSION, sdk_version_dependency: Gem.loaded_specs['telesign'].version) super(customer_id, api_key, rest_endpoint: rest_endpoint, timeout: timeout, source: source, sdk_version_origin: sdk_version_origin, sdk_version_dependency: sdk_version_dependency) end # Use this action to create a verification process for the specified phone number. # # See https://developer.telesign.com/enterprise/reference/createverificationprocess for detailed API documentation. def create_verification_process(phone_number, **params) params = params.merge({ recipient: { phone_number: phone_number } }) params[:verification_policy] ||= [{ method: 'sms', fallback_time: 30 }] self.post(PATH_CREATE_VERIFICATION_PROCESS, **params) end # Use this action to retrieve a verification process for the specified reference_id. # # See https://developer.telesign.com/enterprise/reference/getverificationprocess for detailed API documentation. def retrieve_verification_process(reference_id, **params) self.get(PATH_RETRIEVE_VERIFICATION_PROCESS % {:reference_id => reference_id}, **params) end # Use this action to update a verification process for the specified reference_id. # # See https://developer.telesign.com/enterprise/reference/updateverificationprocess for detailed API documentation. def update_verification_process(reference_id, **params) self.patch(PATH_UPDATE_VERIFICATION_PROCESS % {:reference_id => reference_id}, auth_method: 'Basic', **params) end private def content_type "application/json" end end end TeleSign-ruby_telesign_enterprise-cfcf76f/lib/telesignenterprise/phoneid.rb000066400000000000000000000064121515427375200275750ustar00rootroot00000000000000require 'telesign/phoneid' require_relative 'constants' PHONEID_STANDARD_RESOURCE = '/v1/phoneid/standard/%{phone_number}' PHONEID_LIVE_RESOURCE = '/v1/phoneid/live/%{phone_number}' PHONEID_GET_INFO_PATH = '/v1/phoneid/%{phone_number}' PHONEID_GET_INFO_PATH_ALT = '/v1/phoneid' module TelesignEnterprise # A set of APIs that deliver deep phone number data attributes that help optimize the end user # verification process and evaluate risk. # # TeleSign PhoneID provides a wide range of risk assessment indicators on the number to help confirm user identity, # delivering real-time decision making throughout the number lifecycle and ensuring only legitimate users are # creating accounts and accessing your applications. class PhoneIdClient < Telesign::PhoneIdClient def initialize(customer_id, api_key, rest_endpoint: 'https://rest-ww.telesign.com', timeout: nil, source: 'ruby_telesign_enterprise', sdk_version_origin: TelesignEnterprise::SDK_VERSION, sdk_version_dependency: Gem.loaded_specs['telesign'].version) super(customer_id, api_key, rest_endpoint: rest_endpoint, timeout: timeout, source: source, sdk_version_origin: sdk_version_origin, sdk_version_dependency: sdk_version_dependency) end # The PhoneID Standard API that provides phone type and telecom carrier information to identify which phone # numbers can receive SMS messages and/or a potential fraud risk. # # See https://developer.telesign.com/docs/rest_phoneid-standard for detailed API documentation. def standard(phone_number, **params) self.get(PHONEID_STANDARD_RESOURCE % {:phone_number => phone_number}, **params) end # The PhoneID Live API delivers insights such as whether a phone is active or disconnected, a device is reachable # or unreachable and its roaming status. # # See https://developer.telesign.com/docs/rest_api-phoneid-live for detailed API documentation. def live(phone_number, ucid, **params) self.get(PHONEID_LIVE_RESOURCE % {:phone_number => phone_number}, ucid: ucid, **params) end # Enter a phone number with country code to receive detailed information about carrier, location, and other details. # Phone number provided in URL path: POST /v1/phoneid/{phone_number} # # See https://developer.telesign.com/enterprise/reference/submitphonenumberforidentity for detailed API documentation. def phone_id_path(phone_number, **params) params['consent'] ||= { 'method' => 1 } self.post(PHONEID_GET_INFO_PATH % {:phone_number => phone_number}, **params) end # Enter a phone number with country code to receive detailed information about carrier, location, and other details. # Phone number provided in body: POST /v1/phoneid # # See https://developer.telesign.com/enterprise/reference/submitphonenumberforidentityalt for detailed API documentation. def phone_id_body(phone_number, **params) params['phone_number'] = phone_number params['consent'] ||= { 'method' => 1 } self.post(PHONEID_GET_INFO_PATH_ALT, **params) end end end TeleSign-ruby_telesign_enterprise-cfcf76f/lib/telesignenterprise/score.rb000066400000000000000000000015001515427375200272530ustar00rootroot00000000000000require 'telesign' require_relative 'constants' module TelesignEnterprise # Score provides risk information about a specified phone number. class ScoreClient < Telesign::ScoreClient def initialize(customer_id, api_key, rest_endpoint: 'https://detect.telesign.com', timeout: nil, source: 'ruby_telesign_enterprise', sdk_version_origin: TelesignEnterprise::SDK_VERSION, sdk_version_dependency: Gem.loaded_specs['telesign'].version) super(customer_id, api_key, rest_endpoint: rest_endpoint, timeout: timeout, source: source, sdk_version_origin: sdk_version_origin, sdk_version_dependency: sdk_version_dependency) end end endTeleSign-ruby_telesign_enterprise-cfcf76f/lib/telesignenterprise/telebureau.rb000066400000000000000000000040301515427375200302760ustar00rootroot00000000000000require 'telesign/rest' require_relative 'constants' TELEBUREAU_RETRIEVE_RESOURCE = '/v1/telebureau/event/%{reference_id}' TELEBUREAU_DELETE_RESOURCE = '/v1/telebureau/event/%{reference_id}' module TelesignEnterprise # TeleBureau is a service is based on TeleSign's watchlist, which is a proprietary database containing verified phone # numbers of users known to have committed online fraud. TeleSign crowd-sources this information from its customers. # Participation is voluntary, but you have to contribute in order to benefit. class TelebureauClient < Telesign::RestClient def initialize(customer_id, api_key, rest_endpoint: 'https://rest-ww.telesign.com', timeout: nil, source: 'ruby_telesign_enterprise', sdk_version_origin: TelesignEnterprise::SDK_VERSION, sdk_version_dependency: Gem.loaded_specs['telesign'].version) super(customer_id, api_key, rest_endpoint: rest_endpoint, timeout: timeout, source: source, sdk_version_origin: sdk_version_origin, sdk_version_dependency: sdk_version_dependency) end # Retrieves the fraud event status. You make this call in your web application after completion of create # transaction for a telebureau event. # # See https://developer.telesign.com/docs/telebureau-api for detailed API documentation. def retrieve_event(reference_id, **params) self.get(TELEBUREAU_RETRIEVE_RESOURCE % {:reference_id => reference_id}, **params) end # Deletes a previously submitted fraud event. You make this call in your web application after completion of the # create transaction for a telebureau event. # # See https://developer.telesign.com/docs/telebureau-api for detailed API documentation. def delete_event(reference_id, **params) self.delete(TELEBUREAU_DELETE_RESOURCE % {:reference_id => reference_id}, **params) end end end TeleSign-ruby_telesign_enterprise-cfcf76f/lib/telesignenterprise/verify.rb000066400000000000000000000075301515427375200274550ustar00rootroot00000000000000require 'telesign/rest' require_relative 'omniverify' require_relative 'constants' VERIFY_SMS_RESOURCE = '/v1/verify/sms' VERIFY_VOICE_RESOURCE = '/v1/verify/call' VERIFY_SMART_RESOURCE = '/v1/verify/smart' VERIFY_STATUS_RESOURCE = '/v1/verify/%{reference_id}' VERIFY_COMPLETION_RESOURCE = '/v1/verify/completion/%{reference_id}' VERIFY_OMNICHANNEL_RESOURCE = '/verification' module TelesignEnterprise # The Verify API delivers phone-based verification and two-factor authentication using a time-based, one-time passcode # sent via SMS message and Voice call. class VerifyClient < Telesign::RestClient def initialize(customer_id, api_key, rest_endpoint: 'https://rest-ww.telesign.com', timeout: nil, source: 'ruby_telesign_enterprise', sdk_version_origin: TelesignEnterprise::SDK_VERSION, sdk_version_dependency: Gem.loaded_specs['telesign'].version, rest_endpoint_verify: 'https://verify.telesign.com') @omniVerifyClient = OmniVerifyClient.new(customer_id, api_key, rest_endpoint: rest_endpoint_verify) super(customer_id, api_key, rest_endpoint: rest_endpoint, timeout: timeout, source: source, sdk_version_origin: sdk_version_origin, sdk_version_dependency: sdk_version_dependency) end # The SMS Verify API delivers phone-based verification and two-factor authentication using a time-based, # one-time passcode sent over SMS. # # See https://developer.telesign.com/docs/rest_api-verify-sms for detailed API documentation. def sms(phone_number, **params) self.post(VERIFY_SMS_RESOURCE, phone_number: phone_number, **params) end # The Voice Verify API delivers patented phone-based verification and two-factor authentication using a one-time # passcode sent over voice message. # # See https://developer.telesign.com/docs/rest_api-verify-call for detailed API documentation. def voice(phone_number, **params) self.post(VERIFY_VOICE_RESOURCE, phone_number: phone_number, **params) end # The Smart Verify web service simplifies the process of verifying user identity by integrating several TeleSign # web services into a single API call. This eliminates the need for you to make multiple calls to the TeleSign # Verify resource. # # See https://developer.telesign.com/docs/rest_api-smart-verify for detailed API documentation. def smart(phone_number, ucid, **params) self.post(VERIFY_SMART_RESOURCE, phone_number: phone_number, ucid: ucid, **params) end # Retrieves the verification result for any verify resource. # # See https://developer.telesign.com/docs/rest_api-verify-transaction-callback for detailed API documentation. def status(reference_id, **params) self.get(VERIFY_STATUS_RESOURCE % {:reference_id => reference_id}, **params) end # Notifies TeleSign that a verification was successfully delivered to the user in order to help improve the # quality of message delivery routes. # # See https://developer.telesign.com/docs/completion-service-for-verify-products for detailed API documentation. def completion(reference_id, **params) self.put(VERIFY_COMPLETION_RESOURCE % {:reference_id => reference_id}, **params) end # Use this action to create a verification process for the specified phone number. # # See https://developer.telesign.com/enterprise/reference/createverificationprocess for detailed API documentation. def create_verification_process(phone_number, **params) @omniVerifyClient.create_verification_process(phone_number, **params) end end end TeleSign-ruby_telesign_enterprise-cfcf76f/lib/telesignenterprise/voice.rb000066400000000000000000000017161515427375200272560ustar00rootroot00000000000000require 'telesign' require_relative 'constants' module TelesignEnterprise # TeleSign's Voice API allows you to easily send voice messages. You can send alerts, reminders, and notifications, # or you can send verification messages containing time-based, one-time passcodes (TOTP). class VoiceClient < Telesign::VoiceClient def initialize(customer_id, api_key, rest_endpoint: 'https://rest-ww.telesign.com', timeout: nil, source: 'ruby_telesign_enterprise', sdk_version_origin: TelesignEnterprise::SDK_VERSION, sdk_version_dependency: Gem.loaded_specs['telesign'].version) super(customer_id, api_key, rest_endpoint: rest_endpoint, timeout: timeout, source: source, sdk_version_origin: sdk_version_origin, sdk_version_dependency: sdk_version_dependency) end end endTeleSign-ruby_telesign_enterprise-cfcf76f/telesignenterprise.gemspec000066400000000000000000000020431515427375200264150ustar00rootroot00000000000000require_relative 'lib/telesignenterprise/constants' Gem::Specification.new do |s| s.name = 'telesignenterprise' s.version = TelesignEnterprise::SDK_VERSION s.add_runtime_dependency 'telesign', '~> 4.0.1' s.licenses = ['MIT'] s.date = '2017-05-02' s.summary = 'TeleSign Enterprise Ruby SDK' s.description = 'TeleSign Enterprise Ruby SDK' s.authors = ['TeleSign'] s.email = 'support@telesign.com' s.files = Dir['lib/**/*rb'] s.homepage = 'http://rubygems.org/gems/telesign' s.add_runtime_dependency 'base64' s.add_development_dependency 'rake', '~> 13.2' s.add_development_dependency 'uuid', '~> 2.3' s.add_development_dependency 'mocha', '~> 2.7' s.add_development_dependency 'webmock', '~> 3.24' s.add_development_dependency 'codecov', '~> 0.6.0' s.add_development_dependency 'simplecov', '~> 0.22.0' s.add_development_dependency 'test-unit', '~> 3.6' end TeleSign-ruby_telesign_enterprise-cfcf76f/test/000077500000000000000000000000001515427375200221155ustar00rootroot00000000000000TeleSign-ruby_telesign_enterprise-cfcf76f/test/test_rest.rb000066400000000000000000000452661515427375200244730ustar00rootroot00000000000000require 'uuid' require 'time' require 'test/unit' require 'webmock/test_unit' require 'telesignenterprise' class TestRest < Test::Unit::TestCase def setup @customer_id = 'FFFFFFFF-EEEE-DDDD-1234-AB1234567890' @api_key = 'ABC12345yusumoN6BYsBVkh+yRJ5czgsnCehZaOYldPJdmFh6NeX8kunZ2zU1YWaUw/0wV6xfw==' @phone_number = '1234567890' @reference_id = '0123456789ABCDEF0123456789ABCDEF' @account_lifecycle_event = 'create' @score_client = TelesignEnterprise::ScoreClient.new(@customer_id, @api_key, rest_endpoint: 'https://detect.telesign.com') end def test_phoneid_standard stub_request(:get, "localhost/v1/phoneid/standard/#{@phone_number}").to_return(body: '{}') client = TelesignEnterprise::PhoneIdClient.new(@customer_id, @api_key, rest_endpoint: 'http://localhost') client.standard(@phone_number) assert_requested :get, "http://localhost/v1/phoneid/standard/#{@phone_number}" assert_requested :get, "http://localhost/v1/phoneid/standard/#{@phone_number}", body: '' assert_not_requested :get, "http://localhost/v1/phoneid/standard/#{@phone_number}", headers: {'Content-Type' => /.*\S.*/} assert_requested :get, "http://localhost/v1/phoneid/standard/#{@phone_number}", headers: {'x-ts-auth-method' => 'HMAC-SHA256'} assert_requested :get, "http://localhost/v1/phoneid/standard/#{@phone_number}", headers: {'x-ts-nonce' => /.*\S.*/} assert_requested :get, "http://localhost/v1/phoneid/standard/#{@phone_number}", headers: {'Date' => /.*\S.*/} end def test_score_success stub_request(:post, "https://detect.telesign.com/intelligence/phone") .with( body: hash_including({ 'phone_number' => @phone_number, 'account_lifecycle_event' => @account_lifecycle_event }), headers: { 'Content-Type' => 'application/x-www-form-urlencoded' } ) .to_return( status: 200, body: '{"risk": {"level": "low", "recommendation": "allow"}}', headers: { 'Content-Type' => 'application/json' } ) response = @score_client.score(@phone_number, @account_lifecycle_event) puts "Response status code: #{response.status_code}" puts "Response headers: #{response.headers}" puts "Response body: #{response.body}" puts "Parsed JSON response: #{response.json}" assert response.ok assert_equal 'low', response.json['risk']['level'] assert_equal 'allow', response.json['risk']['recommendation'] assert_requested :post, "https://detect.telesign.com/intelligence/phone" assert_requested :post, "https://detect.telesign.com/intelligence/phone", body: hash_including({ 'phone_number' => @phone_number, 'account_lifecycle_event' => @account_lifecycle_event }) assert_requested :post, "https://detect.telesign.com/intelligence/phone", headers: {'Content-Type' => 'application/x-www-form-urlencoded'} assert_requested :post, "https://detect.telesign.com/intelligence/phone", headers: {'x-ts-auth-method' => 'HMAC-SHA256'} assert_requested :post, "https://detect.telesign.com/intelligence/phone", headers: {'x-ts-nonce' => /.*\S.*/} assert_requested :post, "https://detect.telesign.com/intelligence/phone", headers: {'Date' => /.*\S.*/} end def test_messaging stub_request(:post, 'localhost/v1/messaging').to_return(body: '{}') client = TelesignEnterprise::MessagingClient.new(@customer_id, @api_key, rest_endpoint: 'http://localhost') client.message(@phone_number, 'Test Message', 'ARN') assert_requested :post, "http://localhost/v1/messaging" assert_requested :post, "http://localhost/v1/messaging", body: "phone_number=#{@phone_number}&message=Test+Message&message_type=ARN" assert_requested :post, "http://localhost/v1/messaging", headers: {'Content-Type' => 'application/x-www-form-urlencoded'} assert_requested :post, "http://localhost/v1/messaging", headers: {'x-ts-auth-method' => 'HMAC-SHA256'} assert_requested :post, "http://localhost/v1/messaging", headers: {'x-ts-nonce' => /.*\S.*/} assert_requested :post, "http://localhost/v1/messaging", headers: {'Date' => /.*\S.*/} end def test_messaging_omnichannel stub_request(:post, 'localhost/v1/omnichannel').to_return(body: '{}') client = TelesignEnterprise::MessagingClient.new(@customer_id, @api_key, rest_endpoint: 'http://localhost') params = {message: { sms: { template: 'text', parameters: { text: 'Test Message'} } }, recipient: { phone_number: @phone_number }, 'channels'=>[{channel: 'sms', fallback_time: 300 }], message_type: 'ARN' } client.omni_message(**params) assert_requested :post, "http://localhost/v1/omnichannel" assert_requested :post, "http://localhost/v1/omnichannel", body: '{"message":{"sms":{"template":"text","parameters":{"text":"Test Message"}}},"recipient":{"phone_number":"1234567890"},"channels":[{"channel":"sms","fallback_time":300}],"message_type":"ARN"}' assert_requested :post, "http://localhost/v1/omnichannel", headers: {'Content-Type' => 'application/json'} assert_requested :post, "http://localhost/v1/omnichannel", headers: {'x-ts-auth-method' => 'HMAC-SHA256'} assert_requested :post, "http://localhost/v1/omnichannel", headers: {'x-ts-nonce' => /.*\S.*/} assert_requested :post, "http://localhost/v1/omnichannel", headers: {'Date' => /.*\S.*/} end def test_messaging_status stub_request(:get, 'localhost/v1/messaging/REFERENCE_ID').to_return(body: '{}') client = TelesignEnterprise::MessagingClient.new(@customer_id, @api_key, rest_endpoint: 'http://localhost') client.status('REFERENCE_ID') assert_requested :get, "http://localhost/v1/messaging/REFERENCE_ID" assert_requested :get, "http://localhost/v1/messaging/REFERENCE_ID", headers: {'x-ts-auth-method' => 'HMAC-SHA256'} assert_requested :get, "http://localhost/v1/messaging/REFERENCE_ID", headers: {'x-ts-nonce' => /.*\S.*/} assert_requested :get, "http://localhost/v1/messaging/REFERENCE_ID", headers: {'Date' => /.*\S.*/} end def test_voice stub_request(:post, 'localhost/v1/voice').to_return(body: '{}') client = TelesignEnterprise::VoiceClient.new(@customer_id, @api_key, rest_endpoint: 'http://localhost') client.call(@phone_number, 'Test Message', 'ARN') assert_requested :post, "http://localhost/v1/voice" assert_requested :post, "http://localhost/v1/voice", body: "phone_number=#{@phone_number}&message=Test+Message&message_type=ARN" assert_requested :post, "http://localhost/v1/voice", headers: {'Content-Type' => 'application/x-www-form-urlencoded'} assert_requested :post, "http://localhost/v1/voice", headers: {'x-ts-auth-method' => 'HMAC-SHA256'} assert_requested :post, "http://localhost/v1/voice", headers: {'x-ts-nonce' => /.*\S.*/} assert_requested :post, "http://localhost/v1/voice", headers: {'Date' => /.*\S.*/} end def test_voice_status stub_request(:get, 'localhost/v1/voice/REFERENCE_ID').to_return(body: '{}') client = TelesignEnterprise::VoiceClient.new(@customer_id, @api_key, rest_endpoint: 'http://localhost') client.status('REFERENCE_ID') assert_requested :get, "http://localhost/v1/voice/REFERENCE_ID" assert_requested :get, "http://localhost/v1/voice/REFERENCE_ID", headers: {'x-ts-auth-method' => 'HMAC-SHA256'} assert_requested :get, "http://localhost/v1/voice/REFERENCE_ID", headers: {'x-ts-nonce' => /.*\S.*/} assert_requested :get, "http://localhost/v1/voice/REFERENCE_ID", headers: {'Date' => /.*\S.*/} end def test_verify_status_with_verify_code stub_request(:get, 'localhost/v1/verify/REFERENCE_ID?verify_code=12345').to_return(body: '{}') client = TelesignEnterprise::VerifyClient.new(@customer_id, @api_key, rest_endpoint: 'http://localhost') client.status('REFERENCE_ID', verify_code: '12345') assert_requested :get, "http://localhost/v1/verify/REFERENCE_ID?verify_code=12345" assert_requested :get, "http://localhost/v1/verify/REFERENCE_ID?verify_code=12345", headers: {'x-ts-auth-method' => 'HMAC-SHA256'} assert_requested :get, "http://localhost/v1/verify/REFERENCE_ID?verify_code=12345", headers: {'x-ts-nonce' => /.*\S.*/} assert_requested :get, "http://localhost/v1/verify/REFERENCE_ID?verify_code=12345", headers: {'Date' => /.*\S.*/} end def test_create_verification_process stub_request(:post, 'localhost/verification').to_return(body: '{}') client = TelesignEnterprise::VerifyClient.new(@customer_id, @api_key, rest_endpoint: 'http://localhost', rest_endpoint_verify: 'http://localhost') client.create_verification_process(@phone_number) assert_requested :post, "http://localhost/verification" assert_requested :post, "http://localhost/verification", body: '{"recipient":{"phone_number":"1234567890"},"verification_policy":[{"method":"sms","fallback_time":30}]}' assert_requested :post, "http://localhost/verification", headers: {'Content-Type' => 'application/json'} assert_requested :post, "http://localhost/verification", headers: {'x-ts-auth-method' => 'HMAC-SHA256'} assert_requested :post, "http://localhost/verification", headers: {'x-ts-nonce' => /.*\S.*/} assert_requested :post, "http://localhost/verification", headers: {'Date' => /.*\S.*/} end def test_retrieve_verification_process stub_request(:get, "localhost/verification/#{@reference_id}").to_return(body: '{}') client = TelesignEnterprise::OmniVerifyClient.new(@customer_id, @api_key, rest_endpoint: 'http://localhost') client.retrieve_verification_process(@reference_id) assert_requested :get, "localhost/verification/#{@reference_id}" assert_requested :get, "localhost/verification/#{@reference_id}", headers: {'x-ts-auth-method' => 'HMAC-SHA256'} assert_requested :get, "localhost/verification/#{@reference_id}", headers: {'x-ts-nonce' => /.*\S.*/} assert_requested :get, "localhost/verification/#{@reference_id}", headers: {'Date' => /.*\S.*/} end def test_update_verification_process stub_request(:patch, "localhost/verification/#{@reference_id}").to_return(body: '{}') stub_request(:patch, "localhost/verification/#{@reference_id}/state").to_return(body: '{}') client = TelesignEnterprise::OmniVerifyClient.new(@customer_id, @api_key, rest_endpoint: 'http://localhost') params = { action: 'finalize', security_factor: '123456' } client.update_verification_process(@reference_id, **params) assert_requested :patch, "localhost/verification/#{@reference_id}/state" assert_requested :patch, "localhost/verification/#{@reference_id}/state", headers: {'x-ts-auth-method' => 'Basic'} assert_requested :patch, "localhost/verification/#{@reference_id}/state", headers: {'x-ts-nonce' => /.*\S.*/} assert_requested :patch, "localhost/verification/#{@reference_id}/state", headers: {'Date' => /.*\S.*/} end def test_phone_id_path stub_request(:post, "localhost/v1/phoneid/#{@phone_number}").to_return(body: '{}') client = TelesignEnterprise::PhoneIdClient.new(@customer_id, @api_key, rest_endpoint: 'http://localhost') client.phone_id_path(@phone_number) assert_requested :post, "http://localhost/v1/phoneid/#{@phone_number}" assert_requested :post, "http://localhost/v1/phoneid/#{@phone_number}", headers: {'Content-Type' => 'application/json'} assert_requested :post, "http://localhost/v1/phoneid/#{@phone_number}", headers: {'x-ts-auth-method' => 'HMAC-SHA256'} assert_requested :post, "http://localhost/v1/phoneid/#{@phone_number}", headers: {'x-ts-nonce' => /.*\S.*/} assert_requested :post, "http://localhost/v1/phoneid/#{@phone_number}", headers: {'Date' => /.*\S.*/} end def test_phone_id_body stub_request(:post, "localhost/v1/phoneid").to_return(body: '{}') client = TelesignEnterprise::PhoneIdClient.new(@customer_id, @api_key, rest_endpoint: 'http://localhost') client.phone_id_body(@phone_number) assert_requested :post, "http://localhost/v1/phoneid" assert_requested :post, "http://localhost/v1/phoneid", headers: {'Content-Type' => 'application/json'} assert_requested :post, "http://localhost/v1/phoneid", headers: {'x-ts-auth-method' => 'HMAC-SHA256'} assert_requested :post, "http://localhost/v1/phoneid", headers: {'x-ts-nonce' => /.*\S.*/} assert_requested :post, "http://localhost/v1/phoneid", headers: {'Date' => /.*\S.*/} end def test_app_verify_initiate stub_request(:post, "localhost/v1/verify/auto/voice/initiate").to_return(body: '{}') client = TelesignEnterprise::AppVerifyClient.new(@customer_id, @api_key, rest_endpoint: 'http://localhost') client.initiate(@phone_number) assert_requested :post, "http://localhost/v1/verify/auto/voice/initiate" assert_requested :post, "http://localhost/v1/verify/auto/voice/initiate", body: "phone_number=#{@phone_number}" assert_requested :post, "http://localhost/v1/verify/auto/voice/initiate", headers: {'Content-Type' => 'application/x-www-form-urlencoded'} assert_requested :post, "http://localhost/v1/verify/auto/voice/initiate", headers: {'x-ts-auth-method' => 'HMAC-SHA256'} assert_requested :post, "http://localhost/v1/verify/auto/voice/initiate", headers: {'x-ts-nonce' => /.*\S.*/} assert_requested :post, "http://localhost/v1/verify/auto/voice/initiate", headers: {'Date' => /.*\S.*/} end def test_app_verify_finalize stub_request(:post, "localhost/v1/verify/auto/voice/finalize").to_return(body: '{}') client = TelesignEnterprise::AppVerifyClient.new(@customer_id, @api_key, rest_endpoint: 'http://localhost') client.finalize(@reference_id) assert_requested :post, "http://localhost/v1/verify/auto/voice/finalize" assert_requested :post, "http://localhost/v1/verify/auto/voice/finalize", body: "reference_id=#{@reference_id}" assert_requested :post, "http://localhost/v1/verify/auto/voice/finalize", headers: {'Content-Type' => 'application/x-www-form-urlencoded'} assert_requested :post, "http://localhost/v1/verify/auto/voice/finalize", headers: {'x-ts-auth-method' => 'HMAC-SHA256'} assert_requested :post, "http://localhost/v1/verify/auto/voice/finalize", headers: {'x-ts-nonce' => /.*\S.*/} assert_requested :post, "http://localhost/v1/verify/auto/voice/finalize", headers: {'Date' => /.*\S.*/} end def test_app_verify_report_unknown_caller_id stub_request(:post, "localhost/v1/verify/auto/voice/finalize/callerid").to_return(body: '{}') client = TelesignEnterprise::AppVerifyClient.new(@customer_id, @api_key, rest_endpoint: 'http://localhost') unknown_caller_id = "15551234567" client.report_unknown_caller_id(@reference_id, unknown_caller_id) assert_requested :post, "http://localhost/v1/verify/auto/voice/finalize/callerid" assert_requested :post, "http://localhost/v1/verify/auto/voice/finalize/callerid", body: "reference_id=#{@reference_id}&unknown_caller_id=#{unknown_caller_id}" assert_requested :post, "http://localhost/v1/verify/auto/voice/finalize/callerid", headers: {'Content-Type' => 'application/x-www-form-urlencoded'} assert_requested :post, "http://localhost/v1/verify/auto/voice/finalize/callerid", headers: {'x-ts-auth-method' => 'HMAC-SHA256'} assert_requested :post, "http://localhost/v1/verify/auto/voice/finalize/callerid", headers: {'x-ts-nonce' => /.*\S.*/} assert_requested :post, "http://localhost/v1/verify/auto/voice/finalize/callerid", headers: {'Date' => /.*\S.*/} end def test_app_verify_report_timeout stub_request(:post, "localhost/v1/verify/auto/voice/finalize/timeout").to_return(body: '{}') client = TelesignEnterprise::AppVerifyClient.new(@customer_id, @api_key, rest_endpoint: 'http://localhost') client.report_timeout(@reference_id) assert_requested :post, "http://localhost/v1/verify/auto/voice/finalize/timeout" assert_requested :post, "http://localhost/v1/verify/auto/voice/finalize/timeout", body: "reference_id=#{@reference_id}" assert_requested :post, "http://localhost/v1/verify/auto/voice/finalize/timeout", headers: {'Content-Type' => 'application/x-www-form-urlencoded'} assert_requested :post, "http://localhost/v1/verify/auto/voice/finalize/timeout", headers: {'x-ts-auth-method' => 'HMAC-SHA256'} assert_requested :post, "http://localhost/v1/verify/auto/voice/finalize/timeout", headers: {'x-ts-nonce' => /.*\S.*/} assert_requested :post, "http://localhost/v1/verify/auto/voice/finalize/timeout", headers: {'Date' => /.*\S.*/} end def test_app_verify_get_transaction_status stub_request(:get, "localhost/v1/verify/auto/voice/#{@reference_id}").to_return(body: '{}') client = TelesignEnterprise::AppVerifyClient.new(@customer_id, @api_key, rest_endpoint: 'http://localhost') client.get_transaction_status(@reference_id) assert_requested :get, "http://localhost/v1/verify/auto/voice/#{@reference_id}" assert_not_requested :get, "http://localhost/v1/verify/auto/voice/#{@reference_id}", headers: {'Content-Type' => /.*\S.*/} assert_requested :get, "http://localhost/v1/verify/auto/voice/#{@reference_id}", headers: {'x-ts-auth-method' => 'HMAC-SHA256'} assert_requested :get, "http://localhost/v1/verify/auto/voice/#{@reference_id}", headers: {'x-ts-nonce' => /.*\S.*/} assert_requested :get, "http://localhost/v1/verify/auto/voice/#{@reference_id}", headers: {'Date' => /.*\S.*/} end end