Class: Asdawqw::ReservationNotificationObject

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/asdawqw/models/reservation_notification_object.rb

Overview

ReservationNotificationObject Model.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#to_hash, #to_json

Constructor Details

#initialize(reservation_id = nil, product_id = nil, supplier_id = nil, agent_name = nil, confirmation_id = nil, unique_key = nil, new_state = nil, customer_name = nil, from_date = nil, to_date = nil, adult = nil, child = nil, email = nil, total = nil, fees = nil, taxes = nil, commission = nil, rate = nil, address = nil, city = nil, zip = nil, country = nil, state = nil, phone = nil, notes = nil, credit_card_type = nil, credit_card_number = nil, credit_card_expiration_month = nil, credit_card_expiration_year = nil, credit_card_cid = nil) ⇒ ReservationNotificationObject

Returns a new instance of ReservationNotificationObject.



167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
# File 'lib/asdawqw/models/reservation_notification_object.rb', line 167

def initialize(reservation_id = nil,
               product_id = nil,
               supplier_id = nil,
               agent_name = nil,
               confirmation_id = nil,
               unique_key = nil,
               new_state = nil,
               customer_name = nil,
               from_date = nil,
               to_date = nil,
               adult = nil,
               child = nil,
               email = nil,
               total = nil,
               fees = nil,
               taxes = nil,
               commission = nil,
               rate = nil,
               address = nil,
               city = nil,
               zip = nil,
               country = nil,
               state = nil,
               phone = nil,
               notes = nil,
               credit_card_type = nil,
               credit_card_number = nil,
               credit_card_expiration_month = nil,
               credit_card_expiration_year = nil,
               credit_card_cid = nil)
  @reservation_id = reservation_id
  @product_id = product_id
  @supplier_id = supplier_id
  @agent_name = agent_name
  @confirmation_id = confirmation_id
  @unique_key = unique_key
  @new_state = new_state
  @customer_name = customer_name
  @from_date = from_date
  @to_date = to_date
  @adult = adult
  @child = child
  @address = address
  @city = city
  @zip = zip
  @country = country
  @state = state
  @email = email
  @phone = phone
  @notes = notes
  @credit_card_type = credit_card_type
  @credit_card_number = credit_card_number
  @credit_card_expiration_month = credit_card_expiration_month
  @credit_card_expiration_year = credit_card_expiration_year
  @credit_card_cid = credit_card_cid
  @total = total
  @fees = fees
  @taxes = taxes
  @commission = commission
  @rate = rate
end

Instance Attribute Details

#addressString

Guest address

Returns:



60
61
62
# File 'lib/asdawqw/models/reservation_notification_object.rb', line 60

def address
  @address
end

#adultInteger

number of adults

Returns:

  • (Integer)


52
53
54
# File 'lib/asdawqw/models/reservation_notification_object.rb', line 52

def adult
  @adult
end

#agent_nameString

Agent name/Channel name

Returns:



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

def agent_name
  @agent_name
end

#childInteger

number of children

Returns:

  • (Integer)


56
57
58
# File 'lib/asdawqw/models/reservation_notification_object.rb', line 56

def child
  @child
end

#cityString

Guest city

Returns:



64
65
66
# File 'lib/asdawqw/models/reservation_notification_object.rb', line 64

def city
  @city
end

#commissionReservationCommissionsNotificationModel

Model



125
126
127
# File 'lib/asdawqw/models/reservation_notification_object.rb', line 125

def commission
  @commission
end

#confirmation_idString

Channel confirmation code

Returns:



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

def confirmation_id
  @confirmation_id
end

#countryString

Guest country

Returns:



72
73
74
# File 'lib/asdawqw/models/reservation_notification_object.rb', line 72

def country
  @country
end

#credit_card_cidString

Credit card cid

Returns:



108
109
110
# File 'lib/asdawqw/models/reservation_notification_object.rb', line 108

def credit_card_cid
  @credit_card_cid
end

#credit_card_expiration_monthString

Credit card expiration month

Returns:



100
101
102
# File 'lib/asdawqw/models/reservation_notification_object.rb', line 100

def credit_card_expiration_month
  @credit_card_expiration_month
end

#credit_card_expiration_yearString

Credit card expiration yea

Returns:



104
105
106
# File 'lib/asdawqw/models/reservation_notification_object.rb', line 104

def credit_card_expiration_year
  @credit_card_expiration_year
end

#credit_card_numberString

Credit card number

Returns:



96
97
98
# File 'lib/asdawqw/models/reservation_notification_object.rb', line 96

def credit_card_number
  @credit_card_number
end

#credit_card_typeString

Credit card type

Returns:



92
93
94
# File 'lib/asdawqw/models/reservation_notification_object.rb', line 92

def credit_card_type
  @credit_card_type
end

#customer_nameString

Guest full name (in format firstName, lastName)

Returns:



40
41
42
# File 'lib/asdawqw/models/reservation_notification_object.rb', line 40

def customer_name
  @customer_name
end

#emailString

Guest email

Returns:



80
81
82
# File 'lib/asdawqw/models/reservation_notification_object.rb', line 80

def email
  @email
end

#feesList of ReservationFeeNotificationModel

List of models

Returns:



117
118
119
# File 'lib/asdawqw/models/reservation_notification_object.rb', line 117

def fees
  @fees
end

#from_dateDate

Reservation date from. Date is in format “yyyy-MM-dd”

Returns:

  • (Date)


44
45
46
# File 'lib/asdawqw/models/reservation_notification_object.rb', line 44

def from_date
  @from_date
end

#new_stateString

Reservation state

Returns:



36
37
38
# File 'lib/asdawqw/models/reservation_notification_object.rb', line 36

def new_state
  @new_state
end

#notesString

Guest notes

Returns:



88
89
90
# File 'lib/asdawqw/models/reservation_notification_object.rb', line 88

def notes
  @notes
end

#phoneString

Guest phone

Returns:



84
85
86
# File 'lib/asdawqw/models/reservation_notification_object.rb', line 84

def phone
  @phone
end

#product_idString

Id of the product in BookingPal

Returns:



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

def product_id
  @product_id
end

#rateReservationRateNotifcationModel

Model



129
130
131
# File 'lib/asdawqw/models/reservation_notification_object.rb', line 129

def rate
  @rate
end

#reservation_idString

Id of the reservation in BookingPal

Returns:



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

def reservation_id
  @reservation_id
end

#stateString

Guest state

Returns:



76
77
78
# File 'lib/asdawqw/models/reservation_notification_object.rb', line 76

def state
  @state
end

#supplier_idString

Id of the property manager

Returns:



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

def supplier_id
  @supplier_id
end

#taxesList of ReservationTaxNotificationModel

List of models

Returns:



121
122
123
# File 'lib/asdawqw/models/reservation_notification_object.rb', line 121

def taxes
  @taxes
end

#to_dateDate

Reservation date to. Date is in format “yyyy-MM-dd”

Returns:

  • (Date)


48
49
50
# File 'lib/asdawqw/models/reservation_notification_object.rb', line 48

def to_date
  @to_date
end

#totalFloat

Best available rate (This is the total value that guests will pay, including rate, fees, taxes, and all commissions. )

Returns:

  • (Float)


113
114
115
# File 'lib/asdawqw/models/reservation_notification_object.rb', line 113

def total
  @total
end

#unique_keyString

Unique code to identify that the request is from BookingPal. This value is unique for every PMS (and it will be different in different environments).

Returns:



32
33
34
# File 'lib/asdawqw/models/reservation_notification_object.rb', line 32

def unique_key
  @unique_key
end

#zipString

Guest zip code

Returns:



68
69
70
# File 'lib/asdawqw/models/reservation_notification_object.rb', line 68

def zip
  @zip
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
# File 'lib/asdawqw/models/reservation_notification_object.rb', line 230

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  reservation_id = hash['reservationId']
  product_id = hash['productId']
  supplier_id = hash['supplierId']
  agent_name = hash['agentName']
  confirmation_id = hash['confirmationId']
  unique_key = hash['uniqueKey']
  new_state = hash['newState']
  customer_name = hash['customerName']
  from_date = hash['fromDate']
  to_date = hash['toDate']
  adult = hash['adult']
  child = hash['child']
  email = hash['email']
  total = hash['total']
  # Parameter is an array, so we need to iterate through it
  fees = nil
  unless hash['fees'].nil?
    fees = []
    hash['fees'].each do |structure|
      fees << (ReservationFeeNotificationModel.from_hash(structure) if structure)
    end
  end
  # Parameter is an array, so we need to iterate through it
  taxes = nil
  unless hash['taxes'].nil?
    taxes = []
    hash['taxes'].each do |structure|
      taxes << (ReservationTaxNotificationModel.from_hash(structure) if structure)
    end
  end
  if hash['commission']
    commission = ReservationCommissionsNotificationModel.from_hash(hash['commission'])
  end
  rate = ReservationRateNotifcationModel.from_hash(hash['rate']) if
    hash['rate']
  address = hash['address']
  city = hash['city']
  zip = hash['zip']
  country = hash['country']
  state = hash['state']
  phone = hash['phone']
  notes = hash['notes']
  credit_card_type = hash['creditCardType']
  credit_card_number = hash['creditCardNumber']
  credit_card_expiration_month = hash['creditCardExpirationMonth']
  credit_card_expiration_year = hash['creditCardExpirationYear']
  credit_card_cid = hash['creditCardCid']

  # Create object from extracted values.
  ReservationNotificationObject.new(reservation_id,
                                    product_id,
                                    supplier_id,
                                    agent_name,
                                    confirmation_id,
                                    unique_key,
                                    new_state,
                                    customer_name,
                                    from_date,
                                    to_date,
                                    adult,
                                    child,
                                    email,
                                    total,
                                    fees,
                                    taxes,
                                    commission,
                                    rate,
                                    address,
                                    city,
                                    zip,
                                    country,
                                    state,
                                    phone,
                                    notes,
                                    credit_card_type,
                                    credit_card_number,
                                    credit_card_expiration_month,
                                    credit_card_expiration_year,
                                    credit_card_cid)
end

.namesObject

A mapping from model property names to API property names.



132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
# File 'lib/asdawqw/models/reservation_notification_object.rb', line 132

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['reservation_id'] = 'reservationId'
  @_hash['product_id'] = 'productId'
  @_hash['supplier_id'] = 'supplierId'
  @_hash['agent_name'] = 'agentName'
  @_hash['confirmation_id'] = 'confirmationId'
  @_hash['unique_key'] = 'uniqueKey'
  @_hash['new_state'] = 'newState'
  @_hash['customer_name'] = 'customerName'
  @_hash['from_date'] = 'fromDate'
  @_hash['to_date'] = 'toDate'
  @_hash['adult'] = 'adult'
  @_hash['child'] = 'child'
  @_hash['address'] = 'address'
  @_hash['city'] = 'city'
  @_hash['zip'] = 'zip'
  @_hash['country'] = 'country'
  @_hash['state'] = 'state'
  @_hash['email'] = 'email'
  @_hash['phone'] = 'phone'
  @_hash['notes'] = 'notes'
  @_hash['credit_card_type'] = 'creditCardType'
  @_hash['credit_card_number'] = 'creditCardNumber'
  @_hash['credit_card_expiration_month'] = 'creditCardExpirationMonth'
  @_hash['credit_card_expiration_year'] = 'creditCardExpirationYear'
  @_hash['credit_card_cid'] = 'creditCardCid'
  @_hash['total'] = 'total'
  @_hash['fees'] = 'fees'
  @_hash['taxes'] = 'taxes'
  @_hash['commission'] = 'commission'
  @_hash['rate'] = 'rate'
  @_hash
end