Class: ShellCardManagementApIs::DayTimeRestrictions

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/shell_card_management_ap_is/models/day_time_restrictions.rb

Overview

DayTimeRestrictions Model.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#to_hash, #to_json

Constructor Details

#initialize(monday = SKIP, tuesday = SKIP, wednesday = SKIP, thursday = SKIP, friday = SKIP, saturday = SKIP, sunday = SKIP, time_from = SKIP, time_to = SKIP) ⇒ DayTimeRestrictions

Returns a new instance of DayTimeRestrictions.



91
92
93
94
95
96
97
98
99
100
101
102
103
# File 'lib/shell_card_management_ap_is/models/day_time_restrictions.rb', line 91

def initialize(monday = SKIP, tuesday = SKIP, wednesday = SKIP,
               thursday = SKIP, friday = SKIP, saturday = SKIP,
               sunday = SKIP, time_from = SKIP, time_to = SKIP)
  @monday = monday unless monday == SKIP
  @tuesday = tuesday unless tuesday == SKIP
  @wednesday = wednesday unless wednesday == SKIP
  @thursday = thursday unless thursday == SKIP
  @friday = friday unless friday == SKIP
  @saturday = saturday unless saturday == SKIP
  @sunday = sunday unless sunday == SKIP
  @time_from = time_from unless time_from == SKIP
  @time_to = time_to unless time_to == SKIP
end

Instance Attribute Details

#fridayTrueClass | FalseClass

True if card could be used on a Friday, else false

Returns:

  • (TrueClass | FalseClass)


30
31
32
# File 'lib/shell_card_management_ap_is/models/day_time_restrictions.rb', line 30

def friday
  @friday
end

#mondayTrueClass | FalseClass

True if card could be used on a Monday, else false

Returns:

  • (TrueClass | FalseClass)


14
15
16
# File 'lib/shell_card_management_ap_is/models/day_time_restrictions.rb', line 14

def monday
  @monday
end

#saturdayTrueClass | FalseClass

True if card could be used on a Saturday, else false

Returns:

  • (TrueClass | FalseClass)


34
35
36
# File 'lib/shell_card_management_ap_is/models/day_time_restrictions.rb', line 34

def saturday
  @saturday
end

#sundayTrueClass | FalseClass

True if card could be used on a Sunday, else false.

Returns:

  • (TrueClass | FalseClass)


38
39
40
# File 'lib/shell_card_management_ap_is/models/day_time_restrictions.rb', line 38

def sunday
  @sunday
end

#thursdayTrueClass | FalseClass

True if card could be used on a Thursday, else false

Returns:

  • (TrueClass | FalseClass)


26
27
28
# File 'lib/shell_card_management_ap_is/models/day_time_restrictions.rb', line 26

def thursday
  @thursday
end

#time_fromString

Card could be used from this time in a day. Format: HH:mm (24-hour format) Note:

  1. Clients to convert this to appropriate DateTime or TimeSpan type.

“00:00” is the lowest time value and “23:59” is the highest time value.

Returns:

  • (String)


46
47
48
# File 'lib/shell_card_management_ap_is/models/day_time_restrictions.rb', line 46

def time_from
  @time_from
end

#time_toString

Card could be used up to this time in a day. Format: HH:mm (24-hour format) Note:

  1. Clients to convert this to appropriate DateTime or TimeSpan type.

“00:00” is the lowest time value and “23:59” is the highest time value.

Returns:

  • (String)


54
55
56
# File 'lib/shell_card_management_ap_is/models/day_time_restrictions.rb', line 54

def time_to
  @time_to
end

#tuesdayTrueClass | FalseClass

True if card could be used on a Tuesday, else false.

Returns:

  • (TrueClass | FalseClass)


18
19
20
# File 'lib/shell_card_management_ap_is/models/day_time_restrictions.rb', line 18

def tuesday
  @tuesday
end

#wednesdayTrueClass | FalseClass

True if card could be used on a Wednesday, else false.

Returns:

  • (TrueClass | FalseClass)


22
23
24
# File 'lib/shell_card_management_ap_is/models/day_time_restrictions.rb', line 22

def wednesday
  @wednesday
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
# File 'lib/shell_card_management_ap_is/models/day_time_restrictions.rb', line 106

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  monday = hash.key?('Monday') ? hash['Monday'] : SKIP
  tuesday = hash.key?('Tuesday') ? hash['Tuesday'] : SKIP
  wednesday = hash.key?('Wednesday') ? hash['Wednesday'] : SKIP
  thursday = hash.key?('Thursday') ? hash['Thursday'] : SKIP
  friday = hash.key?('Friday') ? hash['Friday'] : SKIP
  saturday = hash.key?('Saturday') ? hash['Saturday'] : SKIP
  sunday = hash.key?('Sunday') ? hash['Sunday'] : SKIP
  time_from = hash.key?('TimeFrom') ? hash['TimeFrom'] : SKIP
  time_to = hash.key?('TimeTo') ? hash['TimeTo'] : SKIP

  # Create object from extracted values.
  DayTimeRestrictions.new(monday,
                          tuesday,
                          wednesday,
                          thursday,
                          friday,
                          saturday,
                          sunday,
                          time_from,
                          time_to)
end

.namesObject

A mapping from model property names to API property names.



57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/shell_card_management_ap_is/models/day_time_restrictions.rb', line 57

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['monday'] = 'Monday'
  @_hash['tuesday'] = 'Tuesday'
  @_hash['wednesday'] = 'Wednesday'
  @_hash['thursday'] = 'Thursday'
  @_hash['friday'] = 'Friday'
  @_hash['saturday'] = 'Saturday'
  @_hash['sunday'] = 'Sunday'
  @_hash['time_from'] = 'TimeFrom'
  @_hash['time_to'] = 'TimeTo'
  @_hash
end

.nullablesObject

An array for nullable fields



87
88
89
# File 'lib/shell_card_management_ap_is/models/day_time_restrictions.rb', line 87

def self.nullables
  []
end

.optionalsObject

An array for optional fields



72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/shell_card_management_ap_is/models/day_time_restrictions.rb', line 72

def self.optionals
  %w[
    monday
    tuesday
    wednesday
    thursday
    friday
    saturday
    sunday
    time_from
    time_to
  ]
end