Class: Centaman::Service::PurchaseTicket
- Inherits:
-
Centaman::Service
- Object
- Wrapper
- Centaman::Service
- Centaman::Service::PurchaseTicket
- Defined in:
- lib/centaman/service/purchase_ticket.rb
Constant Summary
Constants inherited from Wrapper
Instance Attribute Summary collapse
-
#booking_time ⇒ Object
readonly
Returns the value of attribute booking_time.
-
#booking_type ⇒ Object
readonly
Returns the value of attribute booking_type.
-
#checkout_service ⇒ Object
readonly
Returns the value of attribute checkout_service.
-
#contact ⇒ Object
readonly
Returns the value of attribute contact.
-
#order_info ⇒ Object
readonly
Returns the value of attribute order_info.
-
#payment_reference ⇒ Object
readonly
Returns the value of attribute payment_reference.
-
#tickets ⇒ Object
readonly
Returns the value of attribute tickets.
Attributes inherited from Wrapper
#api_password, #api_token, #api_url, #api_username, #proxie_host, #proxie_password, #proxie_port, #proxie_user
Instance Method Summary collapse
- #after_init(args) ⇒ Object
- #endpoint ⇒ Object
- #options_hash_no_json ⇒ Object
- #tickets_payload ⇒ Object
Methods inherited from Centaman::Service
#after_post, #fetch_all, #post, #put
Methods inherited from Wrapper
#generate_token, #headers, #initialize, #options, #payload, #payload_key, #proxy_hash, #wrap_request_in_case_of_timeout
Constructor Details
This class inherits a constructor from Centaman::Wrapper
Instance Attribute Details
#booking_time ⇒ Object (readonly)
Returns the value of attribute booking_time.
3 4 5 |
# File 'lib/centaman/service/purchase_ticket.rb', line 3 def booking_time @booking_time end |
#booking_type ⇒ Object (readonly)
Returns the value of attribute booking_type.
3 4 5 |
# File 'lib/centaman/service/purchase_ticket.rb', line 3 def booking_type @booking_type end |
#checkout_service ⇒ Object (readonly)
Returns the value of attribute checkout_service.
3 4 5 |
# File 'lib/centaman/service/purchase_ticket.rb', line 3 def checkout_service @checkout_service end |
#contact ⇒ Object (readonly)
Returns the value of attribute contact.
3 4 5 |
# File 'lib/centaman/service/purchase_ticket.rb', line 3 def contact @contact end |
#order_info ⇒ Object (readonly)
Returns the value of attribute order_info.
3 4 5 |
# File 'lib/centaman/service/purchase_ticket.rb', line 3 def order_info @order_info end |
#payment_reference ⇒ Object (readonly)
Returns the value of attribute payment_reference.
3 4 5 |
# File 'lib/centaman/service/purchase_ticket.rb', line 3 def payment_reference @payment_reference end |
#tickets ⇒ Object (readonly)
Returns the value of attribute tickets.
3 4 5 |
# File 'lib/centaman/service/purchase_ticket.rb', line 3 def tickets @tickets end |
Instance Method Details
#after_init(args) ⇒ Object
6 7 8 9 10 11 12 13 14 |
# File 'lib/centaman/service/purchase_ticket.rb', line 6 def after_init(args) @booking_type = args[:booking_type] @booking_time = args[:booking_time] @tickets = args[:tickets] @payment_reference = args[:payment_reference] @contact = args[:contact] @order_info = args[:order_info] @checkout_service = args[:checkout_service] end |
#endpoint ⇒ Object
16 17 18 |
# File 'lib/centaman/service/purchase_ticket.rb', line 16 def endpoint '/ticket_services/TimedTicketTransaction' end |
#options_hash_no_json ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/centaman/service/purchase_ticket.rb', line 38 def [ { "Item" => tickets_payload, "TimedTicketTypeId" => booking_time.id, "TimedTicketTypeDescription" => "#{contact.last_name}, #{contact.first_name}", "BookingTypeId" => booking_type.booking_type_id, "StartDate" => booking_time.start_date.strftime('%Y-%m-%d'), # "StartTime" => booking_time.start_time, "EndTime" => booking_time.end_time, "PaymentReference" => payment_reference, "BookingCost" => total_after_discounts.round(2), "TotalPaid" => total_paid.round(2), "TaxPaid" => total_taxes.round(2), "TransactionDate" => Date.today.strftime('%Y-%m-%d'), "BookingContactID" => contact.member_code, "TotalTickets" => total_tickets, # "BalanceAmount" => nil, # "ReceiptNo" => nil, # "BookingId" => nil } ] end |
#tickets_payload ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/centaman/service/purchase_ticket.rb', line 20 def tickets_payload calculators.map do |calculator| ticket_hash = { 'ItemDescription' => calculator.description, 'ItemCode' => calculator.id, 'Quantity' => calculator.quantity, 'ItemCost' => calculator.price_per_after_online_discount, 'TotalPaid' => calculator.total_per, 'TaxPaid' => calculator.taxes_per, 'AttendeeName' => '', # 'Barcode' => nil, 'IsExtraItem' => calculator.is_extra?, 'CouponCode' => order_info.coupon_service.centaman_coupon_code || '' } ticket_hash end end |