class Centaman::Service::PurchaseTicket

Attributes

booking_time[R]
booking_type[R]
checkout_service[R]
contact[R]
order_info[R]
payment_reference[R]
tickets[R]

Public Instance Methods

after_init(args) click to toggle source
# 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() click to toggle source
# File lib/centaman/service/purchase_ticket.rb, line 16
def endpoint
  '/ticket_services/TimedTicketTransaction'
end
options_hash_no_json() click to toggle source
# File lib/centaman/service/purchase_ticket.rb, line 38
def options_hash_no_json
  [
    {
      "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() click to toggle source
# 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

Private Instance Methods

calculators() click to toggle source
# File lib/centaman/service/purchase_ticket.rb, line 84
def calculators
  checkout_service.ticket_calculators + checkout_service.extra_calculators
end
options_hash() click to toggle source
# File lib/centaman/service/purchase_ticket.rb, line 64
def options_hash
  options_hash_no_json.to_json
end
total_after_discounts() click to toggle source
# File lib/centaman/service/purchase_ticket.rb, line 68
def total_after_discounts
  checkout_service.total_price_after_discounts
end
total_paid() click to toggle source
# File lib/centaman/service/purchase_ticket.rb, line 72
def total_paid
  checkout_service.total
end
total_taxes() click to toggle source
# File lib/centaman/service/purchase_ticket.rb, line 76
def total_taxes
  checkout_service.total_taxes
end
total_tickets() click to toggle source
# File lib/centaman/service/purchase_ticket.rb, line 80
def total_tickets
  checkout_service.total_tickets
end