Class: UspsApi::RecurringAppointment

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/usps_api/models/recurring_appointment.rb

Overview

Must have either oneTimeAppointment or recurringAppointment

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json

Constructor Details

#initialize(effective_start_date: SKIP, effective_end_date: SKIP, appointment_time: SKIP, day_frequency_array: SKIP, week_frequency_array: SKIP, additional_properties: nil) ⇒ RecurringAppointment

Returns a new instance of RecurringAppointment.



60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/usps_api/models/recurring_appointment.rb', line 60

def initialize(effective_start_date: SKIP, effective_end_date: SKIP,
               appointment_time: SKIP, day_frequency_array: SKIP,
               week_frequency_array: SKIP, additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @effective_start_date = effective_start_date unless effective_start_date == SKIP
  @effective_end_date = effective_end_date unless effective_end_date == SKIP
  @appointment_time = appointment_time unless appointment_time == SKIP
  @day_frequency_array = day_frequency_array unless day_frequency_array == SKIP
  @week_frequency_array = week_frequency_array unless week_frequency_array == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#appointment_timeDateTime

Time of appointment in Local Time. Required for Create actions.

Returns:

  • (DateTime)


23
24
25
# File 'lib/usps_api/models/recurring_appointment.rb', line 23

def appointment_time
  @appointment_time
end

#day_frequency_arrayArray[DayFrequencyArray]

Day of the week for the appointment. Required for Create actions.

Returns:



27
28
29
# File 'lib/usps_api/models/recurring_appointment.rb', line 27

def day_frequency_array
  @day_frequency_array
end

#effective_end_dateDate

End date of appointment. Required for Create actions.

Returns:

  • (Date)


19
20
21
# File 'lib/usps_api/models/recurring_appointment.rb', line 19

def effective_end_date
  @effective_end_date
end

#effective_start_dateDate

Start date of appointment. Required for Create actions.

Returns:

  • (Date)


15
16
17
# File 'lib/usps_api/models/recurring_appointment.rb', line 15

def effective_start_date
  @effective_start_date
end

#week_frequency_arrayArray[WeekFrequencyArray]

Week of the month for the appointment. Required for Create actions.

Returns:



31
32
33
# File 'lib/usps_api/models/recurring_appointment.rb', line 31

def week_frequency_array
  @week_frequency_array
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
# File 'lib/usps_api/models/recurring_appointment.rb', line 75

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  effective_start_date =
    hash.key?('effectiveStartDate') ? hash['effectiveStartDate'] : SKIP
  effective_end_date =
    hash.key?('effectiveEndDate') ? hash['effectiveEndDate'] : SKIP
  appointment_time = if hash.key?('appointmentTime')
                       (DateTimeHelper.from_rfc3339(hash['appointmentTime']) if hash['appointmentTime'])
                     else
                       SKIP
                     end
  day_frequency_array =
    hash.key?('dayFrequencyArray') ? hash['dayFrequencyArray'] : SKIP
  week_frequency_array =
    hash.key?('weekFrequencyArray') ? hash['weekFrequencyArray'] : SKIP

  # Create a new hash for additional properties, removing known properties.
  new_hash = hash.reject { |k, _| names.value?(k) }

  additional_properties = APIHelper.get_additional_properties(
    new_hash, proc { |value| value }
  )

  # Create object from extracted values.
  RecurringAppointment.new(effective_start_date: effective_start_date,
                           effective_end_date: effective_end_date,
                           appointment_time: appointment_time,
                           day_frequency_array: day_frequency_array,
                           week_frequency_array: week_frequency_array,
                           additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



34
35
36
37
38
39
40
41
42
# File 'lib/usps_api/models/recurring_appointment.rb', line 34

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['effective_start_date'] = 'effectiveStartDate'
  @_hash['effective_end_date'] = 'effectiveEndDate'
  @_hash['appointment_time'] = 'appointmentTime'
  @_hash['day_frequency_array'] = 'dayFrequencyArray'
  @_hash['week_frequency_array'] = 'weekFrequencyArray'
  @_hash
end

.nullablesObject

An array for nullable fields



56
57
58
# File 'lib/usps_api/models/recurring_appointment.rb', line 56

def self.nullables
  []
end

.optionalsObject

An array for optional fields



45
46
47
48
49
50
51
52
53
# File 'lib/usps_api/models/recurring_appointment.rb', line 45

def self.optionals
  %w[
    effective_start_date
    effective_end_date
    appointment_time
    day_frequency_array
    week_frequency_array
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



123
124
125
126
127
128
129
# File 'lib/usps_api/models/recurring_appointment.rb', line 123

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} effective_start_date: #{@effective_start_date.inspect}, effective_end_date:"\
  " #{@effective_end_date.inspect}, appointment_time: #{@appointment_time.inspect},"\
  " day_frequency_array: #{@day_frequency_array.inspect}, week_frequency_array:"\
  " #{@week_frequency_array.inspect}, additional_properties: #{@additional_properties}>"
end

#to_custom_appointment_timeObject



109
110
111
# File 'lib/usps_api/models/recurring_appointment.rb', line 109

def to_custom_appointment_time
  DateTimeHelper.to_rfc3339(appointment_time)
end

#to_sObject

Provides a human-readable string representation of the object.



114
115
116
117
118
119
120
# File 'lib/usps_api/models/recurring_appointment.rb', line 114

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} effective_start_date: #{@effective_start_date}, effective_end_date:"\
  " #{@effective_end_date}, appointment_time: #{@appointment_time}, day_frequency_array:"\
  " #{@day_frequency_array}, week_frequency_array: #{@week_frequency_array},"\
  " additional_properties: #{@additional_properties}>"
end