Class: Pinnacle::InboundMessageMetadata

Inherits:
Object
  • Object
show all
Defined in:
lib/rcs/types/inbound_message_metadata.rb

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(sender: OMIT, message: OMIT, additional_properties: nil) ⇒ Pinnacle::InboundMessageMetadata

Parameters:



26
27
28
29
30
31
32
33
# File 'lib/rcs/types/inbound_message_metadata.rb', line 26

def initialize(sender: OMIT, message: OMIT, additional_properties: nil)
  @sender = sender if sender != OMIT
  @message = message if message != OMIT
  @additional_properties = additional_properties
  @_field_set = { "sender": sender, "message": message }.reject do |_k, v|
    v == OMIT
  end
end

Instance Attribute Details

#additional_propertiesOpenStruct (readonly)

Returns Additional properties unmapped to the current class definition.

Returns:

  • (OpenStruct)

    Additional properties unmapped to the current class definition



15
16
17
# File 'lib/rcs/types/inbound_message_metadata.rb', line 15

def additional_properties
  @additional_properties
end

#messagePinnacle::MessageMetadata (readonly)



13
14
15
# File 'lib/rcs/types/inbound_message_metadata.rb', line 13

def message
  @message
end

#senderPinnacle::SenderMetadata (readonly)



11
12
13
# File 'lib/rcs/types/inbound_message_metadata.rb', line 11

def sender
  @sender
end

Class Method Details

.from_json(json_object:) ⇒ Pinnacle::InboundMessageMetadata

Deserialize a JSON object to an instance of InboundMessageMetadata

Parameters:

  • json_object (String)

Returns:



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/rcs/types/inbound_message_metadata.rb', line 39

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  if parsed_json["sender"].nil?
    sender = nil
  else
    sender = parsed_json["sender"].to_json
    sender = Pinnacle::SenderMetadata.from_json(json_object: sender)
  end
  if parsed_json["message"].nil?
    message = nil
  else
    message = parsed_json["message"].to_json
    message = Pinnacle::MessageMetadata.from_json(json_object: message)
  end
  new(
    sender: sender,
    message: message,
    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)


74
75
76
77
# File 'lib/rcs/types/inbound_message_metadata.rb', line 74

def self.validate_raw(obj:)
  obj.sender.nil? || Pinnacle::SenderMetadata.validate_raw(obj: obj.sender)
  obj.message.nil? || Pinnacle::MessageMetadata.validate_raw(obj: obj.message)
end

Instance Method Details

#to_json(*_args) ⇒ String

Serialize an instance of InboundMessageMetadata to a JSON object

Returns:

  • (String)


64
65
66
# File 'lib/rcs/types/inbound_message_metadata.rb', line 64

def to_json(*_args)
  @_field_set&.to_json
end