Class: Zaui
- Inherits:
-
Object
- Object
- Zaui
- Defined in:
- lib/zaui.rb
Instance Attribute Summary collapse
-
#responder ⇒ Object
readonly
Returns the value of attribute responder.
-
#xml ⇒ Object
readonly
Returns the value of attribute xml.
-
#zapi ⇒ Object
readonly
Returns the value of attribute zapi.
Instance Method Summary collapse
- #_zapi(xml) ⇒ Object
- #add_activity_to_cart(id:, date:, end_date: nil, passengers: {adults: 0, children: 0, infants: 0}, pickup_location_id: nil, rental: {start_time: nil, end_time: nil}) ⇒ Object
- #add_product_to_cart(product_id:, quantity:) ⇒ 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_categories ⇒ Object
- #get_activity_details_by_activity_id(id, date: nil) ⇒ Object
- #get_cart_contents ⇒ Object
- #get_merchandise_by_category_id(id) ⇒ Object
- #get_merchandise_categories ⇒ Object
- #get_package_categories ⇒ Object
- #get_packages_by_category_id(id) ⇒ Object
- #get_product_details_by_product_id(id) ⇒ Object
- #get_products ⇒ Object
-
#initialize(zapi: nil, zapi_xml: nil, responder: nil, session: nil) ⇒ Zaui
constructor
A new instance of Zaui.
- #load_booking_into_cart(booking_number:) ⇒ Object
- #process_cart_with_payment(hash: {}) ⇒ Object
- #process_single_transaction(hash: {}) ⇒ Object
- #promotion_code_apply(code:) ⇒ Object
- #remove_activity_cart_item(id:, date: nil) ⇒ Object
- #remove_product_cart_item(id:) ⇒ Object
- #update_customer_details_to_cart(first_name:, last_name:, phone:, email:) ⇒ Object
- #update_notes_to_cart(notes) ⇒ Object
Constructor Details
#initialize(zapi: nil, zapi_xml: nil, responder: nil, session: nil) ⇒ Zaui
Returns a new instance of Zaui.
5 6 7 8 9 |
# File 'lib/zaui.rb', line 5 def initialize zapi: nil, zapi_xml: nil, responder: nil, session: nil @zapi = zapi || Zapi.new() @xml = zapi_xml || ZapiXML.new(session: ZapiObject.new(hash: session)) @responder = responder || ZapiObject end |
Instance Attribute Details
#responder ⇒ Object (readonly)
Returns the value of attribute responder.
3 4 5 |
# File 'lib/zaui.rb', line 3 def responder @responder end |
#xml ⇒ Object (readonly)
Returns the value of attribute xml.
3 4 5 |
# File 'lib/zaui.rb', line 3 def xml @xml end |
#zapi ⇒ Object (readonly)
Returns the value of attribute zapi.
3 4 5 |
# File 'lib/zaui.rb', line 3 def zapi @zapi end |
Instance Method Details
#_zapi(xml) ⇒ Object
161 162 163 |
# File 'lib/zaui.rb', line 161 def _zapi xml zapi.request(xml: xml) end |
#add_activity_to_cart(id:, date:, end_date: nil, passengers: {adults: 0, children: 0, infants: 0}, pickup_location_id: nil, rental: {start_time: nil, end_time: nil}) ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/zaui.rb', line 47 def add_activity_to_cart id:, date:, end_date: nil, passengers: {adults: 0, children: 0, infants: 0}, pickup_location_id: nil, rental: {start_time: nil, end_time: nil} hash = { activity_id: id, activity_date: date, activity_end_date: end_date, adults: passengers[:adults], children: passengers[:children], infants: passengers[:infants], rental_start_time: rental[:start_time], rental_end_time: rental[:end_time], pickup_location_id: pickup_location_id } raw = _zapi(xml.add_activity_to_cart(hash: hash)) end |
#add_product_to_cart(product_id:, quantity:) ⇒ Object
27 28 29 |
# File 'lib/zaui.rb', line 27 def add_product_to_cart product_id:, quantity: raw = _zapi(xml.add_product_to_cart(product_id: product_id, quantity: quantity)) end |
#agents_get_profile(agent_id:, agent_hash:) ⇒ Object
11 12 13 |
# File 'lib/zaui.rb', line 11 def agents_get_profile agent_id:, agent_hash: raw = _zapi(xml.agents_get_profile(agent_id: agent_id, agent_hash: agent_hash)) end |
#check_activity_inventory_by_date(hash:) ⇒ Object
146 147 148 149 150 151 152 153 154 155 |
# File 'lib/zaui.rb', line 146 def check_activity_inventory_by_date hash: inventory_data = { activity_id: hash[:activity_id], activity_date: hash[:activity_date], adults: hash[:adults], children: hash[:children], infants: hash[:infants] } raw = _zapi(xml.check_activity_inventory_by_date(hash: inventory_data)) end |
#check_product_inventory(product_id:, quantity:) ⇒ Object
70 71 72 |
# File 'lib/zaui.rb', line 70 def check_product_inventory product_id:, quantity: raw = _zapi(xml.check_product_inventory(product_id: product_id, quantity: quantity)) end |
#clear_cart_session ⇒ Object
157 158 159 |
# File 'lib/zaui.rb', line 157 def clear_cart_session raw = _zapi(xml.clear_cart_session) end |
#email_booking_itinerary(booking_number:) ⇒ Object
130 131 132 |
# File 'lib/zaui.rb', line 130 def email_booking_itinerary booking_number: raw = _zapi(xml.email_booking_itinerary(booking_number: booking_number)) end |
#get_activities_by_category_id(id) ⇒ Object
39 40 41 |
# File 'lib/zaui.rb', line 39 def get_activities_by_category_id id raw = _zapi(xml.get_activities_by_category_id(id)).try(:[],'activities').try(:[],'activity') end |
#get_activity_categories ⇒ Object
35 36 37 |
# File 'lib/zaui.rb', line 35 def get_activity_categories raw = _zapi(xml.get_activity_categories).try(:[],'categories').try(:[],'category') end |
#get_activity_details_by_activity_id(id, date: nil) ⇒ Object
43 44 45 |
# File 'lib/zaui.rb', line 43 def get_activity_details_by_activity_id id, date: nil raw = _zapi(xml.get_activity_details_by_activity_id(id, date: date)).try(:[],'activity') end |
#get_cart_contents ⇒ Object
74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/zaui.rb', line 74 def get_cart_contents raw = _zapi(xml.get_cart_contents) activities = raw.try(:[],'cart').try(:[],'activities').try(:[],'activity') activities = activities.is_a?(Array) ? activities : [activities] tax = raw.try(:[],'cart').try(:[],'cartTotals').try(:[],'tax') products = raw.try(:[],'cart').try(:[],'products').try(:[],'product') products = products.is_a?(Array) ? products : [products] { :activities => activities, :products => products, :tax => tax, :total => raw['cart']['remainingBalance']['balance'] } end |
#get_merchandise_by_category_id(id) ⇒ Object
23 24 25 |
# File 'lib/zaui.rb', line 23 def get_merchandise_by_category_id id raw = _zapi(xml.get_merchandise_by_category_id(id)).try(:[],'products').try(:[],'product') end |
#get_merchandise_categories ⇒ Object
19 20 21 |
# File 'lib/zaui.rb', line 19 def get_merchandise_categories raw = _zapi(xml.get_merchandise_categories).try(:[],'categories').try(:[],'category') end |
#get_package_categories ⇒ Object
138 139 140 |
# File 'lib/zaui.rb', line 138 def get_package_categories raw = _zapi(xml.get_package_categories)[:categories][:category] end |
#get_packages_by_category_id(id) ⇒ Object
142 143 144 |
# File 'lib/zaui.rb', line 142 def get_packages_by_category_id id raw = _zapi(xml.get_packages_by_category_id(id)) end |
#get_product_details_by_product_id(id) ⇒ Object
31 32 33 |
# File 'lib/zaui.rb', line 31 def get_product_details_by_product_id id raw = _zapi(xml.get_product_details_by_product_id(id)).try(:[],'product') end |
#get_products ⇒ Object
15 16 17 |
# File 'lib/zaui.rb', line 15 def get_products raw = _zapi(xml.get_activity_and_product_catalog).try(:[],'products').try(:[],'product') end |
#load_booking_into_cart(booking_number:) ⇒ Object
134 135 136 |
# File 'lib/zaui.rb', line 134 def load_booking_into_cart booking_number: raw = _zapi(xml.load_booking_into_cart(booking_number: booking_number)) end |
#process_cart_with_payment(hash: {}) ⇒ Object
107 108 109 110 111 112 113 114 115 116 |
# File 'lib/zaui.rb', line 107 def process_cart_with_payment hash: {} cart_data = { name_on_card: hash[:name_on_card], cc_num: hash[:cc_num].gsub(/[^\d]/, ''), expiration_month: hash[:expiration_month], expiration_year: hash[:expiration_year], csv: hash[:csv] } raw = _zapi(xml.process_cart_with_payment(hash: cart_data)) end |
#process_single_transaction(hash: {}) ⇒ Object
118 119 120 121 122 123 124 125 126 127 128 |
# File 'lib/zaui.rb', line 118 def process_single_transaction hash: {} cart_data = { amount: hash[:amount], name_on_card: hash[:name_on_card], cc_num: hash[:cc_num].gsub(/[^\d]/, ''), expiration_month: hash[:expiration_month], expiration_year: hash[:expiration_year], csv: hash[:csv] } raw = _zapi(xml.process_single_transaction(hash: cart_data)) end |
#promotion_code_apply(code:) ⇒ Object
103 104 105 |
# File 'lib/zaui.rb', line 103 def promotion_code_apply code: raw = _zapi(xml.promotion_code_apply(promo_code: code)) end |
#remove_activity_cart_item(id:, date: nil) ⇒ Object
62 63 64 |
# File 'lib/zaui.rb', line 62 def remove_activity_cart_item id:, date: nil raw = _zapi(xml.remove_activity_cart_item(activity_id: id, date: date)) end |
#remove_product_cart_item(id:) ⇒ Object
66 67 68 |
# File 'lib/zaui.rb', line 66 def remove_product_cart_item id: raw = _zapi(xml.remove_product_cart_item(product_id: id)) end |
#update_customer_details_to_cart(first_name:, last_name:, phone:, email:) ⇒ Object
89 90 91 92 93 94 95 96 97 |
# File 'lib/zaui.rb', line 89 def update_customer_details_to_cart first_name:, last_name:, phone:, email: request = xml.update_customer_details_to_cart( first_name: first_name, last_name: last_name, phone: phone, email: email ) raw = _zapi(request) end |
#update_notes_to_cart(notes) ⇒ Object
99 100 101 |
# File 'lib/zaui.rb', line 99 def update_notes_to_cart notes raw = _zapi(xml.update_notes_to_cart(notes)) end |