Class: Parsec::Order
Constant Summary collapse
- RES_STATUS =
{ 'OK' => 'Success', # 'New booking' 'CA' => 'Cancelled', 'OR' => 'On Request' }.freeze
Constants inherited from Base
Instance Attribute Summary collapse
-
#end_date ⇒ Object
readonly
Returns the value of attribute end_date.
-
#hotel_code ⇒ Object
readonly
Returns the value of attribute hotel_code.
-
#number ⇒ Object
readonly
Returns the value of attribute number.
-
#parsec_id ⇒ Object
readonly
Returns the value of attribute parsec_id.
-
#price ⇒ Object
readonly
Returns the value of attribute price.
-
#rooms ⇒ Object
readonly
Returns the value of attribute rooms.
-
#start_date ⇒ Object
readonly
Returns the value of attribute start_date.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
Class Method Summary collapse
-
.build(order_data) ⇒ Object
rubocop:disable Metrics/AbcSize.
Instance Method Summary collapse
-
#initialize(product_item_id:, rooms:, price:, hotel_code:, start_date:, end_date:, parsec_id:, status:) ⇒ Order
constructor
rubocop:disable Metrics/ParameterLists.
Constructor Details
#initialize(product_item_id:, rooms:, price:, hotel_code:, start_date:, end_date:, parsec_id:, status:) ⇒ Order
rubocop:disable Metrics/ParameterLists
14 15 16 17 18 19 20 21 22 23 |
# File 'lib/parsec/order.rb', line 14 def initialize(product_item_id:, rooms:, price:, hotel_code:, start_date:, end_date:, parsec_id:, status:) @product_item_id = product_item_id @rooms = rooms @price = price @hotel_code = hotel_code @start_date = start_date @end_date = end_date @parsec_id = parsec_id @status = status end |
Instance Attribute Details
#end_date ⇒ Object (readonly)
Returns the value of attribute end_date.
11 12 13 |
# File 'lib/parsec/order.rb', line 11 def end_date @end_date end |
#hotel_code ⇒ Object (readonly)
Returns the value of attribute hotel_code.
11 12 13 |
# File 'lib/parsec/order.rb', line 11 def hotel_code @hotel_code end |
#number ⇒ Object (readonly)
Returns the value of attribute number.
11 12 13 |
# File 'lib/parsec/order.rb', line 11 def number @number end |
#parsec_id ⇒ Object (readonly)
Returns the value of attribute parsec_id.
11 12 13 |
# File 'lib/parsec/order.rb', line 11 def parsec_id @parsec_id end |
#price ⇒ Object (readonly)
Returns the value of attribute price.
11 12 13 |
# File 'lib/parsec/order.rb', line 11 def price @price end |
#rooms ⇒ Object (readonly)
Returns the value of attribute rooms.
11 12 13 |
# File 'lib/parsec/order.rb', line 11 def rooms @rooms end |
#start_date ⇒ Object (readonly)
Returns the value of attribute start_date.
11 12 13 |
# File 'lib/parsec/order.rb', line 11 def start_date @start_date end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
11 12 13 |
# File 'lib/parsec/order.rb', line 11 def status @status end |
Class Method Details
.build(order_data) ⇒ Object
rubocop:disable Metrics/AbcSize
27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/parsec/order.rb', line 27 def self.build(order_data) hotel_data = order_data[:hotel_res_list][:hotel_res] new(product_item_id: order_data[:res_global_info][:res_i_ds][:res_id].find { |id| id[:@type] == 'ClientReference' }[:@id], rooms: Array.wrap(hotel_data[:rooms][:room]).map { |r| [r[:room_type][:@code], r[:room_type][:@name]] }.to_h, hotel_code: hotel_data[:info][:@hotel_code], start_date: Date.strptime(hotel_data[:hotel_res_info][:date_range][:@start], DATE_FORMAT), end_date: Date.strptime(hotel_data[:hotel_res_info][:date_range][:@end], DATE_FORMAT), price: hotel_data[:hotel_res_info][:total][:@amount].to_f, parsec_id: hotel_data[:hotel_res_info][:hotel_res_i_ds][:hotel_res_id].find { |id| id[:@type] == 'Locator' }[:@id], status: RES_STATUS[hotel_data[:@res_status]]) end |