module Cart def get_cart(session_key, options = {}) options.merge!(basic_auth: @auth, headers: @headers) self.class.get(base_api_endpoint("Web/Cart/#{session_key}?messageTypes=-11"), options) end def get_checkout_complete(session_key, options = {}) options.merge!(basic_auth: @auth, headers: @headers) self.class.get(base_api_endpoint("Web/Cart/#{session_key}&savedCart=true"), options) end def empty_cart(session_key, options = {}) options.merge!(basic_auth: @auth, headers: @headers) self.class.delete(base_api_endpoint("Web/Cart/#{session_key}"), options) end def change_mode_of_sale(session_key, code, options = {}) parameters = { 'ModeOfSaleId': code, } options.merge!(basic_auth: @auth, headers: @headers) options.merge!(:body => parameters.to_json) self.class.put(base_api_endpoint("Web/Cart/#{session_key}/Properties"), options) end def add_gift_certificate(session_key, amount, name, notes, gift_certificate_type, options = {}) parameters = { 'Amount': amount, 'PaymentMethodId': gift_certificate_type, 'Notes': notes, 'Name': name, } options.merge!(basic_auth: @auth, headers: @headers) options.merge!(:body => parameters.to_json) self.class.post(base_api_endpoint("Web/Cart/#{session_key}/GiftCertificates"), options) end def remove_gift_certificate(session_key, gift_certificate_number, options = {}) options.merge!(basic_auth: @auth, headers: @headers) self.class.delete(base_api_endpoint("Web/Cart/#{session_key}/GiftCertificates/#{gift_certificate_number}"), options) end def apply_gift_certificate(session_key, gift_certificate_number, amount, options = {}) parameters = { 'Amount': amount, 'GiftCertificateNumber': gift_certificate_number, } options.merge!(basic_auth: @auth, headers: @headers) options.merge!(:body => parameters.to_json) self.class.post(base_api_endpoint("Web/Cart/#{session_key}/Payments/GiftCertificate"), options) end def un_apply_gift_certificate(session_key, gift_certificate_number, options = {}) options.merge!(basic_auth: @auth, headers: @headers) self.class.delete(base_api_endpoint("Web/Cart/#{session_key}/Payments/GiftCertificate/#{gift_certificate_number}"), options) end def add_contribution(session_key, amount, fund, membership_level, renew = false, upgrade = false, options = {}) parameters = { 'Amount': amount, 'FundId': fund, 'Upgrade': upgrade, 'Renew': renew, 'MembershipLevelId': membership_level, } options.merge!(basic_auth: @auth, headers: @headers) options.merge!(:body => parameters.to_json) self.class.post(base_api_endpoint("Web/Cart/#{session_key}/Contributions"), options) end def remove_contribution(session_key, line_item_id, options = {}) options.merge!(basic_auth: @auth, headers: @headers) self.class.delete(base_api_endpoint("Web/Cart/#{session_key}/Contributions/#{line_item_id}"), options) end def add_on_account(session_key, amount, payment_method_id, options = {}) parameters = { 'Amount': amount, 'PaymentMethodId': payment_method_id, } options.merge!(basic_auth: @auth, headers: @headers) options.merge!(:body => parameters.to_json) self.class.post(base_api_endpoint("Web/Cart/#{session_key}/OnAccount"), options) end def apply_on_account(session_key, amount, payment_method_id, options = {}) parameters = { 'Amount': amount, 'PaymentMethodId': payment_method_id, } options.merge!(basic_auth: @auth, headers: @headers) options.merge!(:body => parameters.to_json) self.class.post(base_api_endpoint("Web/Cart/#{session_key}/Payments/OnAccount"), options) end def remove_on_account(session_key, payment_id, options = {}) options.merge!(basic_auth: @auth, headers: @headers) self.class.delete(base_api_endpoint("Web/Cart/#{session_key}/OnAccount/#{payment_id}"), options) end def get_properties(session_key, options = {}) options.merge!(basic_auth: @auth, headers: @headers) self.class.get(base_api_endpoint("Web/Cart/#{session_key}/Properties"), options) end def update_properties(session_key, get_properties_response, options = {}) options.merge!(basic_auth: @auth, headers: @headers) options.merge!(:body => get_properties_response.to_json) self.class.put(base_api_endpoint("Web/Cart/#{session_key}/Properties"), options) end def reserve_tickets(session_key, number_of_seats, perf_id, price_type, zone_id, unseated, requested_seats = nil, special_requests = nil, options = {}) zone_id = 0 if requested_seats.present? || zone_id.nil? parameters = { 'PriceType': price_type, 'PerformanceId': perf_id, 'NumberOfSeats': number_of_seats, 'ZoneId': zone_id, 'SpecialRequests': special_requests, 'Unseated': unseated, 'RequestedSeats': requested_seats, } options.merge!(basic_auth: @auth, headers: @headers) options.merge!(:body => parameters.to_json) self.class.post(base_api_endpoint("Web/Cart/#{session_key}/Tickets"), options) end def return_tickets(session_key, return_or_donate, id, options = {}) parameters = { 'TicketNumber': id, 'ReturnOrDonate': return_or_donate, } options.merge!(basic_auth: @auth, headers: @headers) options.merge!(:body => parameters.to_json) self.class.post(base_api_endpoint("Web/Cart/#{session_key}/Tickets/Return"), options) end def add_package_item(session_key, price_type, package_id, number_of_seats, zone_id, leave_single_seats, parent_package_line_item_id, unseated, requested_seats = nil, options = {}) zone_id = 0 if requested_seats.present? || zone_id.nil? parent_package_line_item_id = 0 if parent_package_line_item_id.nil? parameters = { 'PriceType': price_type, 'PackageId': package_id, 'NumberOfSeats': number_of_seats, 'ZoneId': zone_id, 'RequestedSeats': requested_seats, 'LeaveSingleSeats': leave_single_seats, 'ParentPackageLineItemId': parent_package_line_item_id, 'Unseated': unseated, } options.merge!(basic_auth: @auth, headers: @headers) options.merge!(:body => parameters.to_json) self.class.post(base_api_endpoint("Web/Cart/#{session_key}/Packages/Fixed"), options) end def remove_package_item(session_key, package_id, line_item_id, options = {}) options.merge!(basic_auth: @auth, headers: @headers) self.class.delete(base_api_endpoint("Web/Cart/#{session_key}/Packages/Fixed/#{package_id}/#{line_item_id}"), options) end def add_nfs_package_item(session_key, nfs_package_line_item_id, performance_id, performance_group_id, price_type, package_id, number_of_seats, zone_id, leave_single_seats, unseated, options = {}) parameters = { 'NFSPackageLineItemId': nfs_package_line_item_id, 'PriceType': price_type, 'PackageId': package_id, 'PerformanceId': performance_id, 'PerformanceGroupId': performance_group_id, 'NumberOfSeats': number_of_seats, 'ZoneId': zone_id, 'LeaveSingleSeats': leave_single_seats, 'Unseated': unseated, } options.merge!(basic_auth: @auth, headers: @headers) options.merge!(:body => parameters.to_json) self.class.post(base_api_endpoint("Web/Cart/#{session_key}/Packages/Nfs"), options) end def remove_nfs_package_item(session_key, line_item_id, options = {}) options.merge!(basic_auth: @auth, headers: @headers) self.class.delete(base_api_endpoint("Web/Cart/#{session_key}/Packages/Nfs/#{line_item_id}"), options) end def add_sub_package_item(session_key, price_type, sub_package_id, number_of_seats, zone_id, leave_single_seats, parent_super_line_item_id, super_line_item_id, unseated, requested_seats = nil, options = {}) parameters = { 'ParentSuperPackageLineItemId': parent_super_line_item_id, 'SuperPackageLineItemId': super_line_item_id, 'PriceType': price_type, 'SubPackageId': sub_package_id, 'NumberOfSeats': number_of_seats, 'ZoneId': zone_id, 'RequestedSeats': requested_seats, 'LeaveSingleSeats': leave_single_seats, 'Unseated': unseated, } options.merge!(basic_auth: @auth, headers: @headers) options.merge!(:body => parameters.to_json) self.class.post(base_api_endpoint("Web/Cart/#{session_key}/Packages/Super"), options) end def remove_sub_package_item(session_key, super_package_id, super_package_line_item_id, options = {}) options.merge!(basic_auth: @auth, headers: @headers) self.class.delete(base_api_endpoint("Web/Cart/#{session_key}/Packages/Super/#{super_package_id}/#{super_package_line_item_id}"), options) end def print_ticket_elements(session_key, order_id, ticket_design, reprint, mode, new_ticket_no = false, options = {}) parameters = { 'NewTicketNoForReprints': new_ticket_no, 'ReprintTickets': reprint, 'OrderId': order_id, 'TicketDesignId': ticket_design, 'Mode': mode, } options.merge!(basic_auth: @auth, headers: @headers) options.merge!(:body => parameters.to_json) self.class.post(base_api_endpoint("Web/Cart/#{session_key}/Print/TicketElements"), options) end def remove_tickets(session_key, performance_id, line_item_id, options = {}) options.merge!(basic_auth: @auth, headers: @headers) self.class.delete(base_api_endpoint("Web/Cart/#{session_key}/Tickets/#{performance_id}/#{line_item_id}"), options) end def add_or_update_fee(session_key, action, fee_id, item_fee_id = nil, amount = nil, options = {}) parameters = { 'Action': action, 'ItemFeeId': item_fee_id, 'FeeId': fee_id, 'Amount': amount, } options.merge!(basic_auth: @auth, headers: @headers) options.merge!(:body => parameters.to_json) self.class.post(base_api_endpoint("Web/Cart/#{session_key}/Fees"), options) end def validate_cart(session_key, super_package = false, fixed = false, flex = false, plan = false, options = {}) parameters = { 'ValidateSuperPackages': super_package, 'ValidateFSPackages': fixed, 'ValidateNFSPackages': flex, 'ValidatePaymentPlan': plan, } options.merge!(basic_auth: @auth, headers: @headers) options.merge!(:body => parameters.to_json) self.class.post(base_api_endpoint("Web/Cart/#{session_key}/Validate"), options) end def update_cart_properties_custom_data(session_key, index, value, options = {}) parameters = { 'Index': index, 'Value': value, } options.merge!(basic_auth: @auth, headers: @headers) options.merge!(:body => parameters.to_json) put = self.class.put(base_api_endpoint("Web/Cart/#{session_key}/CustomData/#{index}"), options) put.success? end def checkout(session_key, name_on_card, credit_card_number, cvv_number, credit_card_type, expiration_month, expiration_year, is_order_authorized, order_authorization_code, order_amount, allow_under_payment, options = {}) parameters = { 'CreditCardOwner': name_on_card, 'CreditCardNumber': credit_card_number, 'CreditCardType': credit_card_type, 'CreditCardMonth': expiration_month, 'CreditCardYear': expiration_year, 'Amount': order_amount, 'AllowUnderPayment': allow_under_payment, 'CreditCardAuthenticationCode': cvv_number, 'Authorize': is_order_authorized, 'AuthorizationCode': order_authorization_code, } options.merge!(basic_auth: @auth, headers: @headers) options.merge!(:body => parameters.to_json) self.class.post(base_api_endpoint("Web/Cart/#{session_key}/Checkout"), options) end def checkout_with_tms(session_key, order_authorization_code, order_amount, allow_under_payment, payment_method_id, payment_reference, authorize, options = {}) parameters = { 'CreditCardType': payment_method_id, 'Amount': order_amount, 'AllowUnderPayment': allow_under_payment, 'Authorize': authorize, 'ECommerce': true, 'AuthorizationCode': order_authorization_code, 'PaymentReference': payment_reference } options.merge!(basic_auth: @auth, headers: @headers) options.merge!(:body => parameters.to_json) self.class.post(base_api_endpoint("Web/Cart/#{session_key}/Checkout"), options) end def checkout_with_zip(session_key, name_on_card, credit_card_number, cvv_number, credit_card_type, expiration_month, expiration_year, zip_code, is_order_authorized, order_authorization_code, order_amount, allow_under_payment, options = {}) parameters = { 'CreditCardOwner': name_on_card, 'CreditCardNumber': credit_card_number, 'CreditCardType': credit_card_type, 'CreditCardMonth': expiration_month, 'CreditCardYear': expiration_year, 'Amount': order_amount, 'AllowUnderPayment': allow_under_payment, 'CreditCardAuthenticationCode': cvv_number, 'Authorize': is_order_authorized, 'AuthorizationCode': order_authorization_code, 'ZipCode': zip_code, } options.merge!(basic_auth: @auth, headers: @headers) options.merge!(:body => parameters.to_json) self.class.post(base_api_endpoint("Web/Cart/#{session_key}/Checkout"), options) end end