synapsepayments/synapse_pay-ruby

View on GitHub
lib/synapse_pay/endpoints/bank_mfa_questions_endpoint.rb

Summary

Maintainability
A
2 hrs
Test Coverage
module SynapsePay
  class BankMfaQuestionsEndpoint < APIEndpoint
    
    def answer(access_token, bank, mfa, params={}, headers={})
      params = ParamsBuilder.merge({
        :access_token => access_token,
        :bank => bank,
        :mfa => mfa,
      }, params)
      method = APIMethod.new(:post, "/bank/mfa", params, headers, self)
      json = @client.execute(method)
      if(json[:is_mfa] && json[:response][:type] == "questions")
        BankMfaQuestions.new(json[:response], method, @client)
      elsif(json[:is_mfa] && json[:response][:type] == "device")
        BankMfaDevice.new(json[:response], method, @client)
      else
        APIList.new(:Bank, json[:banks], method, @client)
      end
    end

  end
end