Class: Courier::Profiles::SnoozeRule

Inherits:
Object
  • Object
show all
Defined in:
lib/trycourier/profiles/types/snooze_rule.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type:, start:, until_:, additional_properties: nil) ⇒ Profiles::SnoozeRule

Parameters:

  • type (Profiles::SnoozeRuleType)
  • start (String)
  • until_ (String)
  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



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_propertiesObject (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

#startObject (readonly)

Returns the value of attribute start.



9
10
11
# File 'lib/trycourier/profiles/types/snooze_rule.rb', line 9

def start
  @start
end

#typeObject (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

Parameters:

  • json_object (JSON)

Returns:



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.

Parameters:

  • obj (Object)

Returns:

  • (Void)


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

Returns:

  • (JSON)


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