Sha256: f71db0c5c783cb42457ac71d0ba4c6891eb1e36d04a7c8ec4b5fa7194e827f62

Contents?: true

Size: 710 Bytes

Versions: 3

Compression:

Stored size: 710 Bytes

Contents

# frozen_string_literal: true

require "credit_card_bins"

module CreditCardInfo
  module Providers
    class CreditCardBins
      def self.fetch(code)
        bin = CreditCardBin.new(code)
        CreditCardInfo::Response.new(
          data: {
            bin:         bin.bin,
            bank:        bin.issuer,
            card:        bin.brand,
            type:        bin.type,
            level:       bin.category,
            country:     bin.data.dig("country", "name"),
            countrycode: bin.data.dig("country", "alpha_2")
          }
        )
      rescue StandardError => e
        CreditCardInfo::Response.new(error: { code: e.class, message: e.message })
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
credit_card_info-0.2.0 lib/credit_card_info/providers/credit_card_bins.rb
credit_card_info-0.1.1 lib/credit_card_info/providers/credit_card_bins.rb
credit_card_info-0.1.0 lib/credit_card_info/providers/credit_card_bins.rb