booker_ruby 2.0.1 → 3.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/booker/client.rb +5 -3
- data/lib/booker/v4.1/availability.rb +2 -2
- data/lib/booker/v4.1/booking.rb +29 -18
- data/lib/booker/v4.1/merchant.rb +87 -9
- data/lib/booker/v4/common_rest.rb +1 -1
- data/lib/booker/v5/availability.rb +4 -4
- data/lib/booker/version.rb +1 -1
- 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: 041d3e240d6256924589eb8f528409e6f9f96231
|
4
|
+
data.tar.gz: bc4db79ffab85ef87d604e925bb76299c7b9f1b9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 26541378dc2c8760039e63781589b6f10da16f72a975cfbc1077ba08a487df0147fc71041de142ced765aac5e5c7b050778c75b58ea9b2d57d9b7fa1ba5c573b
|
7
|
+
data.tar.gz: b6d81407d710bba52fbe5b7cc5a435f9da93767ea4e32f09a6fe2585f790096a29592711b8b0c7316c8c24e43a5929b3e0c9246cf8cd712277f43a70b21e32d8
|
data/lib/booker/client.rb
CHANGED
@@ -212,7 +212,8 @@ module Booker
|
|
212
212
|
'Content-Type' => CREATE_TOKEN_CONTENT_TYPE,
|
213
213
|
'Ocp-Apim-Subscription-Key' => self.api_subscription_key
|
214
214
|
},
|
215
|
-
body: body.to_query
|
215
|
+
body: body.to_query,
|
216
|
+
timeout: 30
|
216
217
|
}
|
217
218
|
|
218
219
|
url = "#{self.auth_base_url}#{CREATE_TOKEN_PATH}"
|
@@ -237,7 +238,7 @@ module Booker
|
|
237
238
|
query: {
|
238
239
|
locationId: location_id
|
239
240
|
},
|
240
|
-
|
241
|
+
timeout: 30
|
241
242
|
}
|
242
243
|
url = "#{self.auth_base_url}#{UPDATE_TOKEN_CONTEXT_PATH}"
|
243
244
|
|
@@ -262,7 +263,8 @@ module Booker
|
|
262
263
|
'Authorization' => "Bearer #{access_token}",
|
263
264
|
'Ocp-Apim-Subscription-Key' => self.api_subscription_key
|
264
265
|
},
|
265
|
-
open_timeout: 120
|
266
|
+
open_timeout: 120,
|
267
|
+
read_timeout: 300
|
266
268
|
}
|
267
269
|
|
268
270
|
options[:body] = body if body.present?
|
@@ -7,14 +7,14 @@ module Booker
|
|
7
7
|
class_availability: '/v4.1/availability/availability/class'.freeze
|
8
8
|
}.freeze
|
9
9
|
|
10
|
-
def class_availability(location_id:, from_start_date_time:, to_start_date_time:,
|
10
|
+
def class_availability(location_id:, from_start_date_time:, to_start_date_time:, params: {})
|
11
11
|
post API_METHODS[:class_availability], build_params({
|
12
12
|
FromStartDateTime: from_start_date_time,
|
13
13
|
LocationID: location_id,
|
14
14
|
OnlyIfAvailable: true,
|
15
15
|
ToStartDateTime: to_start_date_time,
|
16
16
|
ExcludeClosedDates: true
|
17
|
-
},
|
17
|
+
}, params), Booker::V4::Models::ClassInstance
|
18
18
|
end
|
19
19
|
end
|
20
20
|
end
|
data/lib/booker/v4.1/booking.rb
CHANGED
@@ -3,43 +3,54 @@ module Booker
|
|
3
3
|
class Booking < Booker::Client
|
4
4
|
include Booker::V4::RequestHelper
|
5
5
|
|
6
|
+
V41_PREFIX = '/v4.1/booking'
|
7
|
+
V41_APPOINTMENTS_PREFIX = "#{V41_PREFIX}/appointment"
|
6
8
|
API_METHODS = {
|
7
|
-
appointment:
|
8
|
-
cancel_appointment:
|
9
|
-
create_appointment:
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
9
|
+
appointment: "#{V41_APPOINTMENTS_PREFIX}".freeze,
|
10
|
+
cancel_appointment: "#{V41_APPOINTMENTS_PREFIX}/cancel".freeze,
|
11
|
+
create_appointment: "#{V41_APPOINTMENTS_PREFIX}/create".freeze,
|
12
|
+
create_class_appointment: "#{V41_PREFIX}/class_appointment/create".freeze,
|
13
|
+
appointment_hold: "#{V41_APPOINTMENTS_PREFIX}/hold".freeze,
|
14
|
+
employees: "#{V41_PREFIX}/employees".freeze,
|
15
|
+
services: "#{V41_PREFIX}/services".freeze,
|
16
|
+
location: "#{V41_PREFIX}/location".freeze,
|
17
|
+
locations: "#{V41_PREFIX}/locations".freeze
|
15
18
|
}.freeze
|
16
19
|
|
17
20
|
def appointment(id:)
|
18
21
|
get "#{API_METHODS[:appointment]}/#{id}", build_params, Booker::V4::Models::Appointment
|
19
22
|
end
|
20
23
|
|
21
|
-
def cancel_appointment(id:,
|
22
|
-
put API_METHODS[:cancel_appointment], build_params({ID: id},
|
24
|
+
def cancel_appointment(id:, params: {})
|
25
|
+
put API_METHODS[:cancel_appointment], build_params({ID: id}, params), Booker::V4::Models::Appointment
|
23
26
|
end
|
24
27
|
|
25
|
-
def
|
28
|
+
def create_class_appointment(location_id:, class_instance_id:, customer:, params: {})
|
29
|
+
post API_METHODS[:create_class_appointment], build_params({
|
30
|
+
LocationID: location_id,
|
31
|
+
ClassInstanceID: class_instance_id,
|
32
|
+
Customer: customer
|
33
|
+
}, params), Booker::V4::Models::Appointment
|
34
|
+
end
|
35
|
+
|
36
|
+
def create_appointment(location_id:, available_time:, customer:, params: {})
|
26
37
|
post API_METHODS[:create_appointment], build_params({
|
27
38
|
LocationID: location_id,
|
28
39
|
ItineraryTimeSlotList: [
|
29
40
|
TreatmentTimeSlots: [available_time]
|
30
41
|
],
|
31
42
|
Customer: customer
|
32
|
-
},
|
43
|
+
}, params), Booker::V4::Models::Appointment
|
33
44
|
end
|
34
45
|
|
35
|
-
def create_appointment_hold(location_id:, available_time:, customer:,
|
46
|
+
def create_appointment_hold(location_id:, available_time:, customer:, params: {})
|
36
47
|
post API_METHODS[:appointment_hold], build_params({
|
37
48
|
LocationID: location_id,
|
38
49
|
ItineraryTimeSlot: {
|
39
50
|
TreatmentTimeSlots: [available_time]
|
40
51
|
},
|
41
52
|
Customer: customer
|
42
|
-
},
|
53
|
+
}, params)
|
43
54
|
end
|
44
55
|
|
45
56
|
def delete_appointment_hold(location_id:, incomplete_appointment_id:)
|
@@ -49,11 +60,11 @@ module Booker
|
|
49
60
|
})
|
50
61
|
end
|
51
62
|
|
52
|
-
def employees(location_id:, fetch_all: true,
|
63
|
+
def employees(location_id:, fetch_all: true, params: {})
|
53
64
|
paginated_request(
|
54
65
|
method: :post,
|
55
66
|
path: API_METHODS[:employees],
|
56
|
-
params: build_params({LocationID: location_id},
|
67
|
+
params: build_params({LocationID: location_id}, params, true),
|
57
68
|
model: Booker::V4::Models::Employee,
|
58
69
|
fetch_all: fetch_all
|
59
70
|
)
|
@@ -64,11 +75,11 @@ module Booker
|
|
64
75
|
Booker::V4::Models::Location.from_hash(response)
|
65
76
|
end
|
66
77
|
|
67
|
-
def locations(
|
78
|
+
def locations(params: {})
|
68
79
|
paginated_request(
|
69
80
|
method: :post,
|
70
81
|
path: API_METHODS[:locations],
|
71
|
-
params: build_params({},
|
82
|
+
params: build_params({}, params, true),
|
72
83
|
model: Booker::V4::Models::Location
|
73
84
|
)
|
74
85
|
end
|
data/lib/booker/v4.1/merchant.rb
CHANGED
@@ -3,13 +3,91 @@ module Booker
|
|
3
3
|
class Merchant < Booker::Client
|
4
4
|
include Booker::V4::RequestHelper
|
5
5
|
|
6
|
+
V41_PREFIX = '/v4.1/merchant'
|
7
|
+
V41_LOCATION_PREFIX = "#{V41_PREFIX}/location"
|
8
|
+
V41_APPOINTMENTS_PREFIX = "#{V41_PREFIX}/appointments"
|
6
9
|
API_METHODS = {
|
7
|
-
appointments:
|
8
|
-
|
9
|
-
|
10
|
+
appointments: "#{V41_APPOINTMENTS_PREFIX}".freeze,
|
11
|
+
appointments_partial: "#{V41_APPOINTMENTS_PREFIX}/partial".freeze,
|
12
|
+
appointment_confirm: "#{V41_PREFIX}/appointment/confirm".freeze,
|
13
|
+
customers: "#{V41_PREFIX}/customers".freeze,
|
14
|
+
create_special: "#{V41_PREFIX}/special".freeze,
|
15
|
+
employees: "#{V41_PREFIX}/employees".freeze,
|
16
|
+
treatments: "#{V41_PREFIX}/treatments".freeze,
|
10
17
|
}.freeze
|
11
18
|
|
12
|
-
def
|
19
|
+
def online_booking_settings(location_id:)
|
20
|
+
path = "#{V41_LOCATION_PREFIX}/#{location_id}/online_booking_settings"
|
21
|
+
response = get path, build_params
|
22
|
+
Booker::V4::Models::OnlineBookingSettings.from_hash(response['OnlineBookingSettings'])
|
23
|
+
end
|
24
|
+
|
25
|
+
def location_feature_settings(location_id:)
|
26
|
+
response = get "#{V41_LOCATION_PREFIX}/#{location_id}/feature_settings", build_params
|
27
|
+
Booker::V4::Models::FeatureSettings.from_hash response['FeatureSettings']
|
28
|
+
end
|
29
|
+
|
30
|
+
def location_day_schedules(location_id:, params: {})
|
31
|
+
# Booker requires fromDate and toDate for JSON API, but does not use them when getDefaultDaySchedule is true
|
32
|
+
# So datetime used for these fields does not matter
|
33
|
+
random_datetime = Booker::V4::Models::Model.time_to_booker_datetime(Time.now)
|
34
|
+
|
35
|
+
additional_params = {getDefaultDaySchedule: true, fromDate: random_datetime, toDate: random_datetime}
|
36
|
+
response = get("#{V41_LOCATION_PREFIX}/#{location_id}/schedule", build_params(additional_params, params))
|
37
|
+
response['LocationDaySchedules'].map { |sched| Booker::V4::Models::LocationDaySchedule.from_hash(sched) }
|
38
|
+
end
|
39
|
+
|
40
|
+
def update_location_notification_settings(location_id:, send_appointment_reminders:)
|
41
|
+
params = build_params({NotificationSettings: { SendAppointmentReminders: send_appointment_reminders } })
|
42
|
+
put "#{V41_LOCATION_PREFIX}/#{location_id}/notification_settings", params
|
43
|
+
end
|
44
|
+
|
45
|
+
def confirm_appointment(appointment_id:)
|
46
|
+
put API_METHODS[:appointment_confirm], build_params(ID: appointment_id), Booker::V4::Models::Appointment
|
47
|
+
end
|
48
|
+
|
49
|
+
def appointments_partial(location_id:, start_date:, end_date:, fetch_all: true, params: {})
|
50
|
+
additional_params = {
|
51
|
+
LocationID: location_id,
|
52
|
+
FromStartDate: start_date.to_date,
|
53
|
+
ToStartDate: end_date.to_date
|
54
|
+
}
|
55
|
+
|
56
|
+
paginated_request(
|
57
|
+
method: :post,
|
58
|
+
path: API_METHODS[:appointments_partial],
|
59
|
+
params: build_params(additional_params, params, true),
|
60
|
+
model: Booker::V4::Models::Appointment,
|
61
|
+
fetch_all: fetch_all
|
62
|
+
)
|
63
|
+
end
|
64
|
+
|
65
|
+
def employees(location_id:, fetch_all: true, params: {})
|
66
|
+
paginated_request(
|
67
|
+
method: :post,
|
68
|
+
path: API_METHODS[:employees],
|
69
|
+
params: build_params({LocationID: location_id}, params, true),
|
70
|
+
model: Booker::V4::Models::Employee,
|
71
|
+
fetch_all: fetch_all
|
72
|
+
)
|
73
|
+
end
|
74
|
+
|
75
|
+
def treatments(location_id:, fetch_all: true, params: {})
|
76
|
+
paginated_request(
|
77
|
+
method: :post,
|
78
|
+
path: API_METHODS[:treatments],
|
79
|
+
params: build_params({ LocationID: location_id }, params, true),
|
80
|
+
model: Booker::V4::Models::Treatment,
|
81
|
+
fetch_all: fetch_all
|
82
|
+
)
|
83
|
+
end
|
84
|
+
|
85
|
+
def location(id:)
|
86
|
+
response = get("#{V41_LOCATION_PREFIX}/#{id}", build_params)
|
87
|
+
Booker::V4::Models::Location.from_hash(response)
|
88
|
+
end
|
89
|
+
|
90
|
+
def appointments(location_id:, start_date:, end_date:, fetch_all: true, params: {})
|
13
91
|
additional_params = {
|
14
92
|
LocationID: location_id,
|
15
93
|
FromStartDate: start_date.to_date,
|
@@ -19,13 +97,13 @@ module Booker
|
|
19
97
|
paginated_request(
|
20
98
|
method: :post,
|
21
99
|
path: API_METHODS[:appointments],
|
22
|
-
params: build_params(additional_params,
|
100
|
+
params: build_params(additional_params, params, true),
|
23
101
|
model: Booker::V4::Models::Appointment,
|
24
102
|
fetch_all: fetch_all
|
25
103
|
)
|
26
104
|
end
|
27
105
|
|
28
|
-
def customers(location_id:, fetch_all: true,
|
106
|
+
def customers(location_id:, fetch_all: true, params: {})
|
29
107
|
additional_params = {
|
30
108
|
FilterByExactLocationID: true,
|
31
109
|
LocationID: location_id,
|
@@ -35,20 +113,20 @@ module Booker
|
|
35
113
|
paginated_request(
|
36
114
|
method: :post,
|
37
115
|
path: API_METHODS[:customers],
|
38
|
-
params: build_params(additional_params,
|
116
|
+
params: build_params(additional_params, params, true),
|
39
117
|
model: Booker::V4::Models::Customer,
|
40
118
|
fetch_all: fetch_all
|
41
119
|
)
|
42
120
|
end
|
43
121
|
|
44
|
-
def create_special(location_id:, start_date:, end_date:, coupon_code:, name:,
|
122
|
+
def create_special(location_id:, start_date:, end_date:, coupon_code:, name:, params: {})
|
45
123
|
post(API_METHODS[:create_special], build_params({
|
46
124
|
LocationID: location_id,
|
47
125
|
ApplicableStartDate: start_date.in_time_zone,
|
48
126
|
ApplicableEndDate: end_date.in_time_zone,
|
49
127
|
CouponCode: coupon_code,
|
50
128
|
Name: name
|
51
|
-
},
|
129
|
+
}, params))
|
52
130
|
end
|
53
131
|
end
|
54
132
|
end
|
@@ -9,7 +9,7 @@ module Booker
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def confirm_appointment(appointment_id:)
|
12
|
-
put '/appointment/confirm', build_params(:
|
12
|
+
put '/appointment/confirm', build_params(ID: appointment_id), Booker::V4::Models::Appointment
|
13
13
|
end
|
14
14
|
|
15
15
|
def get_location(booker_location_id:)
|
@@ -8,7 +8,7 @@ module Booker
|
|
8
8
|
thirty_day_availability: '/v5/availability/30day'.freeze
|
9
9
|
}.freeze
|
10
10
|
|
11
|
-
def
|
11
|
+
def search(location_ids:, from_date_time:, to_date_time:, include_employees: true)
|
12
12
|
get API_METHODS[:availability], {
|
13
13
|
locationIds: location_ids,
|
14
14
|
fromDateTime: from_date_time,
|
@@ -17,7 +17,7 @@ module Booker
|
|
17
17
|
}, Booker::V5::Models::AvailabilityResult
|
18
18
|
end
|
19
19
|
|
20
|
-
def
|
20
|
+
def one_day(location_id:, from_date_time:, include_employees: true)
|
21
21
|
get API_METHODS[:one_day_availability], {
|
22
22
|
locationId: location_id,
|
23
23
|
fromDateTime: from_date_time,
|
@@ -25,7 +25,7 @@ module Booker
|
|
25
25
|
}, Booker::V5::Models::AvailabilityResult
|
26
26
|
end
|
27
27
|
|
28
|
-
def
|
28
|
+
def two_day(location_id:, from_date_time:, include_employees: true)
|
29
29
|
get API_METHODS[:two_day_availability], {
|
30
30
|
locationId: location_id,
|
31
31
|
fromDateTime: from_date_time,
|
@@ -33,7 +33,7 @@ module Booker
|
|
33
33
|
}, Booker::V5::Models::AvailabilityResult
|
34
34
|
end
|
35
35
|
|
36
|
-
def
|
36
|
+
def thirty_day(location_id:, from_date_time:, include_employees: true)
|
37
37
|
get API_METHODS[:thirty_day_availability], {
|
38
38
|
locationId: location_id,
|
39
39
|
fromDateTime: from_date_time,
|
data/lib/booker/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: booker_ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 3.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Frederick
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-04-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|