Class: Asdawqw::Thread

Inherits:
BaseModel show all
Defined in:
lib/asdawqw/models/thread.rb

Overview

Thread Model.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#to_hash, #to_json

Constructor Details

#initialize(id = nil, last_message_sent_at = nil, last_message_text = nil, channel_name = nil, channel_abb = nil, guest_name = nil, guest_email_address = nil, product_id = nil, date_from = nil, date_to = nil, reservation_id = nil) ⇒ Thread

Returns a new instance of Thread.



70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# File 'lib/asdawqw/models/thread.rb', line 70

def initialize(id = nil,
               last_message_sent_at = nil,
               last_message_text = nil,
               channel_name = nil,
               channel_abb = nil,
               guest_name = nil,
               guest_email_address = nil,
               product_id = nil,
               date_from = nil,
               date_to = nil,
               reservation_id = nil)
  @id = id
  @last_message_sent_at = last_message_sent_at
  @last_message_text = last_message_text
  @channel_name = channel_name
  @channel_abb = channel_abb
  @guest_name = guest_name
  @guest_email_address = guest_email_address
  @product_id = product_id
  @reservation_id = reservation_id
  @date_from = date_from
  @date_to = date_to
end

Instance Attribute Details

#channel_abbChannelABBEnum

Channel abbreviation - unique channel value in BookingPal. See Appendix

Returns:



27
28
29
# File 'lib/asdawqw/models/thread.rb', line 27

def channel_abb
  @channel_abb
end

#channel_nameString

Channel from where come reservation

Returns:



23
24
25
# File 'lib/asdawqw/models/thread.rb', line 23

def channel_name
  @channel_name
end

#date_fromDate

Start date of reservation. Date is in format “yyyy-MM-dd”

Returns:

  • (Date)


47
48
49
# File 'lib/asdawqw/models/thread.rb', line 47

def date_from
  @date_from
end

#date_toDate

End date of reservation. Date is in format “yyyy-MM-dd”

Returns:

  • (Date)


51
52
53
# File 'lib/asdawqw/models/thread.rb', line 51

def date_to
  @date_to
end

#guest_email_addressString

Email of guest

Returns:



35
36
37
# File 'lib/asdawqw/models/thread.rb', line 35

def guest_email_address
  @guest_email_address
end

#guest_nameString

Name of guest

Returns:



31
32
33
# File 'lib/asdawqw/models/thread.rb', line 31

def guest_name
  @guest_name
end

#idInteger

Thread ID

Returns:

  • (Integer)


11
12
13
# File 'lib/asdawqw/models/thread.rb', line 11

def id
  @id
end

#last_message_sent_atString

Time when last message was sent

Returns:



15
16
17
# File 'lib/asdawqw/models/thread.rb', line 15

def last_message_sent_at
  @last_message_sent_at
end

#last_message_textString

Last message text

Returns:



19
20
21
# File 'lib/asdawqw/models/thread.rb', line 19

def last_message_text
  @last_message_text
end

#product_idInteger

ID of product in BookingPal database

Returns:

  • (Integer)


39
40
41
# File 'lib/asdawqw/models/thread.rb', line 39

def product_id
  @product_id
end

#reservation_idInteger

ID of reservation

Returns:

  • (Integer)


43
44
45
# File 'lib/asdawqw/models/thread.rb', line 43

def reservation_id
  @reservation_id
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
# File 'lib/asdawqw/models/thread.rb', line 95

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  id = hash['id']
  last_message_sent_at = hash['lastMessageSentAt']
  last_message_text = hash['lastMessageText']
  channel_name = hash['channelName']
  channel_abb = hash['channelABB']
  guest_name = hash['guestName']
  guest_email_address = hash['guestEmailAddress']
  product_id = hash['productId']
  date_from = hash['dateFrom']
  date_to = hash['dateTo']
  reservation_id = hash['reservationId']

  # Create object from extracted values.
  Thread.new(id,
             last_message_sent_at,
             last_message_text,
             channel_name,
             channel_abb,
             guest_name,
             guest_email_address,
             product_id,
             date_from,
             date_to,
             reservation_id)
end

.namesObject

A mapping from model property names to API property names.



54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/asdawqw/models/thread.rb', line 54

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['id'] = 'id'
  @_hash['last_message_sent_at'] = 'lastMessageSentAt'
  @_hash['last_message_text'] = 'lastMessageText'
  @_hash['channel_name'] = 'channelName'
  @_hash['channel_abb'] = 'channelABB'
  @_hash['guest_name'] = 'guestName'
  @_hash['guest_email_address'] = 'guestEmailAddress'
  @_hash['product_id'] = 'productId'
  @_hash['reservation_id'] = 'reservationId'
  @_hash['date_from'] = 'dateFrom'
  @_hash['date_to'] = 'dateTo'
  @_hash
end