Sha256: 655fe005b83af1238f0c2e36b0bea8720b97128b3e497e558b3da76fd6eb3fe3

Contents?: true

Size: 854 Bytes

Versions: 6

Compression:

Stored size: 854 Bytes

Contents

module PagSeguro
  class Shipping
    include ActiveModel::Validations
    
    PAC = 1
    SEDEX = 2
    NOT_IDENTIFIED = 3
    
    validates_format_of :postal_code, with: /^\d{8}$/, message: " must be an integer with 8 digits", allow_blank: true
    
    attr_accessor :type, :state, :city, :postal_code, :district, :street, :number, :complement, :cost
    
    def initialize(attributes = {})
      @type = attributes[:type]
      @state = attributes[:state]
      @city = attributes[:city]
      @postal_code = attributes[:postal_code]
      @district = attributes[:district]
      @street = attributes[:street]
      @number = attributes[:number]
      @complement = attributes[:complement]
      @cost = attributes[:cost]
    end
    
    def postal_code
      @postal_code if @postal_code.present? && @postal_code.to_s.size == 8
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
pag_seguro-0.1.6 lib/pag_seguro/shipping.rb
pag_seguro-0.1.4 lib/pag_seguro/shipping.rb
pag_seguro-0.1.3 lib/pag_seguro/shipping.rb
pag_seguro-0.1.2 lib/pag_seguro/shipping.rb
pag_seguro-0.1.1 lib/pag_seguro/shipping.rb
pag_seguro-0.1.0 lib/pag_seguro/shipping.rb