Class: ZapiXML
- Inherits:
-
Object
- Object
- ZapiXML
- Defined in:
- lib/zapi_xml.rb
Instance Attribute Summary collapse
-
#session ⇒ Object
readonly
Returns the value of attribute session.
Instance Method Summary collapse
- #_activities(activities) ⇒ Object
- #_wrap_xml_request(method, params = {}) ⇒ Object
- #add_activity_to_cart(hash: {}) ⇒ Object
- #add_package_to_cart(hash: {}) ⇒ Object
- #add_product_to_cart(product_id:, quantity:) ⇒ Object
- #agent_login(username:, password:) ⇒ Object
- #agents_get_profile(agent_id:, agent_hash:) ⇒ Object
- #check_activity_inventory_by_date(hash: {}) ⇒ Object
- #check_product_inventory(product_id:, quantity:) ⇒ Object
- #clear_cart_session ⇒ Object
- #email_booking_itinerary(booking_number:) ⇒ Object
- #get_activities_by_category_id(id) ⇒ Object
- #get_activity_and_product_catalog ⇒ Object
- #get_activity_categories ⇒ Object
- #get_activity_details_by_activity_id(id, date: nil) ⇒ Object
- #get_all_activities_by_date(date:) ⇒ Object
- #get_all_activities_by_name(activity_name:) ⇒ Object
- #get_all_merchandise_by_name(product_name:) ⇒ Object
- #get_cart_contents ⇒ Object
- #get_manifest_entire_day_by_date(date:) ⇒ Object
- #get_merchandise_by_category_id(id) ⇒ Object
- #get_merchandise_categories ⇒ Object
- #get_package_categories ⇒ Object
- #get_package_details_by_package_id(id) ⇒ Object
- #get_packages_by_category_id(id) ⇒ Object
- #get_product_details_by_product_id(id) ⇒ Object
- #gift_certificate_apply(gift_certificate:) ⇒ Object
-
#initialize(session: nil) ⇒ ZapiXML
constructor
A new instance of ZapiXML.
- #load_booking_into_cart(booking_number:) ⇒ Object
- #mobile_login(username:, password:) ⇒ Object
- #price_quote(activity_date:, activity_id:, pickup_location_id:, passengers: {}) ⇒ Object
- #process_cart_with_payment(hash:, paymentMethodType:) ⇒ Object
- #process_single_transaction(hash:) ⇒ Object
- #promotion_code_apply(promo_code:) ⇒ Object
- #remove_activity_cart_item(activity_id:, date: nil) ⇒ Object
- #remove_product_cart_item(product_id:) ⇒ Object
- #update_customer_details_to_cart(first_name:, last_name:, phone:, email:) ⇒ Object
- #update_notes_to_cart(notes) ⇒ Object
Constructor Details
#initialize(session: nil) ⇒ ZapiXML
Returns a new instance of ZapiXML.
5 6 7 |
# File 'lib/zapi_xml.rb', line 5 def initialize session: nil @session = session end |
Instance Attribute Details
#session ⇒ Object (readonly)
Returns the value of attribute session.
3 4 5 |
# File 'lib/zapi_xml.rb', line 3 def session @session end |
Instance Method Details
#_activities(activities) ⇒ Object
373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 |
# File 'lib/zapi_xml.rb', line 373 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 = {}) ⇒ Object
359 360 361 362 363 364 365 366 367 368 369 370 371 |
# File 'lib/zapi_xml.rb', line 359 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: {}) ⇒ Object
185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 |
# 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" => { }, "checkOnlineThresholds" => nil, "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? #new undocumented flag so Zaui validates the activity time against the thresholds (defaulting to 1 for true) for_xml['checkOnlineThresholds'] = hash[:check_online_thresholds].to_i || 1 _wrap_xml_request(for_xml) end |
#add_package_to_cart(hash: {}) ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# 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:) ⇒ Object
131 132 133 134 135 136 137 138 |
# 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:) ⇒ Object
9 10 11 12 13 14 |
# 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:) ⇒ Object
16 17 18 19 20 21 22 |
# 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: {}) ⇒ Object
246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 |
# File 'lib/zapi_xml.rb', line 246 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:) ⇒ Object
270 271 272 273 274 275 276 |
# File 'lib/zapi_xml.rb', line 270 def check_product_inventory product_id:, quantity: _wrap_xml_request({ "methodName" => 'zapiCheckProductInventory', "productId" => product_id, "quantity" => quantity }) end |
#clear_cart_session ⇒ Object
98 99 100 101 102 103 |
# 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:) ⇒ Object
330 331 332 333 334 335 |
# File 'lib/zapi_xml.rb', line 330 def email_booking_itinerary booking_number: _wrap_xml_request({ "methodName" => "zapiEmailBookingItinerary", "bookingNumber" => booking_number }) end |
#get_activities_by_category_id(id) ⇒ Object
78 79 80 81 82 83 |
# 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 ⇒ Object
31 32 33 34 35 |
# File 'lib/zapi_xml.rb', line 31 def get_activity_and_product_catalog _wrap_xml_request({ "methodName" => 'zapiGetActivityAndProductCatalog' }) end |
#get_activity_categories ⇒ Object
72 73 74 75 76 |
# 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) ⇒ Object
226 227 228 229 230 231 232 233 234 235 236 237 |
# File 'lib/zapi_xml.rb', line 226 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:) ⇒ Object
162 163 164 165 166 167 |
# 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:) ⇒ Object
155 156 157 158 159 160 |
# 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:) ⇒ Object
148 149 150 151 152 153 |
# 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 ⇒ Object
105 106 107 108 109 110 |
# 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:) ⇒ Object
352 353 354 355 356 357 |
# File 'lib/zapi_xml.rb', line 352 def get_manifest_entire_day_by_date date: _wrap_xml_request({ "methodName" => 'zapiGetManifestEntireDayByDate', "date" => date }) end |
#get_merchandise_by_category_id(id) ⇒ Object
91 92 93 94 95 96 |
# 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 ⇒ Object
85 86 87 88 89 |
# File 'lib/zapi_xml.rb', line 85 def get_merchandise_categories _wrap_xml_request({ "methodName" => 'zapiGetMerchandiseCategories' }) end |
#get_package_categories ⇒ Object
37 38 39 40 41 |
# File 'lib/zapi_xml.rb', line 37 def get_package_categories _wrap_xml_request({ "methodName" => 'zapiGetPackageCategories' }) end |
#get_package_details_by_package_id(id) ⇒ Object
50 51 52 53 54 55 |
# 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) ⇒ Object
43 44 45 46 47 48 |
# 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) ⇒ Object
239 240 241 242 243 244 |
# File 'lib/zapi_xml.rb', line 239 def get_product_details_by_product_id id _wrap_xml_request({ "methodName" => 'zapiGetProductDetailsByProductId', "productId" => id }) end |
#gift_certificate_apply(gift_certificate:) ⇒ Object
344 345 346 347 348 349 350 |
# File 'lib/zapi_xml.rb', line 344 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:) ⇒ Object
337 338 339 340 341 342 |
# File 'lib/zapi_xml.rb', line 337 def load_booking_into_cart booking_number: _wrap_xml_request({ "methodName" => "zapiLoadBookingIntoCart", "bookingNumber" => booking_number }) end |
#mobile_login(username:, password:) ⇒ Object
24 25 26 27 28 29 |
# 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: {}) ⇒ Object
169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 |
# 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:) ⇒ Object
278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 |
# File 'lib/zapi_xml.rb', line 278 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:) ⇒ Object
308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 |
# File 'lib/zapi_xml.rb', line 308 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:) ⇒ Object
300 301 302 303 304 305 306 |
# File 'lib/zapi_xml.rb', line 300 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) ⇒ Object
215 216 217 218 219 220 221 222 223 224 |
# File 'lib/zapi_xml.rb', line 215 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:) ⇒ Object
140 141 142 143 144 145 146 |
# 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:) ⇒ Object
120 121 122 123 124 125 126 127 128 129 |
# 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) ⇒ Object
112 113 114 115 116 117 118 |
# 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 |