Class: RubyPsigate::RecurringCharge

Inherits:
Object
  • Object
show all
Includes:
HashVariables
Defined in:
lib/ruby_psigate/recurring_charge.rb

Overview

This class encapsulates the recurring charge elements for use in the Account Class

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from HashVariables

included

Constructor Details

#initialize(attributes = {}) ⇒ RecurringCharge

Returns a new instance of RecurringCharge.



13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/ruby_psigate/recurring_charge.rb', line 13

def initialize(attributes = {})
  @storeid      = attributes[:storeid]
  @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

Instance Attribute Details

#endtimeObject

Returns the value of attribute endtime.



11
12
13
# File 'lib/ruby_psigate/recurring_charge.rb', line 11

def endtime
  @endtime
end

#intervalObject

Returns the value of attribute interval.



11
12
13
# File 'lib/ruby_psigate/recurring_charge.rb', line 11

def interval
  @interval
end

#processtypeObject

Returns the value of attribute processtype.



11
12
13
# File 'lib/ruby_psigate/recurring_charge.rb', line 11

def processtype
  @processtype
end

#rbcidObject

Returns the value of attribute rbcid.



11
12
13
# File 'lib/ruby_psigate/recurring_charge.rb', line 11

def rbcid
  @rbcid
end

#rbnameObject

Returns the value of attribute rbname.



11
12
13
# File 'lib/ruby_psigate/recurring_charge.rb', line 11

def rbname
  @rbname
end

#rbtriggerObject

Returns the value of attribute rbtrigger.



11
12
13
# File 'lib/ruby_psigate/recurring_charge.rb', line 11

def rbtrigger
  @rbtrigger
end

#starttimeObject

Returns the value of attribute starttime.



11
12
13
# File 'lib/ruby_psigate/recurring_charge.rb', line 11

def starttime
  @starttime
end

#statusObject

Returns the value of attribute status.



11
12
13
# File 'lib/ruby_psigate/recurring_charge.rb', line 11

def status
  @status
end

#storeidObject

Returns the value of attribute storeid.



11
12
13
# File 'lib/ruby_psigate/recurring_charge.rb', line 11

def storeid
  @storeid
end

Instance Method Details

#<<(item) ⇒ Object



39
40
41
42
43
# File 'lib/ruby_psigate/recurring_charge.rb', line 39

def << (item)
  raise InvalidRecurringItem unless item.is_a?(RecurringItem)
  @items << item
  return self
end

#itemsObject



45
46
47
48
49
50
51
# File 'lib/ruby_psigate/recurring_charge.rb', line 45

def items
  holder = []
  @items.each do |item|
    holder << item.to_hash
  end
  holder
end

#to_hashObject



26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/ruby_psigate/recurring_charge.rb', line 26

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