From 04a873ba8c8dd49d7af4e9e8e46dbfdaf1fffd17 Mon Sep 17 00:00:00 2001 From: Michael Date: Mon, 1 Apr 2024 13:37:46 -0400 Subject: [PATCH] Updated RuboCop Rules (#67) * standardize rubocop rules * lint * lint * fix tests * sort config * update changelog * update rubocop * remove new rules * downgrade rubocop-ast * revert changes to GemFile --- .rubocop.yml | 189 +++++++++++++++- CHANGELOG.md | 120 +++++----- examples/aml_check.rb | 2 +- examples/biometric_kyc.rb | 12 +- examples/business_verification.rb | 4 +- examples/document_verification.rb | 16 +- examples/enhanced_document_verification.rb | 16 +- examples/enhanced_kyc.rb | 6 +- examples/example-project/smart_bank.rb | 45 ++-- examples/get_web_token.rb | 2 +- examples/smart_selfie_authentication.rb | 10 +- lib/smile-identity-core/aml_check.rb | 4 +- .../business_verification.rb | 2 +- lib/smile-identity-core/constants/env.rb | 8 +- lib/smile-identity-core/id_api.rb | 22 +- lib/smile-identity-core/signature.rb | 2 +- lib/smile-identity-core/utilities.rb | 10 +- lib/smile-identity-core/validations.rb | 4 +- lib/smile-identity-core/web_api.rb | 90 ++++---- smile-identity-core.gemspec | 21 +- spec/smile-identity-core/aml_check_spec.rb | 214 +++++++++--------- .../business_verification_spec.rb | 196 ++++++++-------- .../smile-identity-core/constants/env_spec.rb | 4 +- spec/smile-identity-core/id_api_spec.rb | 60 ++--- spec/smile-identity-core/signature_spec.rb | 6 +- .../smile_identity_core_spec.rb | 6 +- spec/smile-identity-core/utilities_spec.rb | 8 +- spec/smile-identity-core/web_api_spec.rb | 146 ++++++------ 28 files changed, 706 insertions(+), 519 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 75816d5..e907861 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,9 +1,149 @@ +--- + require: - - rubocop-rake - - rubocop-rspec +- rubocop-rake +- rubocop-rspec AllCops: - TargetRubyVersion: 2.5 + TargetRubyVersion: 2.6 + NewCops: enable + +Bundler/DuplicatedGem: + Enabled: true + +Bundler/GemFilename: + Enabled: true + +Layout/ArgumentAlignment: + Enabled: true + EnforcedStyle: with_fixed_indentation + +Layout/ArrayAlignment: + Enabled: true + +Layout/AssignmentIndentation: + Enabled: true + +Layout/BlockAlignment: + Enabled: true + +Layout/CaseIndentation: + Enabled: true + +Layout/ConditionPosition: + Enabled: true + +Layout/ElseAlignment: + Enabled: true + +Layout/EmptyLineAfterGuardClause: + Enabled: true + +Layout/EmptyLineAfterMagicComment: + Enabled: true + +Layout/EmptyLinesAroundBlockBody: + Enabled: true + +Layout/EmptyLinesAroundClassBody: + Enabled: true + +Layout/EmptyLinesAroundModuleBody: + Enabled: true + +Layout/EndAlignment: + Enabled: true + +Layout/EndOfLine: + Enabled: true + +Layout/ExtraSpacing: + Enabled: true + ForceEqualSignAlignment: false + AllowForAlignment: false + +Layout/FirstArgumentIndentation: + Enabled: true + EnforcedStyle: consistent + +Layout/FirstArrayElementIndentation: + Enabled: true + EnforcedStyle: consistent + +Layout/FirstHashElementIndentation: + Enabled: true + EnforcedStyle: consistent + +Layout/HashAlignment: + Enabled: true + +Layout/IndentationConsistency: + Enabled: true + +Layout/IndentationStyle: + Enabled: true + +Layout/IndentationWidth: + Enabled: true + +Layout/LeadingEmptyLines: + Enabled: true + +Layout/MultilineBlockLayout: + Enabled: true + +Layout/MultilineMethodCallIndentation: + Enabled: true + EnforcedStyle: indented + +Layout/MultilineOperationIndentation: + Enabled: true + EnforcedStyle: indented + +Layout/ParameterAlignment: + Enabled: true + +Layout/SpaceAfterComma: + Enabled: true + +Layout/SpaceAroundKeyword: + Enabled: true + +Layout/SpaceAroundOperators: + Enabled: true + +Layout/SpaceBeforeBlockBraces: + Enabled: true + +Layout/SpaceBeforeFirstArg: + Enabled: true + +Layout/SpaceInsideBlockBraces: + Enabled: true + +Layout/SpaceInsideParens: + Enabled: true + +Layout/TrailingEmptyLines: + Enabled: true + +Layout/TrailingWhitespace: + Enabled: true + +Lint/AmbiguousAssignment: + Enabled: true + +Lint/AmbiguousBlockAssociation: + Enabled: true + +Lint/AmbiguousOperator: + Enabled: true + +Lint/AmbiguousRange: + Enabled: true + +Lint/DuplicateElsifCondition: + Enabled: true Metrics/AbcSize: Max: 30 @@ -24,7 +164,8 @@ Naming/FileName: Enabled: false RSpec/ExampleLength: - Enabled: false + Enabled: true + Max: 150 RSpec/FilePath: Enabled: false @@ -33,13 +174,45 @@ RSpec/InstanceVariable: Enabled: false RSpec/MultipleExpectations: - Enabled: false + Enabled: true + Max: 10 RSpec/MultipleMemoizedHelpers: Enabled: false - + RSpec/NestedGroups: - Enabled: false + Enabled: true + Max: 4 -RSpec/RepeatedExampleGroupDescription: +RSpec/NoExpectationExample: Enabled: false + +Style/RedundantBegin: + Enabled: true + +Style/RedundantCondition: + Enabled: true + +Style/RedundantInterpolation: + Enabled: true + +Style/RedundantParentheses: + Enabled: true + +Style/RedundantReturn: + Enabled: true + +Style/StringLiterals: + Enabled: true + +Style/TrailingCommaInArguments: + Enabled: true + EnforcedStyleForMultiline: comma + +Style/TrailingCommaInArrayLiteral: + Enabled: true + EnforcedStyleForMultiline: comma + +Style/TrailingCommaInHashLiteral: + Enabled: true + EnforcedStyleForMultiline: comma diff --git a/CHANGELOG.md b/CHANGELOG.md index 7b026d6..bbef786 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,125 +1,133 @@ # Changelog All notable changes to this project will be documented in this file. -The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -## [2.2.3] - 2023-10-20 -## Added -- Adds support for Enhanced Document Verification - ## [Unreleased] +### Changed +- Linted the project with internal RuboCop rules + +### Fixed +- Removed support for Ruby 2.5 in RuboCop configuration and the gemspec file + +## [2.2.3] - 2023-10-20 +### Added +- Support for Enhanced Document Verification ## [2.2.2] - 2023-10-05 ### Changed -- Lint project. Enforce rubocop rules via github action +- Lint project. Enforce RuboCop rules via GitHub action -## Added -Support Ruby 3.2 +### Added +- Support for Ruby 3.2 ## [2.2.1] - 2023-08-31 ### Changed -- Don't validate the presence of `id_type` and `id_number` for Document Verification jobs +- Removed the validation of `id_type` and `id_number` for Document Verification jobs ## [2.2.0] - 2023-04-05 ### Added -- Adds support for AML check +- Support for AML check + ### Changed -- Fix business verification docstrings +- Fixed business verification docstrings ## [2.1.2] - 2023-03-09 ### Changed -- Fix `get_web_token` by ensuring signature merges to request_params +- Fixed `get_web_token` by ensuring signature merges into request_params ## [2.1.1] - 2022-12-13 ### Added -- Adds UPDATE_PHOTO and COMPARE_USER_INFO to JobType +- UPDATE_PHOTO and COMPARE_USER_INFO to JobType + ### Changed -- Fix wrong constant values for JobType SMART_SELFIE_AUTHENTICATION and SMART_SELFIE_REGISTRATION +- Fixed incorrect constant values for JobType SMART_SELFIE_AUTHENTICATION and SMART_SELFIE_REGISTRATION -# [2.1.0] - 2022-10-28 -## Changed +## [2.1.0] - 2022-10-28 +### Changed - Moved Business verification to IDApi -# [2.0.0] - 2022-10-24 +## [2.0.0] - 2022-10-24 ### Added -- build: Adds support for ruby 3.1 -- docs: adds "examples" folder -- Adds Business Verification product +- Support for Ruby 3.1 +- "Examples" folder in documentation +- Business Verification product ### Changed -- ci: Move from TravisCI to Github Actions -- core: Enforces the use of signature on all API calls -- core: Adds helper constants SMILE_IDENTITY_CORE::ENV, SMILE_IDENTITY_CORE::ImageType, SMILE_IDENTITY_CORE::JobType -- Fixes invalid links in gemspec +- Transition from TravisCI to GitHub Actions +- Enforced the use of signature on all API calls +- Added helper constants SMILE_IDENTITY_CORE::ENV, SMILE_IDENTITY_CORE::ImageType, SMILE_IDENTITY_CORE::JobType +- Fixed invalid links in gemspec ### Removed -- build: Drops support for ruby 2.5.1 -- core: Removes support for `sec_key` as an authentication method - +- Support for Ruby 2.5.1 +- `sec_key` as an authentication method + ## [1.2.1] - 2021-12-02 ### Changed -- Revert changes to version SmileIdentityCore.version_as_hash -- Uses hard coded apiVersion +- Reverted changes to version SmileIdentityCore.version_as_hash +- Used hardcoded apiVersion ## [1.2.0] - 2021-10-08 ### Added -- Add Signature option for signing requests +- Signature option for signing requests ## [1.1.0] - 2021-09-29 -Set version information from SmileIdentityCore.version_as_hash -- Change the urls for both test and prod aa55a72d10854f05a35db4dad3ea63930e8996f6 +### Added +- Version information from SmileIdentityCore.version_as_hash +- Changed URLs for both test and production environments ## [1.0.2] - 2020-01-16 -Add {"success":true,"smile_job_id":"job_id"} to the response when we poll job status too +### Added +- {"success":true,"smile_job_id":"job_id"} to the response when polling job status ## [1.0.1] - 2019-10-24 -## Updated -Remove first_name and last_name validations from id information in Web Api -Add country, id_number and id_type validations for id information in ID Api +### Updated +- Removed first_name and last_name validations from ID information in Web API +- Added country, id_number, and id_type validations for ID information in ID API ## [1.0.0] - 2019-10-11 -## Updated -Amend the success response when job status is false to be a JSON String containing {"success":true,"smile_job_id":"job_id"} -Add the ID API Class -Add the ability to query ID Api from the Web API class -Update the documentation +### Updated +- Amended the success response when job status is false to be a JSON String containing {"success":true,"smile_job_id":"job_id"} +- Added the ID API Class +- Added the ability to query ID API from the Web API class +- Updated the documentation ## [0.2.3] - 2019-09-17 ### Changed -- Lenient Decoding of the api key +- Lenient decoding of the API key ## [0.2.2] - 2019-09-17 ### Added -- Add the language to the package information +- Language to the package information ## [0.2.1] - 2019-09-05 - ### Added -- Accept more formats as inputs -- Use the signature class in the Web API class -- Add a Utilities class with get_job_status that we use internally to expose a public get_job_status method on WebApi +- Support for additional formats as inputs +- Usage of the signature class in the Web API class +- Utilities class with a public `get_job_status` method on WebApi ### Updated -- Updates to the readme -- Update some error messages +- Readme updates +- Updated some error messages ### Fixed -- Fix the loss of optional_callback -- Ensure that we allow nil inputs or empty hashes for options and id_info -- Confirm the signature when querying the job status +- Issue with the loss of optional_callback +- Ensured allowance for nil inputs or empty hashes for options and id_info +- Confirmation of signature when querying job status ## [0.2.0] - 2019-08-14 ### Added -- Introduced return_history and image_links +- Return_history and image_links features ### Removed -- Removed two parameters: optional_callback and return_job_status in the submit_job function in favour of an options hash. +- Two parameters: optional_callback and return_job_status in the submit_job function in favor of an options hash ## [0.1.1] - 2019-07-23 ### Added -- Some package configurations were added. +- Additional package configurations ## [0.1.0] - 2019-07-19 ### Added -- The first release version of Web Api. +- The first release version of Web API diff --git a/examples/aml_check.rb b/examples/aml_check.rb index 5b65570..be68b00 100644 --- a/examples/aml_check.rb +++ b/examples/aml_check.rb @@ -18,7 +18,7 @@ full_name: 'John Leo Doe', countries: ['US'], birth_year: '1984', # yyyy - search_existing_user: false + search_existing_user: false, } # Submit the job diff --git a/examples/biometric_kyc.rb b/examples/biometric_kyc.rb index 1a56a05..d9ba790 100644 --- a/examples/biometric_kyc.rb +++ b/examples/biometric_kyc.rb @@ -17,7 +17,7 @@ partner_params = { user_id: '', job_id: '', - job_type: 1 + job_type: 1, } # Create image list @@ -29,13 +29,13 @@ image_details = [ { image_type_id: '<0 | 2>', - image: '' + image: '', }, { # Not required if you don't require proof of life (note photo of # photo check will still be performed on the uploaded selfie) image_type_id: '<4 | 6>', - image: '' - } + image: '', + }, ] # Create ID number info @@ -46,7 +46,7 @@ id_type: '', id_number: '', dob: '', # yyyy-mm-dd - entered: 'true' # must be a string + entered: 'true', # must be a string } # Set options for the job @@ -60,7 +60,7 @@ # Set to true to receive links to the selfie and the photo # it was compared to. You must set return_job_status to true to use this flag. return_image_links: '', - signature: true + signature: true, } # Submit the job diff --git a/examples/business_verification.rb b/examples/business_verification.rb index 04ba659..6f7e099 100644 --- a/examples/business_verification.rb +++ b/examples/business_verification.rb @@ -17,7 +17,7 @@ partner_params = { job_id: '', user_id: '', - job_type: SmileIdentityCore::JobType::BUSINESS_VERIFICATION + job_type: SmileIdentityCore::JobType::BUSINESS_VERIFICATION, } # Create ID info @@ -35,7 +35,7 @@ # Postal address of business. Only Required for BUSINESS_REGISTRATION in Kenya postal_address: '', # Postal code of business. Only Required for BUSINESS_REGISTRATION in Kenya - postal_code: '' + postal_code: '', } # Set the options for the job diff --git a/examples/document_verification.rb b/examples/document_verification.rb index 445ee41..852e664 100644 --- a/examples/document_verification.rb +++ b/examples/document_verification.rb @@ -17,7 +17,7 @@ partner_params = { user_id: '', job_id: '', - job_type: 6 + job_type: 6, } # Create image list @@ -33,27 +33,27 @@ image_details = [ { image_type_id: '<0 | 2>', - image: '' + image: '', }, { # Not required if you don't require proof of life (note photo of photo check # will still be performed on the uploaded selfie) image_type_id: '<4 | 6>', - image: '' + image: '', }, { image_type_id: '<1 | 3>', - image: '' + image: '', }, { # Optional, only use if you're uploading the back of the id document image image_type_id: '<5 | 7>', - image: '' - } + image: '', + }, ] # The ID Document Information id_info = { country: '<2-letter country code>', # The country where ID document was issued - id_type: '' # The ID document type + id_type: '', # The ID document type } # Set options for the job @@ -67,7 +67,7 @@ # Set to true to receive links to the selfie and the photo it was compared to. # You must set return_job_status to true to use this flag. return_image_links: '', - signature: true + signature: true, } # Submit the job diff --git a/examples/enhanced_document_verification.rb b/examples/enhanced_document_verification.rb index 415ed3b..c35fb62 100644 --- a/examples/enhanced_document_verification.rb +++ b/examples/enhanced_document_verification.rb @@ -17,7 +17,7 @@ partner_params = { user_id: '', job_id: '', - job_type: 11 + job_type: 11, } # Create image list @@ -33,27 +33,27 @@ image_details = [ { image_type_id: '<0 | 2>', - image: '' + image: '', }, { # Not required if you don't require proof of life (note photo of photo check # will still be performed on the uploaded selfie) image_type_id: '<4 | 6>', - image: '' + image: '', }, { image_type_id: '<1 | 3>', - image: '' + image: '', }, { # Optional, only use if you're uploading the back of the id document image image_type_id: '<5 | 7>', - image: '' - } + image: '', + }, ] # The ID Document Information id_info = { country: '<2-letter country code>', # The country where ID document was issued - id_type: '' # The ID document type + id_type: '', # The ID document type } # Set options for the job @@ -67,7 +67,7 @@ # Set to true to receive links to the selfie and the photo it was compared to. # You must set return_job_status to true to use this flag. return_image_links: '', - signature: true + signature: true, } # Submit the job diff --git a/examples/enhanced_kyc.rb b/examples/enhanced_kyc.rb index 032acd8..b9ccf67 100644 --- a/examples/enhanced_kyc.rb +++ b/examples/enhanced_kyc.rb @@ -16,7 +16,7 @@ partner_params = { job_id: '', user_id: '', - job_type: 5 + job_type: 5, } # Create ID info @@ -27,12 +27,12 @@ id_type: '', id_number: '', dob: '', # yyyy-mm-dd - phone_number: '' + phone_number: '', } # Set the options for the job options = { - signature: true + signature: true, } # Submit the job diff --git a/examples/example-project/smart_bank.rb b/examples/example-project/smart_bank.rb index bf0495f..9f4ade1 100644 --- a/examples/example-project/smart_bank.rb +++ b/examples/example-project/smart_bank.rb @@ -11,11 +11,12 @@ class SmartBank def initialize # login to the Smile Identity portal to view your partner id - @partner_id = ENV['SMILE_PARTNER_ID'] + @partner_id = ENV.fetch('SMILE_PARTNER_ID', nil) # See https://docs.usesmileid.com/server-to-server/ruby/products/biometric-kyc#create-a-callback-endpoint - @default_callback = ENV['SMILE_JOB_CALLBACK_URL'] - @api_key = ENV['SMILE_API_KEY'] # copy your API key from the Smile Identity portal - @sid_server = ENV['SMILE_SERVER_ENVIRONMENT'] # Use '0' for the sandbox server, use '1' for production server + @default_callback = ENV.fetch('SMILE_JOB_CALLBACK_URL', nil) + @api_key = ENV.fetch('SMILE_API_KEY', nil) # copy your API key from the Smile Identity portal + # Use '0' for the sandbox server, use '1' for production server + @sid_server = ENV.fetch('SMILE_SERVER_ENVIRONMENT', nil) @user_id = SecureRandom.uuid # your unique ID for the user @job_id = SecureRandom.uuid # your unique job ID end @@ -35,12 +36,12 @@ def perform_enhanced_kyc id_type: 'PASSPORT', id_number: 'G0000000', dob: '1992-12-07', # yyyy-mm-dd - phone_number: '00000000000' + phone_number: '00000000000', } # Set the options for the job options = { - signature: true + signature: true, } # Submit the job @@ -57,13 +58,13 @@ def perform_biometric_kyc image_details = [ { image_type_id: SmileIdentityCore::ImageType::SELFIE_IMAGE_FILE, - image: '/path/to/selfie_image.jpeg' + image: '/path/to/selfie_image.jpeg', }, { # Not required if you don't require proof of life (note photo of photo check will # still be performed on the uploaded selfie) image_type_id: SmileIdentityCore::ImageType::LIVENESS_IMAGE_FILE, - image: '/path/to/liveness_image.jpeg' - } + image: '/path/to/liveness_image.jpeg', + }, ] # Create ID number info @@ -74,7 +75,7 @@ def perform_biometric_kyc id_type: 'PASSPORT', id_number: 'G0000000', dob: '1992-12-07', # yyyy-mm-dd - entered: 'true' # must be a string + entered: 'true', # must be a string } # Submit the job @@ -91,27 +92,27 @@ def perform_document_verification image_details = [ { image_type_id: SmileIdentityCore::ImageType::SELFIE_IMAGE_FILE, - image: '/path/to/selfie_image.jpeg' + image: '/path/to/selfie_image.jpeg', }, { # Not required if you don't require proof of life (note photo of photo # check will still be performed on the uploaded selfie) image_type_id: SmileIdentityCore::ImageType::LIVENESS_IMAGE_FILE, - image: '/path/to/liveness_image.jpeg' + image: '/path/to/liveness_image.jpeg', }, { image_type_id: SmileIdentityCore::ImageType::ID_CARD_IMAGE_FILE, - image: '/path/to/front_document_image.jpeg' + image: '/path/to/front_document_image.jpeg', }, { # Optional, only use if you're uploading the back of the id document image image_type_id: SmileIdentityCore::ImageType::ID_CARD_BACK_IMAGE_FILE, - image: '/path/to/back_document_image.jpeg' - } + image: '/path/to/back_document_image.jpeg', + }, ] # The ID Document Information id_info = { country: 'GH', # The country where ID document was issued - id_type: 'PASSPORT' # The ID document type + id_type: 'PASSPORT', # The ID document type } # Submit the job @@ -128,20 +129,20 @@ def perform_smart_selfie_authentication partner_params = { user_id: '512c9c37-a689-4959-a620-bed75fb41344', # previously registered user's user_id job_id: SecureRandom.uuid, # new unique job ID - job_type: SmileIdentityCore::JobType::SMART_SELFIE_REGISTRATION + job_type: SmileIdentityCore::JobType::SMART_SELFIE_REGISTRATION, } # Create image list image_details = [ { image_type_id: SmileIdentityCore::ImageType::SELFIE_IMAGE_FILE, - image: '/path/to/selfie_image.jpeg' + image: '/path/to/selfie_image.jpeg', }, { # Not required if you don't require proof of life # (note photo of photo check will still be performed on the uploaded selfie) image_type_id: SmileIdentityCore::ImageType::LIVENESS_IMAGE_FILE, - image: '/path/to/liveness_image.jpeg' - } + image: '/path/to/liveness_image.jpeg', + }, ] # Submit the job @@ -154,7 +155,7 @@ def partner_params(job_type) { user_id: user_id, job_id: job_id, - job_type: job_type + job_type: job_type, } end @@ -175,7 +176,7 @@ def job_options # Set to true to receive links to the selfie and the photo it was compared to. # You must set return_job_status to true to use this flag. return_image_links: true, - signature: true + signature: true, } end end diff --git a/examples/get_web_token.rb b/examples/get_web_token.rb index 659ec83..bc97235 100644 --- a/examples/get_web_token.rb +++ b/examples/get_web_token.rb @@ -19,7 +19,7 @@ user_id: '', job_id: '', product: '', - callback_url: '' + callback_url: '', } # Get web token diff --git a/examples/smart_selfie_authentication.rb b/examples/smart_selfie_authentication.rb index 6dd6b7d..5473a7f 100644 --- a/examples/smart_selfie_authentication.rb +++ b/examples/smart_selfie_authentication.rb @@ -17,7 +17,7 @@ partner_params = { user_id: '', job_id: '', - job_type: 2 + job_type: 2, } # Create image list @@ -29,13 +29,13 @@ image_details = [ { image_type_id: '<0 | 2>', - image: '' + image: '', }, { # Not required if you don't require proof of life (note photo of photo check will # still be performed on the uploaded selfie) image_type_id: '<4 | 6>', - image: '' - } + image: '', + }, ] # Set options for the job @@ -49,7 +49,7 @@ # Set to true to receive links to the selfie and the photo it was # compared to. You must set return_job_status to true to use this flag. return_image_links: '', - signature: true + signature: true, } # Submit the job diff --git a/lib/smile-identity-core/aml_check.rb b/lib/smile-identity-core/aml_check.rb index 4e5beea..59c2065 100644 --- a/lib/smile-identity-core/aml_check.rb +++ b/lib/smile-identity-core/aml_check.rb @@ -73,8 +73,8 @@ def generate_signature def submit_requests request = Typhoeus::Request.new("#{@url}/aml", method: 'POST', - headers: { 'Content-Type' => 'application/json' }, - body: build_payload.to_json) + headers: { 'Content-Type' => 'application/json' }, + body: build_payload.to_json) request.on_complete do |response| return response.body if response.success? diff --git a/lib/smile-identity-core/business_verification.rb b/lib/smile-identity-core/business_verification.rb index d026717..7ff1d5d 100644 --- a/lib/smile-identity-core/business_verification.rb +++ b/lib/smile-identity-core/business_verification.rb @@ -85,7 +85,7 @@ def submit_requests "#{@url}/business_verification", method: 'POST', headers: { 'Content-Type' => 'application/json' }, - body: build_payload.to_json + body: build_payload.to_json, ) request.on_complete do |response| diff --git a/lib/smile-identity-core/constants/env.rb b/lib/smile-identity-core/constants/env.rb index 3577e27..a1e4e0b 100644 --- a/lib/smile-identity-core/constants/env.rb +++ b/lib/smile-identity-core/constants/env.rb @@ -6,7 +6,7 @@ module SmileIdentityCore module ENV SID_SERVER_MAPPING = { '0' => 'https://testapi.smileidentity.com/v1', - '1' => 'https://api.smileidentity.com/v1' + '1' => 'https://api.smileidentity.com/v1', }.freeze TEST = '0' @@ -15,10 +15,10 @@ module ENV module_function def determine_url(sid_server) - if sid_server.to_s !~ URI::DEFAULT_PARSER.make_regexp - SID_SERVER_MAPPING[sid_server.to_s] || sid_server - else + if sid_server.to_s =~ URI::DEFAULT_PARSER.make_regexp sid_server + else + SID_SERVER_MAPPING[sid_server.to_s] || sid_server end end end diff --git a/lib/smile-identity-core/id_api.rb b/lib/smile-identity-core/id_api.rb index 24f4356..5608d02 100644 --- a/lib/smile-identity-core/id_api.rb +++ b/lib/smile-identity-core/id_api.rb @@ -25,8 +25,8 @@ def submit_job(partner_params, id_info, options = {}) if partner_params[:job_type] == JobType::BUSINESS_VERIFICATION return SmileIdentityCore::BusinessVerification - .new(@partner_id, @api_key, @url) - .submit_job(partner_params, id_info) + .new(@partner_id, @api_key, @url) + .submit_job(partner_params, id_info) end options = symbolize_keys(options || {}) @@ -46,7 +46,7 @@ def setup_requests "#{@url}/#{endpoint}", method: 'POST', headers: { 'Content-Type' => 'application/json' }, - body: configure_json + body: configure_json, ) request.on_complete do |response| @@ -63,14 +63,14 @@ def endpoint def configure_json signature_generator.generate_signature(Time.now.to_s) - .merge(@id_info) - .merge( - partner_id: @partner_id, - partner_params: @partner_params, - source_sdk: SmileIdentityCore::SOURCE_SDK, - source_sdk_version: SmileIdentityCore::VERSION - ) - .to_json + .merge(@id_info) + .merge( + partner_id: @partner_id, + partner_params: @partner_params, + source_sdk: SmileIdentityCore::SOURCE_SDK, + source_sdk_version: SmileIdentityCore::VERSION, + ) + .to_json end def signature_generator diff --git a/lib/smile-identity-core/signature.rb b/lib/smile-identity-core/signature.rb index 8cc67ec..82b3af8 100644 --- a/lib/smile-identity-core/signature.rb +++ b/lib/smile-identity-core/signature.rb @@ -19,7 +19,7 @@ def generate_signature(timestamp = Time.now.to_s) @signature = Base64.strict_encode64(hmac.digest) { signature: @signature, - timestamp: timestamp.to_s + timestamp: timestamp.to_s, } end diff --git a/lib/smile-identity-core/utilities.rb b/lib/smile-identity-core/utilities.rb index 369fe8d..3cf0a50 100644 --- a/lib/smile-identity-core/utilities.rb +++ b/lib/smile-identity-core/utilities.rb @@ -17,7 +17,7 @@ def get_job_status(user_id, job_id, options = {}) options[:return_image_links] ||= false query_job_status(configure_job_query(user_id, job_id, - options).merge(@signature_connection.generate_signature(Time.now.to_s))) + options).merge(@signature_connection.generate_signature(Time.now.to_s))) end private @@ -29,9 +29,9 @@ def symbolize_keys(params) def query_job_status(request_json_data) request = Typhoeus::Request.new( "#{@url}/job_status", - headers: { 'Content-Type': 'application/json', 'Accept': 'application/json' }, + headers: { 'Content-Type': 'application/json', Accept: 'application/json' }, method: :post, - body: request_json_data.to_json + body: request_json_data.to_json, ) request.on_complete do |response| @@ -47,8 +47,6 @@ def query_job_status(request_json_data) raise 'Unable to confirm validity of the job_status response' unless valid return body - rescue StandardError => e - raise e end request.run @@ -62,7 +60,7 @@ def configure_job_query(user_id, job_id, options) image_links: options[:return_image_links], history: options[:return_history], source_sdk: SmileIdentityCore::SOURCE_SDK, - source_sdk_version: SmileIdentityCore::VERSION + source_sdk_version: SmileIdentityCore::VERSION, } end end diff --git a/lib/smile-identity-core/validations.rb b/lib/smile-identity-core/validations.rb index 70b2c0d..ef2b14d 100644 --- a/lib/smile-identity-core/validations.rb +++ b/lib/smile-identity-core/validations.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module SmileIdentityCore - module Validations # :nodoc: + module Validations # :nodoc: def validate_partner_params(partner_params) raise ArgumentError, 'Please ensure that you send through partner params' if partner_params.nil? @@ -10,7 +10,7 @@ def validate_partner_params(partner_params) %i[user_id job_id job_type].each do |key| if partner_params[key].to_s.empty? raise ArgumentError, - "Please make sure that #{key} is included in the partner params" + "Please make sure that #{key} is included in the partner params" end end diff --git a/lib/smile-identity-core/web_api.rb b/lib/smile-identity-core/web_api.rb index 650ce00..43325a0 100644 --- a/lib/smile-identity-core/web_api.rb +++ b/lib/smile-identity-core/web_api.rb @@ -58,7 +58,7 @@ def partner_params=(partner_params) %i[user_id job_id job_type].each do |key| if partner_params[key].to_s.empty? raise ArgumentError, - "Please make sure that #{key} is included in the partner params" + "Please make sure that #{key} is included in the partner params" end end @@ -135,18 +135,18 @@ def get_web_token(request_params) def request_web_token(request_params) request_params = request_params - .merge(SmileIdentityCore::Signature.new(@partner_id, @api_key).generate_signature(Time.now.to_s)) - .merge( - { partner_id: @partner_id, - source_sdk: SmileIdentityCore::SOURCE_SDK, - source_sdk_version: SmileIdentityCore::VERSION } - ) + .merge(SmileIdentityCore::Signature.new(@partner_id, @api_key).generate_signature(Time.now.to_s)) + .merge( + { partner_id: @partner_id, + source_sdk: SmileIdentityCore::SOURCE_SDK, + source_sdk_version: SmileIdentityCore::VERSION }, + ) url = "#{@url}/token" response = Typhoeus.post( url, headers: { 'Content-Type' => 'application/json' }, - body: request_params.to_json + body: request_params.to_json, ) return response.body if response.code == 200 @@ -204,7 +204,7 @@ def configure_prep_upload_json model_parameters: {}, # what is this for callback_url: @callback_url, source_sdk: SmileIdentityCore::SOURCE_SDK, - source_sdk_version: SmileIdentityCore::VERSION + source_sdk_version: SmileIdentityCore::VERSION, ).to_json end @@ -214,7 +214,7 @@ def setup_requests url, method: 'POST', headers: { 'Content-Type' => 'application/json' }, - body: configure_prep_upload_json + body: configure_prep_upload_json, ) request.on_complete do |response| @@ -226,7 +226,7 @@ def setup_requests info_json = configure_info_json(prep_upload_response) file_upload_response = upload_file(prep_upload_response['upload_url'], info_json, - prep_upload_response['smile_job_id']) + prep_upload_response['smile_job_id']) return file_upload_response end @@ -237,38 +237,38 @@ def setup_requests def configure_info_json(server_information) { - "package_information": { - "apiVersion": { - "buildNumber": 0, - "majorVersion": 2, - "minorVersion": 0 + package_information: { + apiVersion: { + buildNumber: 0, + majorVersion: 2, + minorVersion: 0, }, - "language": 'ruby' + language: 'ruby', }, - "misc_information": SmileIdentityCore::Signature.new(@partner_id, @api_key) - .generate_signature(Time.now.to_s) - .merge( - "retry": 'false', - "partner_params": @partner_params, - "file_name": 'selfie.zip', # figure out what to do here - "smile_client_id": @partner_id, - "callback_url": @callback_url, - "userData": { # TO ASK what goes here - "isVerifiedProcess": false, - "name": '', - "fbUserID": '', - "firstName": 'Bill', - "lastName": '', - "gender": '', - "email": '', - "phone": '', - "countryCode": '+', - "countryName": '' - } - ), - "id_info": @id_info, - "images": configure_image_payload, - "server_information": server_information + misc_information: SmileIdentityCore::Signature.new(@partner_id, @api_key) + .generate_signature(Time.now.to_s) + .merge( + retry: 'false', + partner_params: @partner_params, + file_name: 'selfie.zip', # figure out what to do here + smile_client_id: @partner_id, + callback_url: @callback_url, + userData: { # TO ASK what goes here + isVerifiedProcess: false, + name: '', + fbUserID: '', + firstName: 'Bill', + lastName: '', + gender: '', + email: '', + phone: '', + countryCode: '+', + countryName: '', + }, + ), + id_info: @id_info, + images: configure_image_payload, + server_information: server_information, } end @@ -278,13 +278,13 @@ def configure_image_payload { image_type_id: i[:image_type_id], image: '', - file_name: File.basename(i[:image]) + file_name: File.basename(i[:image]), } else { image_type_id: i[:image_type_id], image: i[:image], - file_name: '' + file_name: '', } end end @@ -304,7 +304,7 @@ def zip_up_file(info_json) @images.each do |img| if (img[:image_type_id]).zero? || img[:image_type_id] == 1 zos.put_next_entry(File.basename(img[:image])) - zos.print IO.read(img[:image]) + zos.print File.read(img[:image]) end end end @@ -319,7 +319,7 @@ def upload_file(url, info_json, smile_job_id) url, method: 'PUT', headers: { 'Content-Type' => 'application/zip' }, - body: file.read + body: file.read, ) request.on_complete do |response| diff --git a/smile-identity-core.gemspec b/smile-identity-core.gemspec index 604e2d8..bc8863d 100644 --- a/smile-identity-core.gemspec +++ b/smile-identity-core.gemspec @@ -5,16 +5,16 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require 'smile-identity-core/version' Gem::Specification.new do |spec| - spec.name = 'smile-identity-core' - spec.version = SmileIdentityCore::VERSION - spec.authors = ['Smile Identity'] - spec.email = ['support@usesmileid.com'] + spec.name = 'smile-identity-core' + spec.version = SmileIdentityCore::VERSION + spec.authors = ['Smile Identity'] + spec.email = ['support@usesmileid.com'] - spec.summary = 'The Smile Identity Web API allows the user to access\ + spec.summary = 'The Smile Identity Web API allows the user to access\ most of the features of the Smile Identity system through direct server to server queries.' - spec.description = 'The Official Smile Identity gem' - spec.homepage = 'https://www.usesmileid.com/' - spec.required_ruby_version = '>= 2.5' + spec.description = 'The Official Smile Identity gem' + spec.homepage = 'https://www.usesmileid.com/' + spec.required_ruby_version = '>= 2.6' spec.license = 'MIT' spec.metadata['homepage_uri'] = spec.homepage @@ -27,8 +27,8 @@ Gem::Specification.new do |spec| spec.files = Dir.chdir(File.expand_path(__dir__)) do `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) } end - spec.bindir = 'exe' - spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) } + spec.bindir = 'exe' + spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) } spec.require_paths = ['lib'] spec.add_development_dependency 'bundler', '~> 2.0' @@ -41,4 +41,5 @@ Gem::Specification.new do |spec| spec.add_dependency 'rubyzip', '~> 1.2', '>= 1.2.3' spec.add_dependency 'typhoeus', '~> 1.0', '>= 1.0.1' + spec.metadata['rubygems_mfa_required'] = 'true' end diff --git a/spec/smile-identity-core/aml_check_spec.rb b/spec/smile-identity-core/aml_check_spec.rb index c43bc3c..8b3f0d1 100644 --- a/spec/smile-identity-core/aml_check_spec.rb +++ b/spec/smile-identity-core/aml_check_spec.rb @@ -14,95 +14,95 @@ countries: ['US'], full_name: 'John Leo Doe', birth_year: '1984', - search_existing_user: false + search_existing_user: false, } end let(:aml_response) do { - "Actions": { - "Listed": 'Listed' + Actions: { + Listed: 'Listed', }, - "PartnerParams": { - "job_type": 10, - "user_id": 'aml_test_user_008', - "job_id": 'DeXyJOGtaACFFfbZ2kxjuICE' + PartnerParams: { + job_type: 10, + user_id: 'aml_test_user_008', + job_id: 'DeXyJOGtaACFFfbZ2kxjuICE', }, - "SmileJobID": '0000000411', - "no_of_persons_found": 1, - "people": [ + SmileJobID: '0000000411', + no_of_persons_found: 1, + people: [ { - "addresses": [ - 'Burbank' + addresses: [ + 'Burbank', ], - "adverse_media": [ + adverse_media: [ { - "date_published": '2021-09-24', - "publisher": 'Regulatory Times', - "source_link": 'https:regulatorytimes.com/article', - "title": 'Jon Doe angered regulators' - } + date_published: '2021-09-24', + publisher: 'Regulatory Times', + source_link: 'https:regulatorytimes.com/article', + title: 'Jon Doe angered regulators', + }, ], - "aliases": [ - 'John Doe' + aliases: [ + 'John Doe', ], - "associations": [ + associations: [ { - "association_type": 'PEP', - "name": 'Bob Smith', - "relationship": 'Bob Smith is an associate of John Leo Doe' - } + association_type: 'PEP', + name: 'Bob Smith', + relationship: 'Bob Smith is an associate of John Leo Doe', + }, ], - "dates_of_birth": [ - '1984-07-16' + dates_of_birth: [ + '1984-07-16', ], - "name": 'John Leo Doe', - "nationalities": [ - 'American' + name: 'John Leo Doe', + nationalities: [ + 'American', ], - "pep": { - "pep_level": 1, - "political_positions": [ + pep: { + pep_level: 1, + political_positions: [ { - "country": 'United States', - "from": '2020-01-05', - "position": 'Representative', - "to": '2022-01-05' + country: 'United States', + from: '2020-01-05', + position: 'Representative', + to: '2022-01-05', }, { - "country": 'United States', - "from": '2022-01-05', - "position": 'Senator', - "to": nil - } + country: 'United States', + from: '2022-01-05', + position: 'Senator', + to: nil, + }, ], - "sources": [ + sources: [ { - "source_link": 'https://www.senate.gov/senators/', - "source_name": 'senate.gov' - } - ] + source_link: 'https://www.senate.gov/senators/', + source_name: 'senate.gov', + }, + ], }, - "sanctions": [ + sanctions: [ { - "date_of_birth": '', - "nationality": 'American', - "source_details": { - "listed_date": '2020-01-05', - "source_link": [ - 'https://sanctionslist.com' + date_of_birth: '', + nationality: 'American', + source_details: { + listed_date: '2020-01-05', + source_link: [ + 'https://sanctionslist.com', ], - "source_name": 'Office of Foreign Assets Control (OFAC)', - "source_type": 'Sanctions' - } - } - ] - } + source_name: 'Office of Foreign Assets Control (OFAC)', + source_type: 'Sanctions', + }, + }, + ], + }, ], - "ResultCode": '1030', - "ResultText": 'Found on list', - "signature": '...', - "timestamp": '2023-02-17T16:24:16.835Z' + ResultCode: '1030', + ResultText: 'Found on list', + signature: '...', + timestamp: '2023-02-17T16:24:16.835Z', }.to_json end @@ -157,9 +157,11 @@ # this test does not directly relate to the implementation of the library but it will help us to debug # if any keys get removed from the response which will affect the partner. - expect(JSON.parse(setup_response).keys).to match_array(%w[SmileJobID PartnerParams people - ResultText ResultCode Actions - signature timestamp no_of_persons_found]) + expect(JSON.parse(setup_response).keys).to match_array(%w[ + SmileJobID PartnerParams people + ResultText ResultCode Actions + signature timestamp no_of_persons_found + ]) end it '#submit_job it runs successfully' do @@ -171,9 +173,11 @@ # this test does not directly relate to the implementation of the library but it will help us to debug # if any keys get removed from the response which will affect the partner. - expect(JSON.parse(setup_response).keys).to match_array(%w[SmileJobID PartnerParams people - ResultText ResultCode Actions - signature timestamp no_of_persons_found]) + expect(JSON.parse(setup_response).keys).to match_array(%w[ + SmileJobID PartnerParams people + ResultText ResultCode Actions + signature timestamp no_of_persons_found + ]) end end @@ -183,53 +187,55 @@ end it 'returns a hash formatted for the request' do - signature = { 'signature': Base64.strict_encode64('signature'), timestamp: Time.now.to_s } + signature = { signature: Base64.strict_encode64('signature'), timestamp: Time.now.to_s } allow(connection).to receive(:generate_signature).and_return(signature) parsed_response = connection.send(:build_payload) - expect(parsed_response).to match({ 'timestamp': signature[:timestamp], 'signature': signature[:signature], - 'partner_id': partner_id, - 'user_id': payload[:user_id], - 'job_id': payload[:job_id], - 'full_name': payload[:full_name], - 'job_type': SmileIdentityCore::JobType::AML, - 'countries': payload[:countries], - 'search_existing_user': payload[:search_existing_user], - 'birth_year': payload[:birth_year], - 'source_sdk': SmileIdentityCore::SOURCE_SDK, - 'source_sdk_version': SmileIdentityCore::VERSION }) + expect(parsed_response).to match({ + timestamp: signature[:timestamp], + signature: signature[:signature], + partner_id: partner_id, + user_id: payload[:user_id], + job_id: payload[:job_id], + full_name: payload[:full_name], + job_type: SmileIdentityCore::JobType::AML, + countries: payload[:countries], + search_existing_user: payload[:search_existing_user], + birth_year: payload[:birth_year], + source_sdk: SmileIdentityCore::SOURCE_SDK, + source_sdk_version: SmileIdentityCore::VERSION, + }) end it 'returns a hash formatted for the request with optional params' do connection.instance_variable_set(:@optional_info, { user_email: 'johndoe@email.com' }) - signature = { 'signature': Base64.strict_encode64('signature'), timestamp: Time.now.to_s } + signature = { signature: Base64.strict_encode64('signature'), timestamp: Time.now.to_s } allow(connection).to receive(:generate_signature).and_return(signature) parsed_response = connection.send(:build_payload) - expect(parsed_response).to match({ 'timestamp': signature[:timestamp], 'signature': signature[:signature], - 'partner_id': partner_id, - 'partner_params': { user_email: 'johndoe@email.com' }, - 'user_id': payload[:user_id], - 'job_id': payload[:job_id], - 'job_type': SmileIdentityCore::JobType::AML, - 'search_existing_user': payload[:search_existing_user], - 'full_name': payload[:full_name], - 'countries': payload[:countries], - 'birth_year': payload[:birth_year], - 'source_sdk': SmileIdentityCore::SOURCE_SDK, - 'source_sdk_version': SmileIdentityCore::VERSION }) + expect(parsed_response).to match({ + timestamp: signature[:timestamp], + signature: signature[:signature], + partner_id: partner_id, + partner_params: { user_email: 'johndoe@email.com' }, + user_id: payload[:user_id], + job_id: payload[:job_id], + job_type: SmileIdentityCore::JobType::AML, + search_existing_user: payload[:search_existing_user], + full_name: payload[:full_name], + countries: payload[:countries], + birth_year: payload[:birth_year], + source_sdk: SmileIdentityCore::SOURCE_SDK, + source_sdk_version: SmileIdentityCore::VERSION, + }) end end - describe '#build_payload' do - before do - connection.instance_variable_set(:@params, nil) - connection.instance_variable_set(:@optional_info, nil) - end + it 'successfully submits a job' do + connection.instance_variable_set(:@params, nil) + connection.instance_variable_set(:@optional_info, nil) - it 'successfully submits a job' do - signature = { 'signature': Base64.strict_encode64('signature'), timestamp: Time.now.to_s } - allow(connection).to receive(:generate_signature).and_return(signature) - end + signature = { signature: Base64.strict_encode64('signature'), timestamp: Time.now.to_s } + allow(connection).to receive(:generate_signature).and_return(signature) end end end diff --git a/spec/smile-identity-core/business_verification_spec.rb b/spec/smile-identity-core/business_verification_spec.rb index b85e126..b3240a6 100644 --- a/spec/smile-identity-core/business_verification_spec.rb +++ b/spec/smile-identity-core/business_verification_spec.rb @@ -11,32 +11,32 @@ partner_params: { user_id: 'kyb_test_user_008', job_id: 'DeXyJOGtaACFFfbZ2kxjuICE', - job_type: SmileIdentityCore::JobType::BUSINESS_VERIFICATION + job_type: SmileIdentityCore::JobType::BUSINESS_VERIFICATION, }, id_info: { country: 'NG', id_type: 'BUSINESS_REGISTRATION', id_number: 'A000000', - business_type: 'co' - } + business_type: 'co', + }, } end it 'sets REQUIRED_ID_INFO_FIELD' do - expect(SmileIdentityCore::BusinessVerification::REQUIRED_ID_INFO_FIELD).to eq(%i[country id_type id_number]) + expect(described_class::REQUIRED_ID_INFO_FIELD).to eq(%i[country id_type id_number]) end describe 'when id_type is called' do it 'returns BASIC_BUSINESS_REGISTRATION' do - expect(SmileIdentityCore::BusinessVerification::BASIC_BUSINESS_REGISTRATION).to eq('BASIC_BUSINESS_REGISTRATION') + expect(described_class::BASIC_BUSINESS_REGISTRATION).to eq('BASIC_BUSINESS_REGISTRATION') end it 'returns BUSINESS_REGISTRATION' do - expect(SmileIdentityCore::BusinessVerification::BUSINESS_REGISTRATION).to eq('BUSINESS_REGISTRATION') + expect(described_class::BUSINESS_REGISTRATION).to eq('BUSINESS_REGISTRATION') end it 'returns TAX_INFORMATION' do - expect(SmileIdentityCore::BusinessVerification::TAX_INFORMATION).to eq('TAX_INFORMATION') + expect(described_class::TAX_INFORMATION).to eq('TAX_INFORMATION') end end @@ -80,7 +80,7 @@ expect do connection.submit_job(payload[:partner_params].merge(job_type: 1), payload[:id_info]) end.to raise_error(ArgumentError, - 'Please ensure that you are setting your job_type to 7 to query Business Verification') + 'Please ensure that you are setting your job_type to 7 to query Business Verification') end it 'throws ArgumentError if id_info is nil' do @@ -121,101 +121,101 @@ describe '#setup_requests' do it 'returns a correct json object if it runs successfully' do body = { - 'signature': '---', - 'timestamp': '2022-10-17T10:46:49.392Z', - 'JSONVersion': '1.0.0', - 'SmileJobID': '0000001927', - 'PartnerParams': { - 'user_id': 'kyb_test_user_008', - 'job_id': 'DeXyJOGtaACFFfbZ2kxjuICE', - 'job_type': 7 + signature: '---', + timestamp: '2022-10-17T10:46:49.392Z', + JSONVersion: '1.0.0', + SmileJobID: '0000001927', + PartnerParams: { + user_id: 'kyb_test_user_008', + job_id: 'DeXyJOGtaACFFfbZ2kxjuICE', + job_type: 7, }, - 'ResultType': 'Business Verification', - 'ResultText': 'Business Verified', - 'ResultCode': '1012', - 'IsFinalResult': 'true', - 'Actions': { - 'Verify_Business': 'Verified', - 'Return_Business_Info': 'Returned' + ResultType: 'Business Verification', + ResultText: 'Business Verified', + ResultCode: '1012', + IsFinalResult: 'true', + Actions: { + Verify_Business: 'Verified', + Return_Business_Info: 'Returned', }, - 'company_information': { - 'company_type': 'PRIVATE_COMPANY_LIMITED_BY_SHARES', - 'country': 'Nigeria', - 'address': '10, Workbox, Ojora Close, Victoria Island, Lagos', - 'registration_number': '0000000', - 'search_number': '0000000', - 'authorized_shared_capital': '10000000', - 'industry': 'Technology Solutions Company', - 'tax_id': 'N/A', - 'registration_date': '2016-01-28T16:06:22.003+00:00', - 'phone': '08000000000', - 'legal_name': 'SMILE IDENTITY NIGERIA LIMITED', - 'state': 'LAGOS', - 'email': 'smile@usesmileid.com', - 'status': 'ACTIVE' + company_information: { + company_type: 'PRIVATE_COMPANY_LIMITED_BY_SHARES', + country: 'Nigeria', + address: '10, Workbox, Ojora Close, Victoria Island, Lagos', + registration_number: '0000000', + search_number: '0000000', + authorized_shared_capital: '10000000', + industry: 'Technology Solutions Company', + tax_id: 'N/A', + registration_date: '2016-01-28T16:06:22.003+00:00', + phone: '08000000000', + legal_name: 'SMILE IDENTITY NIGERIA LIMITED', + state: 'LAGOS', + email: 'smile@usesmileid.com', + status: 'ACTIVE', }, - 'fiduciaries': [ + fiduciaries: [ { - 'name': 'Company X', - 'fiduciary_type': 'SECRETARY_COMPANY', - 'address': '10, Workbox, Ojora Close, Victoria Island, Lagos', - 'registration_number': '000000', - 'status': 'N/A' - } + name: 'Company X', + fiduciary_type: 'SECRETARY_COMPANY', + address: '10, Workbox, Ojora Close, Victoria Island, Lagos', + registration_number: '000000', + status: 'N/A', + }, ], - 'beneficial_owners': [ + beneficial_owners: [ { - 'shareholdings': '100000', - 'address': '10, Workbox, Ojora Close, Victoria Island, Lagos', - 'gender': 'Male', - 'nationality': 'Nigerian', - 'registration_number': 'N/A', - 'name': 'Joe Bloggs', - 'shareholder_type': 'Individual', - 'phone_number': '0123456789' + shareholdings: '100000', + address: '10, Workbox, Ojora Close, Victoria Island, Lagos', + gender: 'Male', + nationality: 'Nigerian', + registration_number: 'N/A', + name: 'Joe Bloggs', + shareholder_type: 'Individual', + phone_number: '0123456789', }, { - 'shareholdings': '700000', - 'address': '1234 Main Street Anytown Anystate 00000 USA', - 'gender': 'Not Applicable', - 'nationality': 'N/A', - 'registration_number': '000000', - 'name': 'XYZ Widget Corporation', - 'shareholder_type': 'Corporate', - 'phone_number': '0123456789' - } + shareholdings: '700000', + address: '1234 Main Street Anytown Anystate 00000 USA', + gender: 'Not Applicable', + nationality: 'N/A', + registration_number: '000000', + name: 'XYZ Widget Corporation', + shareholder_type: 'Corporate', + phone_number: '0123456789', + }, ], - 'proprietors': [], - 'documents': { - 'search_certificate': '' + proprietors: [], + documents: { + search_certificate: '', }, - 'directors': [ + directors: [ { - 'shareholdings': '100000', - 'id_number': 'A000000', - 'address': '10, Workbox, Ojora Close, Victoria Island, Lagos', - 'occupation': 'CEO', - 'gender': 'MALE', - 'nationality': 'Nigerian', - 'date_of_birth': '2000-09-20', - 'name': 'Joe Doe Leo', - 'id_type': 'Passport', - 'phone_number': '0123456789' + shareholdings: '100000', + id_number: 'A000000', + address: '10, Workbox, Ojora Close, Victoria Island, Lagos', + occupation: 'CEO', + gender: 'MALE', + nationality: 'Nigerian', + date_of_birth: '2000-09-20', + name: 'Joe Doe Leo', + id_type: 'Passport', + phone_number: '0123456789', }, { - 'shareholdings': '100000', - 'id_number': 'A000000', - 'address': '1234 Main Street Anytown Anystate 00000 USA', - 'occupation': 'COO', - 'gender': 'FEMALE', - 'nationality': 'American', - 'date_of_birth': '2000-01-01', - 'name': 'Jane Doe', - 'id_type': 'Passport', - 'phone_number': '0123456789' - } + shareholdings: '100000', + id_number: 'A000000', + address: '1234 Main Street Anytown Anystate 00000 USA', + occupation: 'COO', + gender: 'FEMALE', + nationality: 'American', + date_of_birth: '2000-01-01', + name: 'Jane Doe', + id_type: 'Passport', + phone_number: '0123456789', + }, ], - 'success': true + success: true, }.to_json response = Typhoeus::Response.new(code: 200, body: body) @@ -244,17 +244,17 @@ end it 'returns a hash formatted for the request' do - signature = { 'signature': Base64.strict_encode64('signature'), timestamp: Time.now.to_s } + signature = { signature: Base64.strict_encode64('signature'), timestamp: Time.now.to_s } allow(connection).to receive(:generate_signature).and_return(signature) parsed_response = connection.send(:build_payload) - expect(parsed_response).to match({ 'timestamp': signature[:timestamp], 'signature': signature[:signature], - 'partner_id': partner_id, 'country': 'NG', - 'partner_params': payload[:partner_params], - 'id_type': payload[:id_info][:id_type], - 'id_number': payload[:id_info][:id_number], - 'business_type': payload[:id_info][:business_type], - 'source_sdk': SmileIdentityCore::SOURCE_SDK, - 'source_sdk_version': SmileIdentityCore::VERSION }) + expect(parsed_response).to match({ timestamp: signature[:timestamp], signature: signature[:signature], + partner_id: partner_id, country: 'NG', + partner_params: payload[:partner_params], + id_type: payload[:id_info][:id_type], + id_number: payload[:id_info][:id_number], + business_type: payload[:id_info][:business_type], + source_sdk: SmileIdentityCore::SOURCE_SDK, + source_sdk_version: SmileIdentityCore::VERSION }) end end end diff --git a/spec/smile-identity-core/constants/env_spec.rb b/spec/smile-identity-core/constants/env_spec.rb index 1f3d7eb..043678d 100644 --- a/spec/smile-identity-core/constants/env_spec.rb +++ b/spec/smile-identity-core/constants/env_spec.rb @@ -6,12 +6,12 @@ describe '.determine_url' do context 'when sid_server is an environment key' do it 'returns the mapped URL for TEST' do - expect(described_class.determine_url(SmileIdentityCore::ENV::TEST)) + expect(described_class.determine_url(described_class::TEST)) .to eq('https://testapi.smileidentity.com/v1') end it 'returns the mapped URL for LIVE' do - expect(described_class.determine_url(SmileIdentityCore::ENV::LIVE)) + expect(described_class.determine_url(described_class::LIVE)) .to eq('https://api.smileidentity.com/v1') end end diff --git a/spec/smile-identity-core/id_api_spec.rb b/spec/smile-identity-core/id_api_spec.rb index 37ea4f3..0c88180 100644 --- a/spec/smile-identity-core/id_api_spec.rb +++ b/spec/smile-identity-core/id_api_spec.rb @@ -10,7 +10,7 @@ { user_id: 'dmKaJazQCziLc6Tw9lwcgzLo', job_id: 'DeXyJOGtaACFFfbZ2kxjuICE', - job_type: SmileIdentityCore::JobType::BASIC_KYC + job_type: SmileIdentityCore::JobType::BASIC_KYC, } end @@ -23,7 +23,7 @@ id_type: 'BVN', id_number: '00000000000', phone_number: '0726789065', - entered: 'true' + entered: 'true', } end @@ -59,8 +59,8 @@ it 'validates that business verification is called' do body = { - "JSONVersion": '1.0.0', - "SmileJobID": '0000001096' + JSONVersion: '1.0.0', + SmileJobID: '0000001096', } response = Typhoeus::Response.new(code: 200, body: body) Typhoeus.stub('https://testapi.smileidentity.com/v1/business_verification').and_return(response) @@ -80,9 +80,9 @@ missing_partner_params = { user_id: 'dmKaJazQCziLc6Tw9lwcgzLo', job_id: 'DeXyJOGtaACFFfbZ2kxjuICE', - job_type: 5 + job_type: 5, } - missing_partner_params.each do |key, _| + missing_partner_params.each_key do |key| expect { connection.submit_job(missing_partner_params.merge({ key => nil }), id_info) } .to raise_error(ArgumentError, "Please make sure that #{key} is included in the partner params") end @@ -92,7 +92,7 @@ expect do connection.submit_job( { user_id: 'dmKaJazQCziLc6Tw9lwcgzLo', job_id: 'DeXyJOGtaACFFfbZ2kxjuICE', job_type: 1 }, - id_info + id_info, ) end.to raise_error(ArgumentError, 'Please ensure that you are setting your job_type to 5 or 7 to query ID Api') end @@ -128,32 +128,32 @@ it 'returns a correct json object if it runs successfully' do body = { - "JSONVersion": '1.0.0', - "SmileJobID": '0000001096', - "PartnerParams": { - "user_id": 'dmKaJazQCziLc6Tw9lwcgzLo', - "job_id": 'DeXyJOGtaACFFfbZ2kxjuICE', - "job_type": 5 + JSONVersion: '1.0.0', + SmileJobID: '0000001096', + PartnerParams: { + user_id: 'dmKaJazQCziLc6Tw9lwcgzLo', + job_id: 'DeXyJOGtaACFFfbZ2kxjuICE', + job_type: 5, }, - "ResultType": 'ID Verification', - "ResultText": 'ID Number Validated', - "ResultCode": '1012', - "IsFinalResult": 'true', - "Actions": { - "Verify_ID_Number": 'Verified', - "Return_Personal_Info": 'Returned' + ResultType: 'ID Verification', + ResultText: 'ID Number Validated', + ResultCode: '1012', + IsFinalResult: 'true', + Actions: { + Verify_ID_Number: 'Verified', + Return_Personal_Info: 'Returned', }, - "Country": 'NG', - "IDType": 'BVN', - "IDNumber": '00000000000', - "ExpirationDate": 'NaN-NaN-NaN', - "FullName": 'some person', - "DOB": 'NaN-NaN-NaN', - "Photo": 'Not Available', - "signature": 'RKYX2ZVpvNTFW8oXdG2rerewererfCdFdRvika0bhJ13ntunAae85e1Fbw9NZl\ + Country: 'NG', + IDType: 'BVN', + IDNumber: '00000000000', + ExpirationDate: 'NaN-NaN-NaN', + FullName: 'some person', + DOB: 'NaN-NaN-NaN', + Photo: 'Not Available', + signature: 'RKYX2ZVpvNTFW8oXdG2rerewererfCdFdRvika0bhJ13ntunAae85e1Fbw9NZl\ i8PE0P0N2cbX5wNCV4Yag4PTCQrLjHG1ZnBHG/Q/Y+sdsdsddsa/rMGyx/m0Jc6w5JrrRDzYsr2\ ihe5sJEs4Mp1N3iTvQcefV93VMo18LQ/Uco0=|7f0b0d5ebc3e5499c224f2db478e210d1860f01368ebc045c7bbe6969f1c08ba', - "timestamp": 1_570_612_182_124 + timestamp: 1_570_612_182_124, }.to_json response = Typhoeus::Response.new(code: 200, body: body) @@ -194,7 +194,7 @@ 'id' => 'info', 'is_merged' => 'in, too', 'source_sdk' => SmileIdentityCore::SOURCE_SDK, - 'source_sdk_version' => SmileIdentityCore::VERSION + 'source_sdk_version' => SmileIdentityCore::VERSION, ) expect(parsed_response).not_to have_key 'sec_key' end diff --git a/spec/smile-identity-core/signature_spec.rb b/spec/smile-identity-core/signature_spec.rb index 17bf75c..66c9f81 100644 --- a/spec/smile-identity-core/signature_spec.rb +++ b/spec/smile-identity-core/signature_spec.rb @@ -10,9 +10,9 @@ it 'returns the defined keys' do payload = connection.generate_signature %i[signature timestamp].each do |key| - expect(payload).to be_kind_of(Hash) + expect(payload).to be_a(Hash) expect(payload).to have_key(key) - expect(payload[key]).to be_kind_of(String) + expect(payload[key]).to be_a(String) end end @@ -35,7 +35,7 @@ hmac.update(partner_id) hmac.update('sid_request') signature = Base64.strict_encode64(hmac.digest) - expect(connection.confirm_signature(timestamp, signature)).to eq(true) + expect(connection.confirm_signature(timestamp, signature)).to be(true) end end end diff --git a/spec/smile-identity-core/smile_identity_core_spec.rb b/spec/smile-identity-core/smile_identity_core_spec.rb index b32af6d..87f947f 100644 --- a/spec/smile-identity-core/smile_identity_core_spec.rb +++ b/spec/smile-identity-core/smile_identity_core_spec.rb @@ -2,16 +2,16 @@ RSpec.describe SmileIdentityCore do it 'has a version number' do - expect(SmileIdentityCore::VERSION).not_to be nil + expect(described_class::VERSION).not_to be_nil end describe 'sets server url' do it 'returns the test url' do - expect(SmileIdentityCore::ENV::SID_SERVER_MAPPING[SmileIdentityCore::ENV::TEST]).to eq('https://testapi.smileidentity.com/v1') + expect(described_class::ENV::SID_SERVER_MAPPING[described_class::ENV::TEST]).to eq('https://testapi.smileidentity.com/v1') end it 'returns the live url' do - expect(SmileIdentityCore::ENV::SID_SERVER_MAPPING[SmileIdentityCore::ENV::LIVE]).to eq('https://api.smileidentity.com/v1') + expect(described_class::ENV::SID_SERVER_MAPPING[described_class::ENV::LIVE]).to eq('https://api.smileidentity.com/v1') end end end diff --git a/spec/smile-identity-core/utilities_spec.rb b/spec/smile-identity-core/utilities_spec.rb index fb731aa..36de11c 100644 --- a/spec/smile-identity-core/utilities_spec.rb +++ b/spec/smile-identity-core/utilities_spec.rb @@ -40,13 +40,13 @@ timestamp: /\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2} [-+]\d{4}/, # new signature! signature: instance_of(String), # new signature! source_sdk: SmileIdentityCore::SOURCE_SDK, - source_sdk_version: SmileIdentityCore::VERSION + source_sdk_version: SmileIdentityCore::VERSION, ) connection.get_job_status( user_id, job_id, - { return_history: return_history, return_image_links: return_image_links } + { return_history: return_history, return_image_links: return_image_links }, ) end @@ -65,7 +65,7 @@ context 'when options are provided as strings' do it 'symbolizes them' do allow(connection).to receive(:query_job_status).with( - hash_including(history: return_history, image_links: return_image_links) + hash_including(history: return_history, image_links: return_image_links), ) connection.get_job_status( user_id, job_id, { 'return_history' => return_history, 'return_image_links' => return_image_links } @@ -126,7 +126,7 @@ def a_signed_response(signature:, timestamp:) connection.instance_variable_set(:@timestamp, 'we only care here that it comes through') result = connection.send(:configure_job_query, - 111, 222, { return_history: return_history, return_image_links: return_image_links }) + 111, 222, { return_history: return_history, return_image_links: return_image_links }) expect(result[:user_id]).to eq(111) expect(result[:job_id]).to eq(222) diff --git a/spec/smile-identity-core/web_api_spec.rb b/spec/smile-identity-core/web_api_spec.rb index 4c6a105..492842e 100644 --- a/spec/smile-identity-core/web_api_spec.rb +++ b/spec/smile-identity-core/web_api_spec.rb @@ -12,7 +12,7 @@ { user_id: '1', job_id: '2', - job_type: SmileIdentityCore::JobType::BIOMETRIC_KYC + job_type: SmileIdentityCore::JobType::BIOMETRIC_KYC, } end @@ -20,12 +20,12 @@ [ { image_type_id: SmileIdentityCore::ImageType::SELFIE_IMAGE_FILE, - image: './tmp/selfie.png' + image: './tmp/selfie.png', }, { image_type_id: SmileIdentityCore::ImageType::ID_CARD_IMAGE_FILE, - image: './tmp/id_image.png' - } + image: './tmp/id_image.png', + }, ] end @@ -33,12 +33,12 @@ [ { image_type_id: SmileIdentityCore::ImageType::SELFIE_IMAGE_FILE, - image: './tmp/selfie.png' + image: './tmp/selfie.png', }, { image_type_id: SmileIdentityCore::ImageType::ID_CARD_BACK_IMAGE_BASE64, - image: '/9j/4AAQSkZJRgABAQAAAQABAAD/2wCEAAkGBxITEhUSEhMVFRUXFxcWFRUVFRUVFRgWFRUXFhcW=' - } + image: '/9j/4AAQSkZJRgABAQAAAQABAAD/2wCEAAkGBxITEhUSEhMVFRUXFxcWFRUVFRUVFRgWFRUXFhcW=', + }, ] end @@ -51,7 +51,7 @@ country: 'NG', id_type: 'BVN', id_number: '00000000000', - entered: 'true' + entered: 'true', } end @@ -60,7 +60,7 @@ optional_callback: 'www.optional_callback.com', return_job_status: false, return_image_links: false, - return_history: false + return_history: false, } end @@ -97,7 +97,7 @@ missing_partner_params = { user_id: '1', job_id: '2', - job_type: nil + job_type: nil, } expect { connection.submit_job(no_partner_parameters, images, id_info, options) } @@ -117,8 +117,8 @@ just_id_image = [ { image_type_id: SmileIdentityCore::ImageType::ID_CARD_BACK_IMAGE_FILE, - image_path: './tmp/id_image.png' - } + image_path: './tmp/id_image.png', + }, ] expect { connection.submit_job(partner_params, no_images, id_info, options) } @@ -148,7 +148,7 @@ 'ref_id' => '125-0000000583-s8fqo7ju2ji2u32hhu4us11bq3yhww', 'smile_job_id' => '0000000583', 'camera_config' => 'null', - 'code' => '2202' + 'code' => '2202', }.to_json Typhoeus.stub('https://www.example.com/upload').and_return(Typhoeus::Response.new(code: 200, body: body)) allow(IO).to receive(:read).with('./tmp/selfie.png').and_return('') @@ -156,8 +156,8 @@ Typhoeus.stub(response_upload_url).and_return(Typhoeus::Response.new(code: 200)) amended_partner_params = partner_params.merge({ - job_type: SmileIdentityCore::JobType::DOCUMENT_VERIFICATION - }) + job_type: SmileIdentityCore::JobType::DOCUMENT_VERIFICATION, + }) %i[id_number id_type].each do |key| amended_id_info = id_info.merge(key => '') expect { connection.submit_job(amended_partner_params, images, amended_id_info, options) } @@ -168,8 +168,8 @@ it 'country field in id_info is required for JT6' do amended_id_info = id_info.merge('country' => '') amended_partner_params = partner_params.merge({ - job_type: SmileIdentityCore::JobType::DOCUMENT_VERIFICATION - }) + job_type: SmileIdentityCore::JobType::DOCUMENT_VERIFICATION, + }) expect { connection.submit_job(amended_partner_params, images, amended_id_info, options) } .to raise_error(ArgumentError, 'Please make sure that country is included in the id_info') end @@ -179,8 +179,8 @@ amended_id_info = id_info.merge(key => '') job_type = SmileIdentityCore::JobType::ENHANCED_DOCUMENT_VERIFICATION amended_partner_params = partner_params.merge({ - job_type: job_type - }) + job_type: job_type, + }) expect { connection.submit_job(amended_partner_params, images, amended_id_info, options) } .to raise_error(ArgumentError, "Please make sure that #{key} is included in the id_info") end @@ -205,7 +205,7 @@ 'ref_id' => '125-0000000583-s8fqo7ju2ji2u32hhu4us11bq3yhww', 'smile_job_id' => '0000000583', 'camera_config' => 'null', - 'code' => '2202' + 'code' => '2202', }.to_json Typhoeus.stub('https://www.example.com/upload').and_return(Typhoeus::Response.new(code: 200, body: body)) @@ -228,8 +228,8 @@ [5, 7].each do |job_type| it "ensures that IDApi is called when job id is #{job_type}" do body = { - "JSONVersion": '1.0.0', - "SmileJobID": '0000001096' + JSONVersion: '1.0.0', + SmileJobID: '0000001096', } response = Typhoeus::Response.new(code: 200, body: body) Typhoeus.stub('https://testapi.smileidentity.com/v1/business_verification').and_return(response) @@ -243,7 +243,7 @@ allow(instance).to receive(:submit_job).and_return(body) connection.submit_job(partner_params.merge(job_type: job_type), images, id_info.merge(business_info), - options.merge(optional_callback: 'https://zombo.com')) + options.merge(optional_callback: 'https://zombo.com')) expect(instance).to have_received(:submit_job).once end end @@ -270,7 +270,7 @@ connection.instance_variable_set('@options', options) expect { connection.send(:validate_return_data) } .to raise_error(ArgumentError, - 'Please choose to either get your response via the callback or job status query') + 'Please choose to either get your response via the callback or job status query') connection.instance_variable_set('@options', options_with_job_status_true) connection.instance_variable_set('@callback_url', default_callback) @@ -281,31 +281,31 @@ describe '#validate_enroll_with_id' do before do connection.instance_variable_set('@images', [ - { - image_type_id: SmileIdentityCore::ImageType::SELFIE_IMAGE_FILE, - image: './tmp/selfie1.png' - }, - { - image_type_id: SmileIdentityCore::ImageType::SELFIE_IMAGE_FILE, - image: './tmp/selfie2.png' - } - ]) + { + image_type_id: SmileIdentityCore::ImageType::SELFIE_IMAGE_FILE, + image: './tmp/selfie1.png', + }, + { + image_type_id: SmileIdentityCore::ImageType::SELFIE_IMAGE_FILE, + image: './tmp/selfie2.png', + }, + ]) connection.instance_variable_set('@id_info', - { - first_name: '', - last_name: '', - middle_name: '', - country: '', - id_type: '', - id_number: '', - entered: 'false' - }) + { + first_name: '', + last_name: '', + middle_name: '', + country: '', + id_type: '', + id_number: '', + entered: 'false', + }) end it 'validates the id parameters required for job_type 1' do expect { connection.send(:validate_enroll_with_id) } .to raise_error(ArgumentError, - 'You are attempting to complete a job type 1 without providing an id card image or id info') + 'You are attempting to complete a job type 1 without providing an id card image or id info') connection.instance_variable_set('@images', images) expect { connection.send(:validate_enroll_with_id) }.not_to raise_error @@ -361,7 +361,7 @@ 'model_parameters' => {}, # The code hard-codes this value 'callback_url' => 'www.example.com', 'source_sdk' => SmileIdentityCore::SOURCE_SDK, - 'source_sdk_version' => SmileIdentityCore::VERSION + 'source_sdk_version' => SmileIdentityCore::VERSION, ) expect(parsed_response).to have_key 'signature' end @@ -383,7 +383,7 @@ 'ref_id' => '125-0000000583-s8fqo7ju2ji2u32hhu4us11bq3yhww', 'smile_job_id' => response_smile_job_id, 'camera_config' => 'null', - 'code' => '2202' + 'code' => '2202', }.to_json Typhoeus.stub("#{url}/upload").and_return(Typhoeus::Response.new(code: 200, body: body)) @@ -434,7 +434,7 @@ let(:configure_info_json) { connection.send(:configure_info_json, 'the server information url') } it 'includes the images on the root level' do - expect(configure_info_json.fetch(:images)).to be_kind_of(Array) + expect(configure_info_json.fetch(:images)).to be_a(Array) end it 'includes the relevant id_info on the root level' do @@ -449,20 +449,20 @@ it 'includes its relevant keys' do [:apiVersion].each do |key| expect(connection.send(:configure_info_json, - 'the server information url')[:package_information]).to have_key(key) + 'the server information url')[:package_information]).to have_key(key) end end it 'includes the relevant keys for the nested apiVersion' do %i[buildNumber majorVersion minorVersion].each do |key| expect(connection.send(:configure_info_json, - 'the server information url')[:package_information][:apiVersion]).to have_key(key) + 'the server information url')[:package_information][:apiVersion]).to have_key(key) end end it 'sets the correct version information' do api_version = connection.send(:configure_info_json, - 'the server information url')[:package_information][:apiVersion] + 'the server information url')[:package_information][:apiVersion] expect(api_version[:buildNumber]).to be(0) expect(api_version[:majorVersion]).to be(2) expect(api_version[:minorVersion]).to be(0) @@ -483,7 +483,7 @@ signature: instance_of(String), # new signature! userData: instance_of(Hash), # hard-coded, and spec'd below retry: 'false', # hard-coded - file_name: 'selfie.zip' # hard-coded + file_name: 'selfie.zip', # hard-coded ) expect(configure_info_json.fetch(:misc_information)).to have_key(:signature) end @@ -503,7 +503,7 @@ end it 'returns the correct data type' do - expect(connection.send(:configure_image_payload)).to be_kind_of(Array) + expect(connection.send(:configure_image_payload)).to be_a(Array) end it 'includes the relevant keys in the hash of the array' do @@ -542,8 +542,8 @@ apiVersion: { buildNumber: 0, majorVersion: 2, - minorVersion: 0 - } + minorVersion: 0, + }, }, misc_information: { signature: "zWzSzfvXzvN0MdPHtW78a9w3Zlyy7k9UY6Li7pikHniTeuma2/9gzZsZIMVy\n/NhMyK0crjvLeheZ\ @@ -565,8 +565,8 @@ email: '', phone: '', countryCode: '+', - countryName: '' - } + countryName: '', + }, }, id_info: id_info, images: connection.send(:configure_image_payload), @@ -575,15 +575,15 @@ 'ref_id' => '125-0000000549-vzegm7mb23rznn5e1lepyij444olpa', 'smile_job_id' => '0000000549', 'camera_config' => 'null', - 'code' => '2202' - } + 'code' => '2202', + }, } end let(:zip_up_file) { connection.send(:zip_up_file, info_json) } it 'returns the correct object type after being zipped' do - expect(zip_up_file).to be_a_kind_of(StringIO) + expect(zip_up_file).to be_a(StringIO) end it 'returns an object with a size greater than 0' do @@ -625,8 +625,8 @@ apiVersion: { buildNumber: 0, majorVersion: 2, - minorVersion: 0 - } + minorVersion: 0, + }, }, misc_information: { signature: "zWzSzfvXzvN0MdPHtW7879w3Zlyy7k9UY6Li7pikHniTUuma2/9gzZsZIMVy\n/NhMyK0crjvLe\ @@ -648,8 +648,8 @@ email: '', phone: '', countryCode: '+', - countryName: '' - } + countryName: '', + }, }, id_info: id_info, images: connection.send(:configure_image_payload), @@ -657,8 +657,8 @@ 'upload_url' => 'https://some_url/selfie.zip', 'smile_job_id' => '0000000549', 'camera_config' => 'null', - 'code' => '2202' - } + 'code' => '2202', + }, } end @@ -743,16 +743,16 @@ before do connection.instance_variable_set('@partner_params', { - user_id: '1', - job_id: '2', - job_type: 1 - }) + user_id: '1', + job_id: '2', + job_type: 1, + }) connection.instance_variable_set('@url', url) connection.instance_variable_set('@options', options) connection.instance_variable_set('@api_key', api_key) connection.instance_variable_set('@partner_id', partner_id) connection.instance_variable_set('@utilies_connection', - SmileIdentityCore::Utilities.new(partner_id, api_key, sid_server)) + SmileIdentityCore::Utilities.new(partner_id, api_key, sid_server)) hmac = OpenSSL::HMAC.new(api_key, 'sha256') hmac.update(timestamp.to_s) @@ -779,7 +779,7 @@ def connection.sleep(time_is_seconds) success: true, smile_job_id: '123', source_sdk: instance_of(String), - source_sdk_version: instance_of(String) + source_sdk_version: instance_of(String), }.to_json typhoeus_response = Typhoeus::Response.new(code: 200, body: body.to_s) @@ -798,7 +798,7 @@ def connection.sleep(time_is_seconds) success: true, smile_job_id: '123', source_sdk: SmileIdentityCore::SOURCE_SDK, - source_sdk_version: SmileIdentityCore::VERSION + source_sdk_version: SmileIdentityCore::VERSION, }.to_json typhoeus_response = Typhoeus::Response.new(code: 200, body: body.to_s) @@ -823,7 +823,7 @@ def connection.sleep(time_is_seconds) user_id: user_id, job_id: job_id, product: product, - callback_url: callback_url + callback_url: callback_url, } end @@ -899,7 +899,7 @@ def connection.sleep(time_is_seconds) headers = { 'Content-Type' => 'application/json' } allow(Typhoeus).to receive(:post).with(url, { body: request_body, headers: headers }) - .and_return(typhoeus_response) + .and_return(typhoeus_response) connection.get_web_token(request_params) end