Class: Courier::Notifications::BaseCheck

Inherits:
Object
  • Object
show all
Defined in:
lib/trycourier/notifications/types/base_check.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id:, status:, type:, additional_properties: nil) ⇒ Notifications::BaseCheck

Parameters:

  • id (String)
  • status (Notifications::CheckStatus)
  • type (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/notifications/types/base_check.rb', line 16

def initialize(id:, status:, type:, additional_properties: nil)
  # @type [String]
  @id = id
  # @type [Notifications::CheckStatus]
  @status = status
  # @type [String]
  @type = type
  # @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/notifications/types/base_check.rb', line 9

def additional_properties
  @additional_properties
end

#idObject (readonly)

Returns the value of attribute id.



9
10
11
# File 'lib/trycourier/notifications/types/base_check.rb', line 9

def id
  @id
end

#statusObject (readonly)

Returns the value of attribute status.



9
10
11
# File 'lib/trycourier/notifications/types/base_check.rb', line 9

def status
  @status
end

#typeObject (readonly)

Returns the value of attribute type.



9
10
11
# File 'lib/trycourier/notifications/types/base_check.rb', line 9

def type
  @type
end

Class Method Details

.from_json(json_object:) ⇒ Notifications::BaseCheck

Deserialize a JSON object to an instance of BaseCheck

Parameters:

  • json_object (JSON)

Returns:



31
32
33
34
35
36
37
38
# File 'lib/trycourier/notifications/types/base_check.rb', line 31

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  JSON.parse(json_object)
  id = struct.id
  status = struct.status
  type = struct.type
  new(id: id, status: status, type: type, 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/notifications/types/base_check.rb', line 51

def self.validate_raw(obj:)
  obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.")
  obj.status.is_a?(Notifications::CheckStatus) != false || raise("Passed value for field obj.status is not the expected type, validation failed.")
  obj.type.is_a?(String) != false || raise("Passed value for field obj.type is not the expected type, validation failed.")
end

Instance Method Details

#to_json(*_args) ⇒ JSON

Serialize an instance of BaseCheck to a JSON object

Returns:

  • (JSON)


43
44
45
# File 'lib/trycourier/notifications/types/base_check.rb', line 43

def to_json(*_args)
  { "id": @id, "status": @status, "type": @type }.to_json
end