ruby-booker 0.0.14 → 0.0.17
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/booker.rb +34 -4
- data/lib/booker/helpers.rb +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d309cbdfef3467adbe861631238dc3000a7da5f8
|
4
|
+
data.tar.gz: 7915ddf991ec8b0fdbcb7e2b9a076a90ec764721
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9f0ee4859b254ebfd021e57c3c960263b5d37247fc7823cca2a99642317b8870744a34c3be0aab40e3258f8af2315d30621f527b22ba666bc5186c7c4fc9600b
|
7
|
+
data.tar.gz: e3e22212b0afa03e4176bd0859702980b173126eb2958f5db5f93626d44fd89cb95ce1118813c102e722a35cedddaf1b89d0e42dddf1d707eb2d6404fc27c2ca
|
data/lib/booker.rb
CHANGED
@@ -2,14 +2,16 @@ require 'httparty'
|
|
2
2
|
require 'booker/helpers'
|
3
3
|
|
4
4
|
module Booker
|
5
|
-
VERSION = "0.0.
|
6
|
-
|
5
|
+
VERSION = "0.0.17"
|
6
|
+
STAGING_BASE_HOST = "stable-app.secure-booker.com"
|
7
|
+
PRODUCTION_BASE_HOST = "app.secure-booker.com"
|
7
8
|
BASE_PATH = "/WebService4/json/customerService.svc"
|
8
9
|
|
9
10
|
class Client
|
10
11
|
attr_reader :url, :access_token, :expires_in, :server_time_offset
|
11
12
|
|
12
|
-
def initialize(key, secret)
|
13
|
+
def initialize(key, secret, options = {})
|
14
|
+
@production = options.fetch(:production) { false }
|
13
15
|
@key = key
|
14
16
|
@secret = secret
|
15
17
|
set_access_token!
|
@@ -191,6 +193,15 @@ module Booker
|
|
191
193
|
return_post_response url, defaults, options
|
192
194
|
end
|
193
195
|
|
196
|
+
def create_appointment options = {}
|
197
|
+
url = build_url "/appointment/create"
|
198
|
+
defaults = {
|
199
|
+
"access_token" => @access_token,
|
200
|
+
}
|
201
|
+
convert_time_to_booker_format! options
|
202
|
+
return_post_response url, defaults, options
|
203
|
+
end
|
204
|
+
|
194
205
|
#http://apidoc.booker.com/Method/Detail/125
|
195
206
|
def get_treatment_categories location_id
|
196
207
|
url = build_url "/treatment_categories",
|
@@ -218,6 +229,13 @@ module Booker
|
|
218
229
|
return_get_response url
|
219
230
|
end
|
220
231
|
|
232
|
+
#http://apidoc.booker.com/Method/Detail/107
|
233
|
+
def get_credit_card_types location_id
|
234
|
+
url = build_url "/location/#{location_id}/creditcard_types",
|
235
|
+
"?access_token=#{@access_token}"
|
236
|
+
return_get_response url
|
237
|
+
end
|
238
|
+
|
221
239
|
#http://apidoc.booker.com/Method/Detail/147
|
222
240
|
def get_server_information
|
223
241
|
url = build_url "/server_information", "?access_token=#{@access_token}"
|
@@ -274,7 +292,7 @@ module Booker
|
|
274
292
|
|
275
293
|
|
276
294
|
def base_url
|
277
|
-
"http://" + Booker::
|
295
|
+
"http://" + (@prouduction ? Booker::PRODUCTION_BASE_HOST : Booker::STAGING_BASE_HOST) + Booker::BASE_PATH
|
278
296
|
end
|
279
297
|
|
280
298
|
def build_url path, query = ''
|
@@ -284,6 +302,18 @@ module Booker
|
|
284
302
|
def convert_time_to_booker_format! options
|
285
303
|
options['StartDateTime'] = Booker::Helpers.format_date options['StartDateTime'], server_time_offset
|
286
304
|
options['EndDateTime'] = Booker::Helpers.format_date options['EndDateTime'], server_time_offset
|
305
|
+
|
306
|
+
if options['ItineraryTimeSlotList']
|
307
|
+
options['ItineraryTimeSlotList'].each do |time_slot_list|
|
308
|
+
|
309
|
+
time_slot_list['StartDateTime'] = Booker::Helpers.format_date time_slot_list['StartDateTime'], server_time_offset
|
310
|
+
|
311
|
+
time_slot_list['TreatmentTimeSlots'].each do |time_slot|
|
312
|
+
time_slot['StartDateTime'] = Booker::Helpers.format_date time_slot['StartDateTime'], server_time_offset
|
313
|
+
end
|
314
|
+
end
|
315
|
+
|
316
|
+
end
|
287
317
|
end
|
288
318
|
|
289
319
|
def log_options options
|
data/lib/booker/helpers.rb
CHANGED
@@ -9,11 +9,11 @@ module Booker
|
|
9
9
|
"/Date(#{(time.in_time_zone(offset)).to_i * 1000})/"
|
10
10
|
end
|
11
11
|
|
12
|
+
# Turn date given by booker api into ruby datetime
|
12
13
|
def self.parse_date time
|
13
14
|
return nil unless time
|
14
15
|
|
15
|
-
|
16
|
-
Time.at(time).to_datetime
|
16
|
+
Time.at( time.scan(/\d+/).first.to_i / 1000 ).to_datetime
|
17
17
|
end
|
18
18
|
end
|
19
19
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-booker
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.17
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jake Craige
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-03-
|
11
|
+
date: 2014-03-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|