Sha256: 4f1ae2007f014399b6e16f3558658eb3ac6c9019131ea508d3371247e36c4b3f

Contents?: true

Size: 940 Bytes

Versions: 15

Compression:

Stored size: 940 Bytes

Contents

# frozen_string_literal: true

module Bs2Api
  module Entities
    class Bank
      attr_accessor :ispb, :account, :customer

      def initialize(args = {})
        @ispb     = args.fetch(:ispb, nil)
        @account  = args.fetch(:account, nil)
        @customer = args.fetch(:customer, nil)
      end

      def to_hash
        ActiveSupport::HashWithIndifferentAccess.new(
          {
            "ispb": @ispb,
            "conta": @account.to_hash,
            "pessoa": @customer.to_hash
          }
        )
      end

      def self.from_response(hash_payload)
        return if hash_payload.blank?
        hash = ActiveSupport::HashWithIndifferentAccess.new(hash_payload)

        Bs2Api::Entities::Bank.new(
          ispb: hash["ispb"],
          account: Bs2Api::Entities::Account.from_response(hash["conta"]),
          customer: Bs2Api::Entities::Customer.from_response(hash["pessoa"])
        )
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
bs2_api-1.9.0 lib/bs2_api/entities/bank.rb
bs2_api-1.8.0 lib/bs2_api/entities/bank.rb
bs2_api-1.7.0 lib/bs2_api/entities/bank.rb
bs2_api-1.6.2 lib/bs2_api/entities/bank.rb
bs2_api-1.6.1 lib/bs2_api/entities/bank.rb
bs2_api-1.6.0 lib/bs2_api/entities/bank.rb
bs2_api-1.5.1 lib/bs2_api/entities/bank.rb
bs2_api-1.5.0 lib/bs2_api/entities/bank.rb
bs2_api-1.4.3 lib/bs2_api/entities/bank.rb
bs2_api-1.4.2 lib/bs2_api/entities/bank.rb
bs2_api-1.4.1 lib/bs2_api/entities/bank.rb
bs2_api-1.4.0 lib/bs2_api/entities/bank.rb
bs2_api-1.2.2 lib/bs2_api/entities/bank.rb
bs2_api-1.2.1 lib/bs2_api/entities/bank.rb
bs2_api-1.2.0 lib/bs2_api/entities/bank.rb