Class: ShellCardManagementApIs::DayTimeRestriction

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

Overview

Details of the day/time restrictions such as weekdays and time range in which transactions should be allowed on the card.

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) ⇒ DayTimeRestriction

Returns a new instance of DayTimeRestriction.



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

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)


31
32
33
# File 'lib/shell_card_management_ap_is/models/day_time_restriction.rb', line 31

def friday
  @friday
end

#mondayTrueClass | FalseClass

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

Returns:

  • (TrueClass | FalseClass)


15
16
17
# File 'lib/shell_card_management_ap_is/models/day_time_restriction.rb', line 15

def monday
  @monday
end

#saturdayTrueClass | FalseClass

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

Returns:

  • (TrueClass | FalseClass)


35
36
37
# File 'lib/shell_card_management_ap_is/models/day_time_restriction.rb', line 35

def saturday
  @saturday
end

#sundayTrueClass | FalseClass

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

Returns:

  • (TrueClass | FalseClass)


39
40
41
# File 'lib/shell_card_management_ap_is/models/day_time_restriction.rb', line 39

def sunday
  @sunday
end

#thursdayTrueClass | FalseClass

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

Returns:

  • (TrueClass | FalseClass)


27
28
29
# File 'lib/shell_card_management_ap_is/models/day_time_restriction.rb', line 27

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)


47
48
49
# File 'lib/shell_card_management_ap_is/models/day_time_restriction.rb', line 47

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)


55
56
57
# File 'lib/shell_card_management_ap_is/models/day_time_restriction.rb', line 55

def time_to
  @time_to
end

#tuesdayTrueClass | FalseClass

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

Returns:

  • (TrueClass | FalseClass)


19
20
21
# File 'lib/shell_card_management_ap_is/models/day_time_restriction.rb', line 19

def tuesday
  @tuesday
end

#wednesdayTrueClass | FalseClass

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

Returns:

  • (TrueClass | FalseClass)


23
24
25
# File 'lib/shell_card_management_ap_is/models/day_time_restriction.rb', line 23

def wednesday
  @wednesday
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



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

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.
  DayTimeRestriction.new(monday,
                         tuesday,
                         wednesday,
                         thursday,
                         friday,
                         saturday,
                         sunday,
                         time_from,
                         time_to)
end

.namesObject

A mapping from model property names to API property names.



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

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



88
89
90
# File 'lib/shell_card_management_ap_is/models/day_time_restriction.rb', line 88

def self.nullables
  []
end

.optionalsObject

An array for optional fields



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

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