class ZapiXML
Attributes
session[R]
Public Class Methods
new(session: nil)
click to toggle source
# File lib/zapi_xml.rb, line 5 def initialize session: nil @session = session end
Public Instance Methods
_activities(activities)
click to toggle source
# File lib/zapi_xml.rb, line 369 def _activities activities activites.map do |a| { "activityId" => nil, "activityDate" => nil, "activityTime" => nil, "pickupLocationId" => nil, "pickupAddress" => nil, "dropOffLocationId" => nil, "dropoffAddress" => nil, "pricingOptions" => nil } end {'activity' => activities} end
_wrap_xml_request(method, params = {})
click to toggle source
# File lib/zapi_xml.rb, line 355 def _wrap_xml_request method, params = {} if session request = params.merge({ 'zapiToken' => session.api_token, 'zapiUserId' => session.user_id, 'zapiAccountId' => session.account_id, 'zapiMethod' => method }) else request = params.merge({ 'zapiMethod' => method }) end request.to_xml(:root => 'request') end
add_activity_to_cart(hash: {})
click to toggle source
# File lib/zapi_xml.rb, line 185 def add_activity_to_cart hash: {} for_xml = { "methodName" => 'zapiAddActivityToCart', "cartId" => session.cart_id, "activityId" => hash[:activity_id], "activityDate" => hash[:activity_date], "activityEndDate" => hash[:activity_end_date], "rentalStartTime" => hash[:rental_start_time], "rentalEndTime" => hash[:rental_end_time], "pricingOptions" => nil, "passengers" => { }, "activityTime" => hash[:activity_time], "pickupLocationId" => nil, "dropOffLocationId" => hash[:dropoff_location_id] } for_xml['passengers']['adults'] = hash[:adults].to_i unless hash[:adults].to_i == 0 for_xml['passengers']['children'] = hash[:children].to_i unless hash[:children].to_i == 0 for_xml['passengers']['infants'] = hash[:infants].to_i unless hash[:infants].to_i == 0 for_xml['pickupLocationId'] = hash[:pickup_location_id].to_i unless hash[:pickup_location_id].blank? _wrap_xml_request(for_xml) end
add_package_to_cart(hash: {})
click to toggle source
# File lib/zapi_xml.rb, line 57 def add_package_to_cart hash: {} _wrap_xml_request({ "methodName" => "zapiAddPackageToCart", "cartId" => session.cart_id, "packageId" => hash[:package_id], "passengers" => { "adults" => hash[:adults].to_i, "students" => hash[:students].to_i, "children" => hash[:children].to_i }, "activities" => _activities(hash[:activities]), "products" => nil }) end
add_product_to_cart(product_id:, quantity: _wrap_xml_request({ "methodName" => 'zapiAddProductToCart', "cartId" => session.cart_id, "productId" => product_id, "quantity" => quantity)
click to toggle source
# File lib/zapi_xml.rb, line 131 def add_product_to_cart product_id:, quantity: _wrap_xml_request({ "methodName" => 'zapiAddProductToCart', "cartId" => session.cart_id, "productId" => product_id, "quantity" => quantity }) end
agent_login(username:, password: _wrap_xml_request( { "methodName" => 'zapiAgentLogin' }, { "zapiUsername" => username, "zapiPassword" => password })
click to toggle source
# File lib/zapi_xml.rb, line 9 def agent_login username:, password: _wrap_xml_request( { "methodName" => 'zapiAgentLogin' }, { "zapiUsername" => username, "zapiPassword" => password } ) end
agents_get_profile(agent_id:, agent_hash: _wrap_xml_request({ "methodName" => 'zapiAgents_GetProfile', "agentID" => agent_id, 'agentHashKey' => agent_hash)
click to toggle source
# File lib/zapi_xml.rb, line 16 def agents_get_profile agent_id:, agent_hash: _wrap_xml_request({ "methodName" => 'zapiAgents_GetProfile', "agentID" => agent_id, 'agentHashKey' => agent_hash }) end
check_activity_inventory_by_date(hash: {})
click to toggle source
# File lib/zapi_xml.rb, line 242 def check_activity_inventory_by_date hash: {} _wrap_xml_request({ "methodName" => 'zapiCheckActivityInventoryByDate', "activityId" => hash[:activity_id], "activityDate" => hash[:activity_date], "activityTime" => hash[:activity_time], "pickupLocationId" => hash[:pickup_location_id], "dropoffLocationId" => hash[:dropoff_location_id], "requestedPassengers" => { "seniors" => hash[:seniors], "adults" => hash[:adults], "students" => hash[:students], "children" => hash[:children], "infants" => hash[:infants] }, "pricingOptions" => { "option" => { "optionId" => hash[:option_id], "quantity" => hash[:quantity] } } }) end
check_product_inventory(product_id:, quantity: _wrap_xml_request({ "methodName" => 'zapiCheckProductInventory', "productId" => product_id, "quantity" => quantity)
click to toggle source
# File lib/zapi_xml.rb, line 266 def check_product_inventory product_id:, quantity: _wrap_xml_request({ "methodName" => 'zapiCheckProductInventory', "productId" => product_id, "quantity" => quantity }) end
clear_cart_session()
click to toggle source
# File lib/zapi_xml.rb, line 98 def clear_cart_session _wrap_xml_request({ "methodName" => 'zapiClearCartSession', "cartId" => session.cart_id }) end
email_booking_itinerary(booking_number: _wrap_xml_request({ "methodName" => "zapiEmailBookingItinerary", "bookingNumber" => booking_number)
click to toggle source
# File lib/zapi_xml.rb, line 326 def email_booking_itinerary booking_number: _wrap_xml_request({ "methodName" => "zapiEmailBookingItinerary", "bookingNumber" => booking_number }) end
get_activities_by_category_id(id)
click to toggle source
# File lib/zapi_xml.rb, line 78 def get_activities_by_category_id id _wrap_xml_request({ "methodName" => 'zapiGetActivitiesByCategoryId', "categoryId" => id }) end
get_activity_and_product_catalog()
click to toggle source
# File lib/zapi_xml.rb, line 31 def get_activity_and_product_catalog _wrap_xml_request({ "methodName" => 'zapiGetActivityAndProductCatalog' }) end
get_activity_categories()
click to toggle source
# File lib/zapi_xml.rb, line 72 def get_activity_categories _wrap_xml_request({ "methodName" => 'zapiGetActivityCategories' }) end
get_activity_details_by_activity_id(id, date: nil)
click to toggle source
# File lib/zapi_xml.rb, line 222 def get_activity_details_by_activity_id id, date: nil hash = { "methodName" => 'zapiGetActivityDetailsByActivityId', "activityId" => id } if date hash.merge!({ "activityDate" => date }) end _wrap_xml_request(hash) end
get_all_activities_by_date(date: _wrap_xml_request({ "methodName" => 'zapiGetAllActivitiesByDate', "activityDate" => date.strftime("%Y-%m-%d"))
click to toggle source
# File lib/zapi_xml.rb, line 162 def get_all_activities_by_date date: _wrap_xml_request({ "methodName" => 'zapiGetAllActivitiesByDate', "activityDate" => date.strftime("%Y-%m-%d") }) end
get_all_activities_by_name(activity_name: _wrap_xml_request({ "methodName" => 'zapiGetAllActivitiesByName', "activityNameToSearch" => activity_name)
click to toggle source
# File lib/zapi_xml.rb, line 155 def get_all_activities_by_name activity_name: _wrap_xml_request({ "methodName" => 'zapiGetAllActivitiesByName', "activityNameToSearch" => activity_name }) end
get_all_merchandise_by_name(product_name: _wrap_xml_request({ "methodName" => 'zapiGetAllMerchandiseByName', "productNameToSearch" => product_name)
click to toggle source
# File lib/zapi_xml.rb, line 148 def get_all_merchandise_by_name product_name: _wrap_xml_request({ "methodName" => 'zapiGetAllMerchandiseByName', "productNameToSearch" => product_name }) end
get_cart_contents()
click to toggle source
# File lib/zapi_xml.rb, line 105 def get_cart_contents raw = _wrap_xml_request({ "methodName" => 'zapiGetCartContents', "cartId" => session.cart_id }) end
get_manifest_entire_day_by_date(date: _wrap_xml_request({ "methodName" => 'zapiGetManifestEntireDayByDate', "date" => date)
click to toggle source
# File lib/zapi_xml.rb, line 348 def get_manifest_entire_day_by_date date: _wrap_xml_request({ "methodName" => 'zapiGetManifestEntireDayByDate', "date" => date }) end
get_merchandise_by_category_id(id)
click to toggle source
# File lib/zapi_xml.rb, line 91 def get_merchandise_by_category_id id _wrap_xml_request({ "methodName" => 'zapiGetMerchandiseByCategoryId', "categoryId" => id }) end
get_merchandise_categories()
click to toggle source
# File lib/zapi_xml.rb, line 85 def get_merchandise_categories _wrap_xml_request({ "methodName" => 'zapiGetMerchandiseCategories' }) end
get_package_categories()
click to toggle source
# File lib/zapi_xml.rb, line 37 def get_package_categories _wrap_xml_request({ "methodName" => 'zapiGetPackageCategories' }) end
get_package_details_by_package_id(id)
click to toggle source
# File lib/zapi_xml.rb, line 50 def get_package_details_by_package_id id _wrap_xml_request({ "methodName" => 'zapiGetPackageDetailsByPackageId', "packageId" => id }) end
get_packages_by_category_id(id)
click to toggle source
# File lib/zapi_xml.rb, line 43 def get_packages_by_category_id id _wrap_xml_request({ "methodName" => 'zapiGetPackagesByCategoryId', "categoryId" => id }) end
get_product_details_by_product_id(id)
click to toggle source
# File lib/zapi_xml.rb, line 235 def get_product_details_by_product_id id _wrap_xml_request({ "methodName" => 'zapiGetProductDetailsByProductId', "productId" => id }) end
gift_certificate_apply(gift_certificate: _wrap_xml_request({ "methodName" => 'zapiGiftCertificateApply', "cartId" => session.cart_id, "giftCertificate" => gift_certificate)
click to toggle source
# File lib/zapi_xml.rb, line 340 def gift_certificate_apply gift_certificate: _wrap_xml_request({ "methodName" => 'zapiGiftCertificateApply', "cartId" => session.cart_id, "giftCertificate" => gift_certificate }) end
load_booking_into_cart(booking_number: _wrap_xml_request({ "methodName" => "zapiLoadBookingIntoCart", "bookingNumber" => booking_number)
click to toggle source
# File lib/zapi_xml.rb, line 333 def load_booking_into_cart booking_number: _wrap_xml_request({ "methodName" => "zapiLoadBookingIntoCart", "bookingNumber" => booking_number }) end
mobile_login(username:, password: _wrap_xml_request( { "methodName" => 'zapiMobileLogin' }, { "zapiUsername" => username, "zapiPassword" => password })
click to toggle source
# File lib/zapi_xml.rb, line 24 def mobile_login username:, password: _wrap_xml_request( { "methodName" => 'zapiMobileLogin' }, { "zapiUsername" => username, "zapiPassword" => password } ) end
price_quote(activity_date:, activity_id:, pickup_location_id:, passengers: {})
click to toggle source
# File lib/zapi_xml.rb, line 169 def price_quote activity_date:, activity_id:, pickup_location_id:, passengers: {} _wrap_xml_request({ "methodName" => 'zapiPriceQuote', "activityId" => activity_id, "activityDate" => activity_date.strftime("%Y-%m-%d"), "passengers" => { "seniors" => passengers[:seniors].to_i, "adults" => passengers[:adults].to_i, "students" => passengers[:students].to_i, "children" => passengers[:children].to_i, "infants" => passengers[:infants].to_i }, "pickupLocationId" => pickup_location_id }) end
process_cart_with_payment(hash:, paymentMethodType: _wrap_xml_request({ "methodName" => 'zapiProcessCartWithPayment', "cartId" => session.cart_id, "paymentMethod" => { "paymentMethodType" => paymentMethodType)
click to toggle source
# File lib/zapi_xml.rb, line 274 def process_cart_with_payment hash:, paymentMethodType: _wrap_xml_request({ "methodName" => 'zapiProcessCartWithPayment', "cartId" => session.cart_id, "paymentMethod" => { "paymentMethodType" => paymentMethodType }, "paymentGatewayId" => nil, "creditCardDetails" => { "nameOnCard" => hash[:name_on_card], "number" => hash[:cc_num], "expMonth" => hash[:expiration_month], "expYear" => hash[:expiration_year], "csv" => hash[:csv], "cardType" => hash[:card_type], "rawSwipeData" => nil, "track1Data" => nil, "track2Data" => nil } }) end
process_single_transaction(hash: _wrap_xml_request({ "methodName" => 'zapiProcessSingleTransaction', "cartId" => session.cart_id, "transactionDetails" => { "transactionType" => 2000, "transactionAmount" => hash[:amount], "creditCardDetails" => { "nameOnCard" => hash[:name_on_card], "number" => hash[:cc_num], "expMonth" => hash[:expiration_month], "expYear" => hash[:expiration_year], "csv" => hash[:csv], "cardType" => hash[:card_type], "rawSwipeData" => nil, "track1Data" => nil, "track2Data" => nil)
click to toggle source
# File lib/zapi_xml.rb, line 304 def process_single_transaction hash: _wrap_xml_request({ "methodName" => 'zapiProcessSingleTransaction', "cartId" => session.cart_id, "transactionDetails" => { "transactionType" => 2000, "transactionAmount" => hash[:amount], "creditCardDetails" => { "nameOnCard" => hash[:name_on_card], "number" => hash[:cc_num], "expMonth" => hash[:expiration_month], "expYear" => hash[:expiration_year], "csv" => hash[:csv], "cardType" => hash[:card_type], "rawSwipeData" => nil, "track1Data" => nil, "track2Data" => nil } } }) end
promotion_code_apply(promo_code: foo = _wrap_xml_request({ "methodName" => 'zapiPromotionCodeApply', "cartId" => session.cart_id, "promoCodeName" => promo_code)
click to toggle source
# File lib/zapi_xml.rb, line 296 def promotion_code_apply promo_code: foo = _wrap_xml_request({ "methodName" => 'zapiPromotionCodeApply', "cartId" => session.cart_id, "promoCodeName" => promo_code }) end
remove_activity_cart_item(activity_id:, date: nil)
click to toggle source
# File lib/zapi_xml.rb, line 211 def remove_activity_cart_item activity_id:, date: nil date = date.strftime("%Y-%m-%d") if date.is_a? Date _wrap_xml_request({ "methodName" => 'zapiRemoveActivityCartItem', "cartId" => session.cart_id, "activityId" => activity_id, "activityDate" => date }) end
remove_product_cart_item(product_id: _wrap_xml_request({ "methodName" => 'zapiRemoveProductCartItem', "cartId" => session.cart_id, "productId" => product_id)
click to toggle source
# File lib/zapi_xml.rb, line 140 def remove_product_cart_item product_id: _wrap_xml_request({ "methodName" => 'zapiRemoveProductCartItem', "cartId" => session.cart_id, "productId" => product_id }) end
update_customer_details_to_cart(first_name:, last_name:, phone:, email: _wrap_xml_request({ "methodName" => 'zapiUpdateCustomerDetailsToCart', "cartId" => session.cart_id, "firstName" => first_name, "lastName" => last_name, "mobileNumber" => phone, "email" => email)
click to toggle source
# File lib/zapi_xml.rb, line 120 def update_customer_details_to_cart first_name:, last_name:, phone:, email: _wrap_xml_request({ "methodName" => 'zapiUpdateCustomerDetailsToCart', "cartId" => session.cart_id, "firstName" => first_name, "lastName" => last_name, "mobileNumber" => phone, "email" => email }) end
update_notes_to_cart(notes)
click to toggle source
# File lib/zapi_xml.rb, line 112 def update_notes_to_cart notes _wrap_xml_request({ "methodName" => 'zapiUpdateNotesToCart', "cartId" => session.cart_id, "notes" => notes }) end