Class: Courier::Profiles::SnoozeRule
- Inherits:
-
Object
- Object
- Courier::Profiles::SnoozeRule
- Defined in:
- lib/trycourier/profiles/types/snooze_rule.rb
Instance Attribute Summary collapse
-
#additional_properties ⇒ Object
readonly
Returns the value of attribute additional_properties.
-
#start ⇒ Object
readonly
Returns the value of attribute start.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
-
#until_ ⇒ Object
readonly
Returns the value of attribute until_.
Class Method Summary collapse
-
.from_json(json_object:) ⇒ Profiles::SnoozeRule
Deserialize a JSON object to an instance of SnoozeRule.
-
.validate_raw(obj:) ⇒ Void
Leveraged for Union-type generation, validate_raw attempts to parse the given hash and check each fields type against the current object’s property definitions.
Instance Method Summary collapse
- #initialize(type:, start:, until_:, additional_properties: nil) ⇒ Profiles::SnoozeRule constructor
-
#to_json(*_args) ⇒ JSON
Serialize an instance of SnoozeRule to a JSON object.
Constructor Details
#initialize(type:, start:, until_:, additional_properties: nil) ⇒ Profiles::SnoozeRule
16 17 18 19 20 21 22 23 24 25 |
# File 'lib/trycourier/profiles/types/snooze_rule.rb', line 16 def initialize(type:, start:, until_:, additional_properties: nil) # @type [Profiles::SnoozeRuleType] @type = type # @type [String] @start = start # @type [String] @until_ = until_ # @type [OpenStruct] Additional properties unmapped to the current class definition @additional_properties = additional_properties end |
Instance Attribute Details
#additional_properties ⇒ Object (readonly)
Returns the value of attribute additional_properties.
9 10 11 |
# File 'lib/trycourier/profiles/types/snooze_rule.rb', line 9 def additional_properties @additional_properties end |
#start ⇒ Object (readonly)
Returns the value of attribute start.
9 10 11 |
# File 'lib/trycourier/profiles/types/snooze_rule.rb', line 9 def start @start end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
9 10 11 |
# File 'lib/trycourier/profiles/types/snooze_rule.rb', line 9 def type @type end |
#until_ ⇒ Object (readonly)
Returns the value of attribute until_.
9 10 11 |
# File 'lib/trycourier/profiles/types/snooze_rule.rb', line 9 def until_ @until_ end |
Class Method Details
.from_json(json_object:) ⇒ Profiles::SnoozeRule
Deserialize a JSON object to an instance of SnoozeRule
31 32 33 34 35 36 37 38 |
# File 'lib/trycourier/profiles/types/snooze_rule.rb', line 31 def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) JSON.parse(json_object) type = struct.type start = struct.start until_ = struct.until new(type: type, start: start, until_: until_, additional_properties: struct) end |
.validate_raw(obj:) ⇒ Void
Leveraged for Union-type generation, validate_raw attempts to parse the given hash and check each fields type against the current object’s property definitions.
51 52 53 54 55 |
# File 'lib/trycourier/profiles/types/snooze_rule.rb', line 51 def self.validate_raw(obj:) obj.type.is_a?(Profiles::SnoozeRuleType) != false || raise("Passed value for field obj.type is not the expected type, validation failed.") obj.start.is_a?(String) != false || raise("Passed value for field obj.start is not the expected type, validation failed.") obj.until_.is_a?(String) != false || raise("Passed value for field obj.until_ is not the expected type, validation failed.") end |
Instance Method Details
#to_json(*_args) ⇒ JSON
Serialize an instance of SnoozeRule to a JSON object
43 44 45 |
# File 'lib/trycourier/profiles/types/snooze_rule.rb', line 43 def to_json(*_args) { "type": @type, "start": @start, "until": @until_ }.to_json end |