Sha256: effca8e200a01018e2559eaa06c31dda8a67cb13818cdd6db75df09bd65b943b

Contents?: true

Size: 655 Bytes

Versions: 7

Compression:

Stored size: 655 Bytes

Contents

module Sisow
  class Issuer
    attr_accessor :id, :name

    def self.list
      @list ||= find_all_from_api
    end

    def self.find(issuer_id)
      list.select { |issuer| issuer.id.to_i == issuer_id.to_i }.first
    end

    def initialize(attributes = {})
      @id   = attributes[:id]
      @name = attributes[:name]
    end

    private

    def self.find_all_from_api
      hash = Sisow::Api::DirectoryRequest.perform

      hash.issuer = [ hash.issuer ] unless hash.issuer.is_a?(Array)

      hash.issuer.map do |issuer|
        new(
          :id => issuer.issuerid,
          :name => issuer.issuername
        )
      end
    end

  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
sisow-1.7 lib/sisow/issuer.rb
sisow-1.6 lib/sisow/issuer.rb
sisow-1.5 lib/sisow/issuer.rb
sisow-1.4 lib/sisow/issuer.rb
sisow-1.3 lib/sisow/issuer.rb
sisow-1.2 lib/sisow/issuer.rb
sisow-1.1.1 lib/sisow/issuer.rb