Class: MessageMediaConversations::MessageDto

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/message_media_conversations/models/message_dto.rb

Overview

MessageDto Model.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#to_hash, #to_json

Constructor Details

#initialize(channel = nil, id = nil, text = nil, timestamp = nil) ⇒ MessageDto

Returns a new instance of MessageDto.



33
34
35
36
37
38
39
40
41
# File 'lib/message_media_conversations/models/message_dto.rb', line 33

def initialize(channel = nil,
               id = nil,
               text = nil,
               timestamp = nil)
  @channel = channel
  @id = id
  @text = text
  @timestamp = timestamp
end

Instance Attribute Details

#channelString

TODO: Write general description for this method

Returns:



9
10
11
# File 'lib/message_media_conversations/models/message_dto.rb', line 9

def channel
  @channel
end

#idString

TODO: Write general description for this method

Returns:



13
14
15
# File 'lib/message_media_conversations/models/message_dto.rb', line 13

def id
  @id
end

#textString

TODO: Write general description for this method

Returns:



17
18
19
# File 'lib/message_media_conversations/models/message_dto.rb', line 17

def text
  @text
end

#timestampString

TODO: Write general description for this method

Returns:



21
22
23
# File 'lib/message_media_conversations/models/message_dto.rb', line 21

def timestamp
  @timestamp
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/message_media_conversations/models/message_dto.rb', line 44

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  channel = hash['channel']
  id = hash['id']
  text = hash['text']
  timestamp = hash['timestamp']

  # Create object from extracted values.
  MessageDto.new(channel,
                 id,
                 text,
                 timestamp)
end

.namesObject

A mapping from model property names to API property names.



24
25
26
27
28
29
30
31
# File 'lib/message_media_conversations/models/message_dto.rb', line 24

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['channel'] = 'channel'
  @_hash['id'] = 'id'
  @_hash['text'] = 'text'
  @_hash['timestamp'] = 'timestamp'
  @_hash
end