Class: Samsara::Types::V1MessageResponse

Inherits:
Object
  • Object
show all
Defined in:
lib/samsara_api/types/v_1_message_response.rb

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(driver_id:, is_read:, sender:, sent_at_ms:, text:, additional_properties: nil) ⇒ Samsara::Types::V1MessageResponse

Parameters:

  • driver_id (Long) —

    ID of the driver for whom the message is sent to or sent by.

  • is_read (Boolean) —

    True if the message was read by the recipient.

  • sender (Samsara::Types::V1MessageSender)
  • sent_at_ms (Long) —

    The time in Unix epoch milliseconds that the message is sent to the recipient.

  • text (String) —

    The text sent in the message.

  • additional_properties (OpenStruct) (defaults to: nil) —

    Additional properties unmapped to the current class definition



34
35
36
37
38
39
40
41
42
# File 'lib/samsara_api/types/v_1_message_response.rb', line 34

def initialize(driver_id:, is_read:, sender:, sent_at_ms:, text:, additional_properties: nil)
  @driver_id = driver_id
  @is_read = is_read
  @sender = sender
  @sent_at_ms = sent_at_ms
  @text = text
  @additional_properties = additional_properties
  @_field_set = { "driverId": driver_id, "isRead": is_read, "sender": sender, "sentAtMs": sent_at_ms, "text": text }
end

Instance Attribute Details

#additional_properties ⇒ OpenStruct (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/samsara_api/types/v_1_message_response.rb', line 20

def additional_properties
  @additional_properties
end

#driver_id ⇒ Long (readonly)

Returns ID of the driver for whom the message is sent to or sent by.

Returns:

  • (Long) —

    ID of the driver for whom the message is sent to or sent by.



10
11
12
# File 'lib/samsara_api/types/v_1_message_response.rb', line 10

def driver_id
  @driver_id
end

#is_read ⇒ Boolean (readonly)

Returns True if the message was read by the recipient.

Returns:

  • (Boolean) —

    True if the message was read by the recipient.



12
13
14
# File 'lib/samsara_api/types/v_1_message_response.rb', line 12

def is_read
  @is_read
end

#sender ⇒ Samsara::Types::V1MessageSender (readonly)



14
15
16
# File 'lib/samsara_api/types/v_1_message_response.rb', line 14

def sender
  @sender
end

#sent_at_ms ⇒ Long (readonly)

Returns The time in Unix epoch milliseconds that the message is sent to the recipient.

Returns:

  • (Long) —

    The time in Unix epoch milliseconds that the message is sent to the recipient.



16
17
18
# File 'lib/samsara_api/types/v_1_message_response.rb', line 16

def sent_at_ms
  @sent_at_ms
end

#text ⇒ String (readonly)

Returns The text sent in the message.

Returns:

  • (String) —

    The text sent in the message.



18
19
20
# File 'lib/samsara_api/types/v_1_message_response.rb', line 18

def text
  @text
end

Class Method Details

.from_json(json_object:) ⇒ Samsara::Types::V1MessageResponse

Parameters:

  • json_object (String)

Returns:



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/samsara_api/types/v_1_message_response.rb', line 47

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  driver_id = parsed_json["driverId"]
  is_read = parsed_json["isRead"]
  unless parsed_json["sender"].nil?
    sender = parsed_json["sender"].to_json
    sender = Samsara::Types::V1MessageSender.from_json(json_object: sender)
  else
    sender = nil
  end
  sent_at_ms = parsed_json["sentAtMs"]
  text = parsed_json["text"]
  new(
    driver_id: driver_id,
    is_read: is_read,
    sender: sender,
    sent_at_ms: sent_at_ms,
    text: text,
    additional_properties: struct
  )
end

.validate_raw(obj:) ⇒ Void

Parameters:

  • obj (Object)

Returns:

  • (Void)


81
82
83
84
85
86
87
# File 'lib/samsara_api/types/v_1_message_response.rb', line 81

def self.validate_raw(obj:)
  obj.driver_id.is_a?(Long) != false || raise("Passed value for field obj.driver_id is not the expected type, validation failed.")
  obj.is_read.is_a?(Boolean) != false || raise("Passed value for field obj.is_read is not the expected type, validation failed.")
  Samsara::Types::V1MessageSender.validate_raw(obj: obj.sender)
  obj.sent_at_ms.is_a?(Long) != false || raise("Passed value for field obj.sent_at_ms 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.")
end

Instance Method Details

#to_json ⇒ String

Returns:

  • (String)


72
73
74
# File 'lib/samsara_api/types/v_1_message_response.rb', line 72

def to_json
  @_field_set&.to_json
end