Class: Unit::Types::Schedule

Inherits:
Object
  • Object
show all
Defined in:
lib/unit-ruby/types/schedule.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(schedule_params) ⇒ Schedule



8
9
10
11
12
13
14
15
16
# File 'lib/unit-ruby/types/schedule.rb', line 8

def initialize(schedule_params)
  @start_time = schedule_params[:start_time]
  @end_time = schedule_params[:end_time]
  @interval = schedule_params[:interval]
  @day_of_month = schedule_params[:day_of_month]
  @day_of_week = schedule_params[:day_of_week]
  @total_number_of_payments = schedule_params[:total_number_of_payments]
  @next_scheduled_action = schedule_params[:next_scheduled_action]
end

Instance Attribute Details

#day_of_monthObject (readonly)

Returns the value of attribute day_of_month.



4
5
6
# File 'lib/unit-ruby/types/schedule.rb', line 4

def day_of_month
  @day_of_month
end

#day_of_weekObject (readonly)

Returns the value of attribute day_of_week.



4
5
6
# File 'lib/unit-ruby/types/schedule.rb', line 4

def day_of_week
  @day_of_week
end

#end_timeObject (readonly)

Returns the value of attribute end_time.



4
5
6
# File 'lib/unit-ruby/types/schedule.rb', line 4

def end_time
  @end_time
end

#intervalObject (readonly)

Returns the value of attribute interval.



4
5
6
# File 'lib/unit-ruby/types/schedule.rb', line 4

def interval
  @interval
end

#next_scheduled_actionObject (readonly)

Returns the value of attribute next_scheduled_action.



4
5
6
# File 'lib/unit-ruby/types/schedule.rb', line 4

def next_scheduled_action
  @next_scheduled_action
end

#start_timeObject (readonly)

Returns the value of attribute start_time.



4
5
6
# File 'lib/unit-ruby/types/schedule.rb', line 4

def start_time
  @start_time
end

#total_number_of_paymentsObject (readonly)

Returns the value of attribute total_number_of_payments.



4
5
6
# File 'lib/unit-ruby/types/schedule.rb', line 4

def total_number_of_payments
  @total_number_of_payments
end

Class Method Details

.cast(val) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/unit-ruby/types/schedule.rb', line 18

def self.cast(val)
  return val if val.is_a? self
  return nil if val.nil?

  new(
    start_time: Unit::Types::Date.cast(val[:start_time]),
    end_time: Unit::Types::Date.cast(val[:end_time]),
    next_scheduled_action: Unit::Types::Date.cast(val[:next_scheduled_action]),
    interval: val[:interval],
    day_of_month: val[:day_of_month],
    day_of_week: val[:day_of_week],
    total_number_of_payments: val[:total_number_of_payments],
  )
end

Instance Method Details

#as_json_apiObject



33
34
35
36
37
38
39
40
41
42
# File 'lib/unit-ruby/types/schedule.rb', line 33

def as_json_api
  {
    start_time: Unit::Types::Date.as_json_api(start_time),
    end_time: Unit::Types::Date.as_json_api(end_time),
    interval: interval,
    day_of_month: day_of_month,
    day_of_week: day_of_week,
    total_number_of_payments: total_number_of_payments
  }.compact
end