Sha256: 4ecd7eb39fd1157485536971ca75d5483fb5bb15c0287dedcdfc8ade810b652a

Contents?: true

Size: 1.3 KB

Versions: 3

Compression:

Stored size: 1.3 KB

Contents

module Braintree
  class UsBankAccountVerificationGateway
    def initialize(gateway)
      @gateway = gateway
      @config = gateway.config
      @config.assert_has_access_token_or_keys
    end

    def find(id)
      raise ArgumentError if id.nil? || id.to_s.strip == ""
      response = @config.http.get("#{@config.base_merchant_path}/us_bank_account_verifications/#{id}")
      UsBankAccountVerification._new(response[:us_bank_account_verification])
    rescue NotFoundError
      raise NotFoundError, "verification with id #{id.inspect} not found"
    end

    def search(&block)
      search = UsBankAccountVerificationSearch.new
      block.call(search) if block

      response = @config.http.post("#{@config.base_merchant_path}/us_bank_account_verifications/advanced_search_ids", {:search => search.to_hash})
      ResourceCollection.new(response) { |ids| _fetch_verifications(search, ids) }
    end

    def _fetch_verifications(search, ids)
      search.ids.in ids
      response = @config.http.post("#{@config.base_merchant_path}/us_bank_account_verifications/advanced_search", {:search => search.to_hash})
      attributes = response[:us_bank_account_verifications]
      Util.extract_attribute_as_array(attributes, :us_bank_account_verification).map { |attrs| UsBankAccountVerification._new(attrs) }
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
braintree-2.87.0 lib/braintree/us_bank_account_verification_gateway.rb
braintree-2.86.0 lib/braintree/us_bank_account_verification_gateway.rb
braintree-2.85.0 lib/braintree/us_bank_account_verification_gateway.rb