class Alloy::KYC::Backends::Mock
Attributes
bearer_token[RW]
database[RW]
Public Class Methods
new()
click to toggle source
# File lib/alloy/kyc/backends/mock.rb, line 11 def initialize @database = generate_fake_data nil end
Public Instance Methods
create_evaluation(params)
click to toggle source
# File lib/alloy/kyc/backends/mock.rb, line 24 def create_evaluation(params) if !params[:document_ssn].nil? && params[:document_ssn] == "111223333" wrap_in_struct(database[:create_evaluations][:requires_oow]) else wrap_in_struct(database[:create_evaluations][:success]) end end
fork_evaluation(path)
click to toggle source
# File lib/alloy/kyc/backends/mock.rb, line 40 def fork_evaluation(path) wrap_in_struct(database[:fork_evaluation][:success]) end
get_bearer_token()
click to toggle source
# File lib/alloy/kyc/backends/mock.rb, line 16 def get_bearer_token @bearer_token = BearerToken.new("access_token", Time.now + (60*60*24*365)) end
requires_bearer_token?()
click to toggle source
# File lib/alloy/kyc/backends/mock.rb, line 20 def requires_bearer_token? bearer_token.nil? || bearer_token.expired? end
submit_oow_responses(path, responses)
click to toggle source
# File lib/alloy/kyc/backends/mock.rb, line 32 def submit_oow_responses(path, responses) if responses[:document_ssn] == "111223333" wrap_in_struct(database[:submit_oow_responses][:requires_oow]) else wrap_in_struct(database[:submit_oow_responses][:success]) end end
Private Instance Methods
fake_create_evaluations_response_requires_oow()
click to toggle source
# File lib/alloy/kyc/backends/mock.rb, line 71 def fake_create_evaluations_response_requires_oow load_mock_data("fake_create_evaluations_response_requires_oow.json") end
fake_create_evaluations_response_success()
click to toggle source
# File lib/alloy/kyc/backends/mock.rb, line 75 def fake_create_evaluations_response_success load_mock_data("fake_create_evaluations_response_success.json") end
fake_fork_response_success()
click to toggle source
# File lib/alloy/kyc/backends/mock.rb, line 67 def fake_fork_response_success load_mock_data("fake_fork_response_success.json") end
generate_fake_data()
click to toggle source
# File lib/alloy/kyc/backends/mock.rb, line 51 def generate_fake_data { create_evaluations: { success: fake_create_evaluations_response_success, requires_oow: fake_create_evaluations_response_requires_oow }, submit_oow_responses: { success: fake_create_evaluations_response_success, requires_oow: fake_create_evaluations_response_requires_oow }, fork_evaluation: { success: fake_fork_response_success } } end
load_mock_data(filename)
click to toggle source
# File lib/alloy/kyc/backends/mock.rb, line 79 def load_mock_data(filename) # Would use Gem.datadir, but https://github.com/rubygems/rubygems/issues/1673 JSON.parse(File.read(Gem.loaded_specs['alloy-kyc'].full_gem_path + "/data/#{filename}")) end
wrap_in_struct(hash)
click to toggle source
# File lib/alloy/kyc/backends/mock.rb, line 46 def wrap_in_struct(hash) json = hash.to_json OpenStruct.new(raw_response: json, body: json) end