Sha256: 019251a15a2ff72bba2ca91c1405973e4affd741bcc937ca63a6a58dd8230ed2

Contents?: true

Size: 984 Bytes

Versions: 5

Compression:

Stored size: 984 Bytes

Contents

module Loopiator
  module Models
    
    #https://www.loopia.se/api/domain_obj/
    class Domain
      attr_accessor :domain, :paid, :registered, :renewal_status, :expiration_date, :reference_number, :unpaid_amount
      
      def initialize(hash)
        hash.symbolize_keys!
        
        self.domain             =   hash.fetch(:domain, "")
        self.paid               =   hash.fetch(:paid, 0).eql?(1)
        self.registered         =   hash.fetch(:registered, 0).eql?(1)
        self.renewal_status     =   hash.fetch(:renewal_status, "")
        self.expiration_date    =   hash.fetch(:expiration_date, "")
        self.reference_number   =   hash.fetch(:reference_no, "").to_s
        self.unpaid_amount      =   hash.fetch(:unpaid_amount, 0)
      end
      
      def paid?
        paid
      end
      
      def registered?
        registered
      end
      
      def needs_to_be_paid?
        (!paid? && unpaid_amount > 0)
      end
      
    end
    
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
loopiator-0.3.8 lib/loopiator/models/domain.rb
loopiator-0.3.7 lib/loopiator/models/domain.rb
loopiator-0.3.6 lib/loopiator/models/domain.rb
loopiator-0.3.5 lib/loopiator/models/domain.rb
loopiator-0.3.4 lib/loopiator/models/domain.rb