zaui_zapi 0.1.1 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/lib/version.rb +1 -1
  3. data/lib/zapi_xml.rb +26 -8
  4. data/lib/zaui.rb +62 -1
  5. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 50bdde3617f28e6a94bfd0d8e3674d7bca45c5e7
4
- data.tar.gz: 55646b4d1755146775663bbd110681b49b42f3b6
3
+ metadata.gz: 4027bdfbf857f351ffd2aca9f7d0fff0e3c2b859
4
+ data.tar.gz: b07d37b5df5fbafd45f6b9ea2deed109bf2f9cb5
5
5
  SHA512:
6
- metadata.gz: 5bc23752049600fb86e43b2b39205045b00508fec23761bea992533f511d6c4cd1d8c5abb755f242327f626cb5f9566e05154a47d2e82f3aabad4d42e7a8a2cd
7
- data.tar.gz: 57af1d47b8b055dfd38a46bf14fcde4148b3522e87d8962d522b094b2dbdb52ac22ba29ef68e3390b27b1a7645b30c81c5403f88c6ac3931fbc1726eab5ceebc
6
+ metadata.gz: cd5c769d5f9df7b60139323f1669fac59be5cb8e3943b2e0d8b94e490824f0efcd9fd2d84bb7c901ea1fff699c7f97f2d4ba8e3e811a1f0d82c3b5cfbc9856c3
7
+ data.tar.gz: b5f735c0c804418dcb2d7accd2f652935e74887bfae9393621935ac5a4e52a5a193762f6e0ab67ebdfb975329dd59bcaf7f9d44572d7f55a2b2184b17ec6397f
data/lib/version.rb CHANGED
@@ -1 +1 @@
1
- VERSION = '0.1.1'
1
+ VERSION = '0.1.4'
data/lib/zapi_xml.rb CHANGED
@@ -152,6 +152,22 @@ class ZapiXML
152
152
  })
153
153
  end
154
154
 
155
+ def price_quote activity_date:, activity_id:, pickup_location_id:, passengers: {}
156
+ _wrap_xml_request({
157
+ "methodName" => 'zapiPriceQuote',
158
+ "activityId" => activity_id,
159
+ "activityDate" => activity_date.strftime("%Y-%m-%d"),
160
+ "passengers" => {
161
+ "seniors" => passengers[:seniors].to_i,
162
+ "adults" => passengers[:adults].to_i,
163
+ "students" => passengers[:students].to_i,
164
+ "children" => passengers[:children].to_i,
165
+ "infants" => passengers[:infants].to_i
166
+ },
167
+ "pickupLocationId" => pickup_location_id
168
+ })
169
+ end
170
+
155
171
  def add_activity_to_cart hash: {}
156
172
  _wrap_xml_request({
157
173
  "methodName" => 'zapiAddActivityToCart',
@@ -168,7 +184,7 @@ class ZapiXML
168
184
  }
169
185
  },
170
186
  "passengers" => {
171
- "seniors" => hash[:seniors].to_I,
187
+ "seniors" => hash[:seniors].to_i,
172
188
  "adults" => hash[:adults].to_i,
173
189
  "students" => hash[:students].to_i,
174
190
  "children" => hash[:children].to_i,
@@ -180,19 +196,21 @@ class ZapiXML
180
196
  })
181
197
  end
182
198
 
183
- def remove_activity_cart_item activity_id:, date:
199
+ def remove_activity_cart_item activity_id:, date: nil
200
+ date = date.strftime("%Y-%m-%d") if date.is_a? Date
201
+
184
202
  _wrap_xml_request({
185
203
  "methodName" => 'zapiRemoveActivityCartItem',
186
204
  "cartId" => session.cart_id,
187
205
  "activityId" => activity_id,
188
- "activityDate" => date.strftime("%Y-%m-%d")
206
+ "activityDate" => date
189
207
  })
190
208
  end
191
209
 
192
- def get_activity_details_by_activity_id activity_id:, date: nil
210
+ def get_activity_details_by_activity_id id, date: nil
193
211
  hash = {
194
212
  "methodName" => 'zapiGetActivityDetailsByActivityId',
195
- "activityId" => activity_id
213
+ "activityId" => id
196
214
  }
197
215
  if date
198
216
  hash.merge!({
@@ -213,8 +231,8 @@ class ZapiXML
213
231
  _wrap_xml_request({
214
232
  "methodName" => 'zapiCheckActivityInventoryByDate',
215
233
  "activityId" => hash[:activity_id],
216
- "activityDate" => hash[:activity_date].strftime("%Y-%m-%d"),
217
- "activityTime" => "HH:MM:SS",
234
+ "activityDate" => hash[:activity_date],
235
+ "activityTime" => hash[:activity_time],
218
236
  "pickupLocationId" => hash[:pickup_location_id],
219
237
  "dropoffLocationId" => hash[:dropoff_location_id],
220
238
  "requestedPassengers" => {
@@ -241,7 +259,7 @@ class ZapiXML
241
259
  })
242
260
  end
243
261
 
244
- def process_cart_with_payment hash: {}
262
+ def process_cart_with_payment hash:
245
263
  _wrap_xml_request({
246
264
  "methodName" => 'zapiProcessCartWithPayment',
247
265
  "cartId" => session.cart_id,
data/lib/zaui.rb CHANGED
@@ -16,14 +16,75 @@ class Zaui
16
16
  raw = _zapi(xml.get_activities_by_category_id(id)).try(:[],'activities').try(:[],'activity')
17
17
  end
18
18
 
19
+ def get_activity_details_by_activity_id id
20
+ raw = _zapi(xml.get_activity_details_by_activity_id(id)).try(:[],'activity')
21
+ end
22
+
23
+ def add_activity_to_cart id:, date:, passengers: {adults: 0, children: 0, infants: 0}
24
+ hash = {
25
+ activity_id: id,
26
+ activity_date: date,
27
+ adults: passengers[:adults],
28
+ children: passengers[:children],
29
+ infants: passengers[:infants]
30
+ }
31
+
32
+ raw = _zapi(xml.add_activity_to_cart(hash: hash))
33
+ end
34
+
35
+ def remove_activity_cart_item id:, date: nil
36
+ raw = _zapi(xml.remove_activity_cart_item(activity_id: id, date: date))
37
+ end
38
+
39
+ def get_cart_contents
40
+ activities = _zapi(xml.get_cart_contents).try(:[],'cart').try(:[],'activities').try(:[],'activity')
41
+ activities.is_a?(Array) ? activities : [activities]
42
+ end
43
+
44
+ def update_customer_details_to_cart first_name:, last_name:, phone:, email:
45
+ request = xml.update_customer_details_to_cart(
46
+ first_name: first_name,
47
+ last_name: last_name,
48
+ phone: phone,
49
+ email: email
50
+ )
51
+ raw = _zapi(request)
52
+ end
53
+
54
+ def process_cart_with_payment hash: {}
55
+ cart_data = {
56
+ name_on_card: hash[:name_on_card],
57
+ cc_num: hash[:cc_num].gsub(/[^\d]/, ''),
58
+ expiration_month: hash[:expiration_month],
59
+ expiration_year: hash[:expiration_year],
60
+ csv: hash[:csv]
61
+ }
62
+ raw = _zapi(xml.process_cart_with_payment(hash: cart_data))
63
+ end
64
+
19
65
  def get_package_categories
20
- raw = _zapi xml.get_package_categories[:categories][:category]
66
+ raw = _zapi(xml.get_package_categories)[:categories][:category]
21
67
  end
22
68
 
23
69
  def get_packages_by_category_id id
24
70
  raw = _zapi(xml.get_packages_by_category_id(id))
25
71
  end
26
72
 
73
+ def check_activity_inventory_by_date hash:
74
+ inventory_data = {
75
+ activity_id: hash[:activity_id],
76
+ activity_date: hash[:activity_date],
77
+ adults: hash[:adults],
78
+ children: hash[:children],
79
+ infants: hash[:infants]
80
+ }
81
+ raw = _zapi(xml.check_activity_inventory_by_date(hash: inventory_data))
82
+ end
83
+
84
+ def clear_cart_session
85
+ raw = _zapi(xml.clear_cart_session)
86
+ end
87
+
27
88
  def _zapi xml
28
89
  zapi.request(xml: xml)
29
90
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zaui_zapi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shane Kretzmann
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-08-11 00:00:00.000000000 Z
11
+ date: 2015-08-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest