Class: UspsApi::OptionalAppointment

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

Overview

Details of the optional appointment start and end time.

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(optional_appointment_start: SKIP, optional_appointment_end: SKIP, additional_properties: nil) ⇒ OptionalAppointment

Returns a new instance of OptionalAppointment.



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

def initialize(optional_appointment_start: SKIP,
               optional_appointment_end: SKIP, additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  unless optional_appointment_start == SKIP
    @optional_appointment_start =
      optional_appointment_start
  end
  @optional_appointment_end = optional_appointment_end unless optional_appointment_end == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#optional_appointment_endDateTime

Optional appointment end date and time in ISO 8601 format

Returns:

  • (DateTime)


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

def optional_appointment_end
  @optional_appointment_end
end

#optional_appointment_startDateTime

Optional appointment start date and time in ISO 8601 format

Returns:

  • (DateTime)


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

def optional_appointment_start
  @optional_appointment_start
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/usps_api/models/optional_appointment.rb', line 56

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  optional_appointment_start = if hash.key?('optionalAppointmentStart')
                                 (DateTimeHelper.from_rfc3339(hash['optionalAppointmentStart']) if hash['optionalAppointmentStart'])
                               else
                                 SKIP
                               end
  optional_appointment_end = if hash.key?('optionalAppointmentEnd')
                               (DateTimeHelper.from_rfc3339(hash['optionalAppointmentEnd']) if hash['optionalAppointmentEnd'])
                             else
                               SKIP
                             end

  # 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.
  OptionalAppointment.new(optional_appointment_start: optional_appointment_start,
                          optional_appointment_end: optional_appointment_end,
                          additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



22
23
24
25
26
27
# File 'lib/usps_api/models/optional_appointment.rb', line 22

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['optional_appointment_start'] = 'optionalAppointmentStart'
  @_hash['optional_appointment_end'] = 'optionalAppointmentEnd'
  @_hash
end

.nullablesObject

An array for nullable fields



38
39
40
# File 'lib/usps_api/models/optional_appointment.rb', line 38

def self.nullables
  []
end

.optionalsObject

An array for optional fields



30
31
32
33
34
35
# File 'lib/usps_api/models/optional_appointment.rb', line 30

def self.optionals
  %w[
    optional_appointment_start
    optional_appointment_end
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



101
102
103
104
105
106
# File 'lib/usps_api/models/optional_appointment.rb', line 101

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} optional_appointment_start: #{@optional_appointment_start.inspect},"\
  " optional_appointment_end: #{@optional_appointment_end.inspect}, additional_properties:"\
  " #{@additional_properties}>"
end

#to_custom_optional_appointment_endObject



88
89
90
# File 'lib/usps_api/models/optional_appointment.rb', line 88

def to_custom_optional_appointment_end
  DateTimeHelper.to_rfc3339(optional_appointment_end)
end

#to_custom_optional_appointment_startObject



84
85
86
# File 'lib/usps_api/models/optional_appointment.rb', line 84

def to_custom_optional_appointment_start
  DateTimeHelper.to_rfc3339(optional_appointment_start)
end

#to_sObject

Provides a human-readable string representation of the object.



93
94
95
96
97
98
# File 'lib/usps_api/models/optional_appointment.rb', line 93

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} optional_appointment_start: #{@optional_appointment_start},"\
  " optional_appointment_end: #{@optional_appointment_end}, additional_properties:"\
  " #{@additional_properties}>"
end