Class: CalendarApi::WorkingLocationProperties

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/calendar_api/models/working_location_properties.rb

Overview

Working location event data. Used if eventType is workingLocation.

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(type: SKIP, home_office: SKIP, office_location: SKIP, custom_location: SKIP, additional_properties: nil) ⇒ WorkingLocationProperties

Returns a new instance of WorkingLocationProperties.



54
55
56
57
58
59
60
61
62
63
64
# File 'lib/calendar_api/models/working_location_properties.rb', line 54

def initialize(type: SKIP, home_office: SKIP, office_location: SKIP,
               custom_location: SKIP, additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @type = type unless type == SKIP
  @home_office = home_office unless home_office == SKIP
  @office_location = office_location unless office_location == SKIP
  @custom_location = custom_location unless custom_location == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#custom_locationCustomLocation

Custom location details for a working location event.

Returns:



27
28
29
# File 'lib/calendar_api/models/working_location_properties.rb', line 27

def custom_location
  @custom_location
end

#home_officeObject

Indicates working from home. Present if type is homeOffice. Value is always an empty object.

Returns:

  • (Object)


19
20
21
# File 'lib/calendar_api/models/working_location_properties.rb', line 19

def home_office
  @home_office
end

#office_locationOfficeLocation

Office location details for a working location event.

Returns:



23
24
25
# File 'lib/calendar_api/models/working_location_properties.rb', line 23

def office_location
  @office_location
end

#typeWorkingLocationType

Type of working location.

Returns:



14
15
16
# File 'lib/calendar_api/models/working_location_properties.rb', line 14

def type
  @type
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# File 'lib/calendar_api/models/working_location_properties.rb', line 67

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  type = hash.key?('type') ? hash['type'] : SKIP
  home_office = hash.key?('homeOffice') ? hash['homeOffice'] : SKIP
  office_location = OfficeLocation.from_hash(hash['officeLocation']) if hash['officeLocation']
  custom_location = CustomLocation.from_hash(hash['customLocation']) if hash['customLocation']

  # 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.
  WorkingLocationProperties.new(type: type,
                                home_office: home_office,
                                office_location: office_location,
                                custom_location: custom_location,
                                additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



30
31
32
33
34
35
36
37
# File 'lib/calendar_api/models/working_location_properties.rb', line 30

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['type'] = 'type'
  @_hash['home_office'] = 'homeOffice'
  @_hash['office_location'] = 'officeLocation'
  @_hash['custom_location'] = 'customLocation'
  @_hash
end

.nullablesObject

An array for nullable fields



50
51
52
# File 'lib/calendar_api/models/working_location_properties.rb', line 50

def self.nullables
  []
end

.optionalsObject

An array for optional fields



40
41
42
43
44
45
46
47
# File 'lib/calendar_api/models/working_location_properties.rb', line 40

def self.optionals
  %w[
    type
    home_office
    office_location
    custom_location
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



100
101
102
103
104
105
# File 'lib/calendar_api/models/working_location_properties.rb', line 100

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

#to_sObject

Provides a human-readable string representation of the object.



92
93
94
95
96
97
# File 'lib/calendar_api/models/working_location_properties.rb', line 92

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