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}"), 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 web_cart_text(session_key, options={}) options.merge!(basic_auth: @auth, headers: @headers) self.class.get(base_api_endpoint("Web/Cart/#{session_key}/Messages?messageTypes=#{ENV['WEB_CART_TEXT']}&savedCart=false"), options) end def order_confirm_text(session_key, options={}) options.merge!(basic_auth: @auth, headers: @headers) self.class.get(base_api_endpoint("Web/Cart/#{session_key}?messageTypes=#{ENV['ORDER_CONFIRM_TEXT']}&savedCart=true"), 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) 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) 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) 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=nil, upgrade=nil, options={}) parameters = { 'Amount': amount, 'FundId': fund, 'Upgrade': upgrade, 'Renew': renew, 'MembershipLevelId': membership_level } options.merge!(basic_auth: @auth, headers: @headers) options.merge!(:body => parameters) 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) self.class.post(base_api_endpoint("Web/Cart/#{session_key}/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, category=0, solicitor='webapi', channel=0, options={}) options.merge!(basic_auth: @auth, headers: @headers) parameters = { "Solicitor": solicitor, "ChannelId": channel } parameters["CategoryId"] = category if category != 0 options.merge!(:body => parameters) self.class.put(base_api_endpoint("Web/Cart/#{session_key}/Properties"), options) end def update_source(session_key, source_no, solicitor='webapi', options={}) options.merge!(basic_auth: @auth, headers: @headers) parameters = { "Solicitor": solicitor, "SourceId": source_no } options.merge!(:body => parameters) self.class.put(base_api_endpoint("Web/Cart/#{session_key}/Properties"), options) end def add_order_comment(session_key, notes, solicitor='webapi', options={}) options.merge!(basic_auth: @auth, headers: @headers) parameters = { "Solicitor": solicitor, "Notes": notes } options.merge!(:body => parameters) 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={}) 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) 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) 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={}) 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) 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) 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) 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) self.class.post(base_api_endpoint("/Web/Cart/#{session_key}/Print/TicketElements"), 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) self.class.post(base_api_endpoint("Web/Cart/#{session_key}/Validate"), options) end end