Sha256: 7839df3002902e461e4249b6f82266b1f7af5f8abb26e0b9589d75809a2c21f4
Contents?: true
Size: 1.04 KB
Versions: 14
Compression:
Stored size: 1.04 KB
Contents
# frozen_string_literal: true module Trusona module Workers # ## Finds user accounts class UserAccountFinder def initialize(user_accounts_service: nil, account_lookups_service: nil) @lookups = account_lookups_service || Trusona::Services::AccountLookupsService.new @user_accounts = user_accounts_service || Trusona::Services::UserAccountsService.new end def find(opts) raise ArgumentError, 'Missing email or trusona id' unless contains_required_arguments(opts) resource = build_resource(opts) if opts[:trusona_id] || opts['trusona_id'] return @user_accounts.get(resource) end @lookups.create(resource) if opts[:email] || opts['email'] end private def contains_required_arguments(opts) opts[:email] || opts['email'] || opts[:trusona_id] || opts['trusona_id'] end def build_resource(options) Trusona::Resources::UserAccount.new(options) end end end end
Version data entries
14 entries across 14 versions & 1 rubygems