Class: Cielo::API30::RecurrentPayment

Inherits:
Object
  • Object
show all
Defined in:
lib/cielo/api30/recurrent_payment.rb

Constant Summary collapse

INTERVAL_MONTHLY =
"Monthly"
INTERVAL_BIMONTHLY =
"Bimonthly"
INTERVAL_QUARTERLY =
"Quarterly"
INTERVAL_SEMIANNUAL =
"SemiAnnual"
INTERVAL_ANNUAL =
"Annual"

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(authorize_now = true) ⇒ RecurrentPayment



15
16
17
# File 'lib/cielo/api30/recurrent_payment.rb', line 15

def initialize(authorize_now=true)
  @authorize_now = authorize_now
end

Instance Attribute Details

#authorize_nowObject

Returns the value of attribute authorize_now.



10
11
12
# File 'lib/cielo/api30/recurrent_payment.rb', line 10

def authorize_now
  @authorize_now
end

#end_dateObject

Returns the value of attribute end_date.



10
11
12
# File 'lib/cielo/api30/recurrent_payment.rb', line 10

def end_date
  @end_date
end

#intervalObject

Returns the value of attribute interval.



10
11
12
# File 'lib/cielo/api30/recurrent_payment.rb', line 10

def interval
  @interval
end

#start_dateObject

Returns the value of attribute start_date.



10
11
12
# File 'lib/cielo/api30/recurrent_payment.rb', line 10

def start_date
  @start_date
end

Class Method Details

.from_json(data) ⇒ Object



25
26
27
28
29
30
31
32
33
# File 'lib/cielo/api30/recurrent_payment.rb', line 25

def self.from_json(data)
  return if data.nil?

  recurrent_payment = new(data["AuthorizeNow"])
  recurrent_payment.start_date =data["StartDate"]
  recurrent_payment.end_date =data["EndDate"]
  recurrent_payment.interval =data["Interval"]
  recurrent_payment
end

Instance Method Details

#as_json(options = {}) ⇒ Object



35
36
37
38
39
40
41
42
# File 'lib/cielo/api30/recurrent_payment.rb', line 35

def as_json(options={})
  {
    AuthorizeNow: @authorize_now,
    StartDate: @start_date,
    EndDate: @end_date,
    Interval: @interval
  }
end

#to_json(*options) ⇒ Object



19
20
21
22
23
# File 'lib/cielo/api30/recurrent_payment.rb', line 19

def to_json(*options)
  hash = as_json(*options)
  hash.reject! {|k,v| v.nil?}
  hash.to_json(*options)
end