Sha256: 2bb8765daa356699822dac4a26946da7774526250b24a63283643142c3fc4089
Contents?: true
Size: 1.43 KB
Versions: 4
Compression:
Stored size: 1.43 KB
Contents
module RubyPsigate class InvalidRecurringItem < RubyPsigateError; end # This class encapsulates the recurring charge elements for use in the Account Class class RecurringCharge include HashVariables hashable %w( RBCID RBName Interval RBTrigger ProcessType Status StartTime EndTime ) attr_accessor :rbcid, :rbname, :interval, :rbtrigger, :status, :starttime, :endtime, :processtype def initialize(attributes = {}) @rbcid = attributes[:rbcid] @rbname = attributes[:rbname] @interval = attributes[:interval] @rbtrigger = attributes[:rbtrigger] @status = attributes[:status] @starttime = attributes[:starttime] @endtime = attributes[:endtime] @processtype = attributes[:processtype] @items = [] end def to_hash @return_hash = super unless items.count == 0 @return_hash[:ItemInfo] = [] items.each do |item| @return_hash[:ItemInfo] << item.to_hash end end @return_hash = @return_hash.delete_if { |key, value| value.nil? } # Delete empty hash values @return_hash end def << (item) raise InvalidRecurringItem unless item.is_a?(RecurringItem) @items << item return self end def items holder = [] @items.each do |item| holder << item.to_hash end holder end end end
Version data entries
4 entries across 4 versions & 1 rubygems