Class: WhatsAppCloudApi::DateTimeObject

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/whats_app_cloud_api/models/date_time_object.rb

Overview

DateTimeObject Model.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#to_hash, #to_json

Constructor Details

#initialize(fallback_value = nil, day_of_week = nil, year = nil, month = nil, day_of_month = nil, hour = nil, minute = nil, calendar = nil) ⇒ DateTimeObject

Returns a new instance of DateTimeObject.



84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# File 'lib/whats_app_cloud_api/models/date_time_object.rb', line 84

def initialize(fallback_value = nil,
               day_of_week = nil,
               year = nil,
               month = nil,
               day_of_month = nil,
               hour = nil,
               minute = nil,
               calendar = nil)
  @fallback_value = fallback_value unless fallback_value == SKIP
  @day_of_week = day_of_week unless day_of_week == SKIP
  @year = year unless year == SKIP
  @month = month unless month == SKIP
  @day_of_month = day_of_month unless day_of_month == SKIP
  @hour = hour unless hour == SKIP
  @minute = minute unless minute == SKIP
  @calendar = calendar unless calendar == SKIP
end

Instance Attribute Details

#calendarString

Default text. For Cloud API, we always use the fallback value, and we do not attempt to localize using other optional fields.

Returns:

  • (String)


50
51
52
# File 'lib/whats_app_cloud_api/models/date_time_object.rb', line 50

def calendar
  @calendar
end

#day_of_monthInteger

Default text. For Cloud API, we always use the fallback value, and we do not attempt to localize using other optional fields.

Returns:

  • (Integer)


35
36
37
# File 'lib/whats_app_cloud_api/models/date_time_object.rb', line 35

def day_of_month
  @day_of_month
end

#day_of_weekInteger

Default text. For Cloud API, we always use the fallback value, and we do not attempt to localize using other optional fields.

Returns:

  • (Integer)


20
21
22
# File 'lib/whats_app_cloud_api/models/date_time_object.rb', line 20

def day_of_week
  @day_of_week
end

#fallback_valueString

Default text. For Cloud API, we always use the fallback value, and we do not attempt to localize using other optional fields.

Returns:

  • (String)


15
16
17
# File 'lib/whats_app_cloud_api/models/date_time_object.rb', line 15

def fallback_value
  @fallback_value
end

#hourInteger

Default text. For Cloud API, we always use the fallback value, and we do not attempt to localize using other optional fields.

Returns:

  • (Integer)


40
41
42
# File 'lib/whats_app_cloud_api/models/date_time_object.rb', line 40

def hour
  @hour
end

#minuteInteger

Default text. For Cloud API, we always use the fallback value, and we do not attempt to localize using other optional fields.

Returns:

  • (Integer)


45
46
47
# File 'lib/whats_app_cloud_api/models/date_time_object.rb', line 45

def minute
  @minute
end

#monthInteger

Default text. For Cloud API, we always use the fallback value, and we do not attempt to localize using other optional fields.

Returns:

  • (Integer)


30
31
32
# File 'lib/whats_app_cloud_api/models/date_time_object.rb', line 30

def month
  @month
end

#yearInteger

Default text. For Cloud API, we always use the fallback value, and we do not attempt to localize using other optional fields.

Returns:

  • (Integer)


25
26
27
# File 'lib/whats_app_cloud_api/models/date_time_object.rb', line 25

def year
  @year
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
# File 'lib/whats_app_cloud_api/models/date_time_object.rb', line 103

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  fallback_value =
    hash.key?('fallback_value') ? hash['fallback_value'] : SKIP
  day_of_week = hash.key?('day_of_week') ? hash['day_of_week'] : SKIP
  year = hash.key?('year') ? hash['year'] : SKIP
  month = hash.key?('month') ? hash['month'] : SKIP
  day_of_month = hash.key?('day_of_month') ? hash['day_of_month'] : SKIP
  hour = hash.key?('hour') ? hash['hour'] : SKIP
  minute = hash.key?('minute') ? hash['minute'] : SKIP
  calendar = hash.key?('calendar') ? hash['calendar'] : SKIP

  # Create object from extracted values.
  DateTimeObject.new(fallback_value,
                     day_of_week,
                     year,
                     month,
                     day_of_month,
                     hour,
                     minute,
                     calendar)
end

.namesObject

A mapping from model property names to API property names.



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

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['fallback_value'] = 'fallback_value'
  @_hash['day_of_week'] = 'day_of_week'
  @_hash['year'] = 'year'
  @_hash['month'] = 'month'
  @_hash['day_of_month'] = 'day_of_month'
  @_hash['hour'] = 'hour'
  @_hash['minute'] = 'minute'
  @_hash['calendar'] = 'calendar'
  @_hash
end

Instance Method Details

#nullablesObject

An array for nullable fields



80
81
82
# File 'lib/whats_app_cloud_api/models/date_time_object.rb', line 80

def nullables
  []
end

#optionalsObject

An array for optional fields



67
68
69
70
71
72
73
74
75
76
77
# File 'lib/whats_app_cloud_api/models/date_time_object.rb', line 67

def optionals
  %w[
    day_of_week
    year
    month
    day_of_month
    hour
    minute
    calendar
  ]
end