Class: Pinnacle::InboundTextMessage

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

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(text:, from:, to:, message_type: OMIT, metadata: OMIT, additional_properties: nil) ⇒ Pinnacle::InboundTextMessage

Parameters:

  • message_type (String) (defaults to: OMIT)
  • text (String)
  • from (String)
  • to (String)
  • metadata (Pinnacle::InboundMessageMetadata) (defaults to: OMIT)
  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/rcs/types/inbound_text_message.rb', line 34

def initialize(text:, from:, to:, message_type: OMIT, metadata: OMIT, additional_properties: nil)
  @message_type = message_type if message_type != OMIT
  @text = text
  @from = from
  @to = to
  @metadata =  if  != OMIT
  @additional_properties = additional_properties
  @_field_set = {
    "messageType": message_type,
    "text": text,
    "from": from,
    "to": to,
    "metadata": 
  }.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



20
21
22
# File 'lib/rcs/types/inbound_text_message.rb', line 20

def additional_properties
  @additional_properties
end

#fromString (readonly)

Returns:

  • (String)


14
15
16
# File 'lib/rcs/types/inbound_text_message.rb', line 14

def from
  @from
end

#message_typeString (readonly)

Returns:

  • (String)


10
11
12
# File 'lib/rcs/types/inbound_text_message.rb', line 10

def message_type
  @message_type
end

#metadataPinnacle::InboundMessageMetadata (readonly)



18
19
20
# File 'lib/rcs/types/inbound_text_message.rb', line 18

def 
  @metadata
end

#textString (readonly)

Returns:

  • (String)


12
13
14
# File 'lib/rcs/types/inbound_text_message.rb', line 12

def text
  @text
end

#toString (readonly)

Returns:

  • (String)


16
17
18
# File 'lib/rcs/types/inbound_text_message.rb', line 16

def to
  @to
end

Class Method Details

.from_json(json_object:) ⇒ Pinnacle::InboundTextMessage

Deserialize a JSON object to an instance of InboundTextMessage

Parameters:

  • json_object (String)

Returns:



56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/rcs/types/inbound_text_message.rb', line 56

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  message_type = parsed_json["messageType"]
  text = parsed_json["text"]
  from = parsed_json["from"]
  to = parsed_json["to"]
  if parsed_json["metadata"].nil?
     = nil
  else
     = parsed_json["metadata"].to_json
     = Pinnacle::InboundMessageMetadata.from_json(json_object: )
  end
  new(
    message_type: message_type,
    text: text,
    from: from,
    to: to,
    metadata: ,
    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)


92
93
94
95
96
97
98
# File 'lib/rcs/types/inbound_text_message.rb', line 92

def self.validate_raw(obj:)
  obj.message_type&.is_a?(String) != false || raise("Passed value for field obj.message_type is not the expected type, validation failed.")
  obj.text.is_a?(String) != false || raise("Passed value for field obj.text is not the expected type, validation failed.")
  obj.from.is_a?(String) != false || raise("Passed value for field obj.from is not the expected type, validation failed.")
  obj.to.is_a?(String) != false || raise("Passed value for field obj.to is not the expected type, validation failed.")
  obj..nil? || Pinnacle::InboundMessageMetadata.validate_raw(obj: obj.)
end

Instance Method Details

#to_json(*_args) ⇒ String

Serialize an instance of InboundTextMessage to a JSON object

Returns:

  • (String)


82
83
84
# File 'lib/rcs/types/inbound_text_message.rb', line 82

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