Sha256: 90e21f8e8b4621bbe928ae1080f20c0a88ab842393be9ec5ab9c5085ea1beff4

Contents?: true

Size: 1.41 KB

Versions: 3

Compression:

Stored size: 1.41 KB

Contents

module Afterbanks
  class Bank < Resource
    has_fields country_code: :string,
               service: :string,
               swift: :string,
               fullname: :string,
               business: :boolean,
               documenttype: :string,
               user: :string,
               pass: :string,
               pass2: :string,
               userdesc: :string,
               passdesc: :string,
               pass2desc: :string,
               usertype: :string,
               passtype: :string,
               pass2type: :string,
               image: :string,
               color: :string

    def self.list(ordered: false)
      response, debug_id = Afterbanks.api_call(
        method: :get,
        path: '/forms/'
      )

      if ordered
        response.sort! do |bank1, bank2|
          bank1['fullname'].downcase <=> bank2['fullname'].downcase
        end
      end

      Response.new(
        result: Collection.new(
          banks_information_for(
            response: response
          ),
          self
        ),
        debug_id: debug_id
      )
    end

    private

    def self.banks_information_for(response:)
      banks_information = []

      response.each do |bank_information|
        if bank_information['business'] == "1"
          bank_information['fullname'] += " Empresas"
        end

        banks_information << bank_information
      end

      banks_information
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
afterbanks-api-ruby-0.2.0 lib/afterbanks/resources/bank.rb
afterbanks-api-ruby-0.1.1 lib/afterbanks/resources/bank.rb
afterbanks-api-ruby-0.1.0 lib/afterbanks/resources/bank.rb