booker_ruby 3.0.8 → 3.0.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/booker/v4/business_client.rb +9 -0
- data/lib/booker/v4/business_rest.rb +114 -0
- data/lib/booker/v4/common_rest.rb +21 -0
- data/lib/booker/v4/customer_client.rb +15 -0
- data/lib/booker/v4/customer_rest.rb +25 -0
- data/lib/booker/version.rb +1 -1
- data/lib/booker_ruby.rb +5 -0
- metadata +7 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 38393c1d2fad9767032e92fbe975ba26348c3776
|
4
|
+
data.tar.gz: 7115c50c535d3b55135965a23abef98dfd5c9b04
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 306452b34395be407432e7f08afb8bcac27408b649631a68c62cd6519f2d4f8bbf25e55b5c4f3e298490e9a8b1ad70759d0c67ca74b2eb84587bc08f3d4a7300
|
7
|
+
data.tar.gz: 00d34f8671b14f7b36b59b4450b95bcec104082fc0cd82353699c92fc51350e61d657c1e603c49142b8d8f273430237aec7d5db8fa59313c777debddd347bc84
|
@@ -0,0 +1,9 @@
|
|
1
|
+
module Booker
|
2
|
+
module V4
|
3
|
+
class BusinessClient < Booker::Client
|
4
|
+
include Booker::V4::BusinessREST
|
5
|
+
ENV_BASE_URL_KEY = 'BOOKER_BUSINESS_SERVICE_URL'.freeze
|
6
|
+
DEFAULT_BASE_URL = 'https://apicurrent-app.booker.ninja/webservice4/json/BusinessService.svc'.freeze
|
7
|
+
end
|
8
|
+
end
|
9
|
+
end
|
@@ -0,0 +1,114 @@
|
|
1
|
+
module Booker
|
2
|
+
module V4
|
3
|
+
module BusinessREST
|
4
|
+
include Booker::V4::CommonREST
|
5
|
+
|
6
|
+
def get_logged_in_user
|
7
|
+
response = get('/user', build_params)
|
8
|
+
result = Booker::V4::Models::User.from_hash(response['User'])
|
9
|
+
result.LocationID = response['LocationID']
|
10
|
+
result.BrandID = response['BrandID']
|
11
|
+
result
|
12
|
+
end
|
13
|
+
|
14
|
+
def get_location_day_schedules(booker_location_id:, params: {})
|
15
|
+
# Booker requires fromDate and toDate for JSON API, but does not use them when getDefaultDaySchedule is true
|
16
|
+
# So datetime used for these fields does not matter
|
17
|
+
random_datetime = Booker::V4::Models::Model.time_to_booker_datetime(Time.now)
|
18
|
+
|
19
|
+
additional_params = {getDefaultDaySchedule: true, fromDate: random_datetime, toDate: random_datetime}
|
20
|
+
response = get("/location/#{booker_location_id}/schedule", build_params(additional_params, params))
|
21
|
+
response['LocationDaySchedules'].map { |sched| Booker::V4::Models::LocationDaySchedule.from_hash(sched) }
|
22
|
+
end
|
23
|
+
|
24
|
+
def find_locations(options: {})
|
25
|
+
paginated_request(
|
26
|
+
method: :post,
|
27
|
+
path: '/locations',
|
28
|
+
params: build_params({}, options, true),
|
29
|
+
model: Booker::V4::Models::Location
|
30
|
+
)
|
31
|
+
end
|
32
|
+
|
33
|
+
def find_employees(booker_location_id:, fetch_all: true, options: {})
|
34
|
+
paginated_request(
|
35
|
+
method: :post,
|
36
|
+
path: '/employees',
|
37
|
+
params: build_params({LocationID: booker_location_id}, options, true),
|
38
|
+
model: Booker::V4::Models::Employee,
|
39
|
+
fetch_all: fetch_all
|
40
|
+
)
|
41
|
+
end
|
42
|
+
|
43
|
+
def find_treatments(booker_location_id:, fetch_all: true, options: {})
|
44
|
+
paginated_request(
|
45
|
+
method: :post,
|
46
|
+
path: '/treatments',
|
47
|
+
params: build_params({LocationID: booker_location_id}, options, true),
|
48
|
+
model: Booker::V4::Models::Treatment,
|
49
|
+
fetch_all: fetch_all
|
50
|
+
)
|
51
|
+
end
|
52
|
+
|
53
|
+
def find_customers(booker_location_id:, fetch_all: true, params: {})
|
54
|
+
additional_params = {
|
55
|
+
'FilterByExactLocationID' => true,
|
56
|
+
'LocationID' => booker_location_id,
|
57
|
+
'CustomerRecordType' => 1,
|
58
|
+
}
|
59
|
+
|
60
|
+
paginated_request(
|
61
|
+
method: :post,
|
62
|
+
path: '/customers',
|
63
|
+
params: build_params(additional_params, params, true),
|
64
|
+
model: Booker::V4::Models::Customer,
|
65
|
+
fetch_all: fetch_all
|
66
|
+
)
|
67
|
+
end
|
68
|
+
|
69
|
+
def find_appointments_partial(booker_location_id:, start_date:, end_date:, fetch_all: true, options: {})
|
70
|
+
additional_params = {
|
71
|
+
LocationID: booker_location_id,
|
72
|
+
FromStartDate: start_date.to_date,
|
73
|
+
ToStartDate: end_date.to_date
|
74
|
+
}
|
75
|
+
|
76
|
+
paginated_request(
|
77
|
+
method: :post,
|
78
|
+
path: '/appointments/partial',
|
79
|
+
params: build_params(additional_params, options, true),
|
80
|
+
model: Booker::V4::Models::Appointment,
|
81
|
+
fetch_all: fetch_all
|
82
|
+
)
|
83
|
+
end
|
84
|
+
|
85
|
+
def create_special(booker_location_id:, start_date:, end_date:, coupon_code:, name:, params: {})
|
86
|
+
post('/special', build_params({
|
87
|
+
'LocationID' => booker_location_id,
|
88
|
+
'ApplicableStartDate' => start_date.in_time_zone,
|
89
|
+
'ApplicableEndDate' => end_date.in_time_zone,
|
90
|
+
'CouponCode' => coupon_code,
|
91
|
+
'Name' => name
|
92
|
+
}, params))
|
93
|
+
end
|
94
|
+
|
95
|
+
def get_location_notification_settings(booker_location_id:)
|
96
|
+
response = get "/location/#{booker_location_id}/notification_settings", build_params
|
97
|
+
Booker::V4::Models::NotificationSettings.from_hash response['NotificationSettings']
|
98
|
+
end
|
99
|
+
|
100
|
+
def update_location_notification_settings(booker_location_id:, send_appointment_reminders:)
|
101
|
+
put "/location/#{booker_location_id}/notification_settings", build_params({
|
102
|
+
NotificationSettings: {
|
103
|
+
SendAppointmentReminders: send_appointment_reminders
|
104
|
+
}
|
105
|
+
})
|
106
|
+
end
|
107
|
+
|
108
|
+
def get_location_feature_settings(booker_location_id:)
|
109
|
+
response = get "/location/#{booker_location_id}/feature_settings", build_params
|
110
|
+
Booker::V4::Models::FeatureSettings.from_hash response['FeatureSettings']
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Booker
|
2
|
+
module V4
|
3
|
+
module CommonREST
|
4
|
+
include Booker::V4::RequestHelper
|
5
|
+
|
6
|
+
def get_online_booking_settings(booker_location_id:)
|
7
|
+
response = get("/location/#{booker_location_id}/online_booking_settings", build_params)
|
8
|
+
Booker::V4::Models::OnlineBookingSettings.from_hash(response['OnlineBookingSettings'])
|
9
|
+
end
|
10
|
+
|
11
|
+
def confirm_appointment(appointment_id:)
|
12
|
+
put '/appointment/confirm', build_params(ID: appointment_id), Booker::V4::Models::Appointment
|
13
|
+
end
|
14
|
+
|
15
|
+
def get_location(booker_location_id:)
|
16
|
+
response = get("/location/#{booker_location_id}", build_params)
|
17
|
+
Booker::V4::Models::Location.from_hash(response)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Booker
|
2
|
+
module V4
|
3
|
+
class CustomerClient < Client
|
4
|
+
include Booker::V4::CustomerREST
|
5
|
+
ENV_BASE_URL_KEY = 'BOOKER_CUSTOMER_SERVICE_URL'.freeze
|
6
|
+
DEFAULT_BASE_URL = 'https://apicurrent-app.booker.ninja/webservice4/json/CustomerService.svc'.freeze
|
7
|
+
|
8
|
+
def initialize(options={})
|
9
|
+
super
|
10
|
+
self.token_store ||= GenericTokenStore
|
11
|
+
self.token_store_callback_method ||= :update_booker_access_token!
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Booker
|
2
|
+
module V4
|
3
|
+
module CustomerREST
|
4
|
+
include Booker::V4::CommonREST
|
5
|
+
|
6
|
+
def create_appointment(booker_location_id:, available_time:, customer:, options: {})
|
7
|
+
post '/appointment/create', build_params({
|
8
|
+
'LocationID' => booker_location_id,
|
9
|
+
'ItineraryTimeSlotList' => [
|
10
|
+
'TreatmentTimeSlots' => [available_time]
|
11
|
+
],
|
12
|
+
'Customer' => customer
|
13
|
+
}, options), Booker::V4::Models::Appointment
|
14
|
+
end
|
15
|
+
|
16
|
+
def create_class_appointment(booker_location_id:, class_instance_id:, customer:, options: {})
|
17
|
+
post '/class_appointment/create', build_params({
|
18
|
+
LocationID: booker_location_id,
|
19
|
+
ClassInstanceID: class_instance_id,
|
20
|
+
Customer: customer
|
21
|
+
}, options), Booker::V4::Models::Appointment
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
data/lib/booker/version.rb
CHANGED
data/lib/booker_ruby.rb
CHANGED
@@ -95,11 +95,16 @@ require 'booker/client'
|
|
95
95
|
|
96
96
|
# V4 Rest
|
97
97
|
require 'booker/v4/request_helper'
|
98
|
+
require 'booker/v4/common_rest'
|
99
|
+
require 'booker/v4/business_rest'
|
100
|
+
require 'booker/v4/customer_rest'
|
98
101
|
|
99
102
|
# Token Store
|
100
103
|
require 'booker/generic_token_store'
|
101
104
|
|
102
105
|
# Client Subclasses
|
106
|
+
require 'booker/v4/business_client'
|
107
|
+
require 'booker/v4/customer_client'
|
103
108
|
require 'booker/v4.1/customer'
|
104
109
|
require 'booker/v4.1/merchant'
|
105
110
|
require 'booker/v5/availability'
|
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: 3.0.
|
4
|
+
version: 3.0.9
|
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-07-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|
@@ -153,6 +153,11 @@ files:
|
|
153
153
|
- lib/booker/model.rb
|
154
154
|
- lib/booker/v4.1/customer.rb
|
155
155
|
- lib/booker/v4.1/merchant.rb
|
156
|
+
- lib/booker/v4/business_client.rb
|
157
|
+
- lib/booker/v4/business_rest.rb
|
158
|
+
- lib/booker/v4/common_rest.rb
|
159
|
+
- lib/booker/v4/customer_client.rb
|
160
|
+
- lib/booker/v4/customer_rest.rb
|
156
161
|
- lib/booker/v4/models/address.rb
|
157
162
|
- lib/booker/v4/models/appointment.rb
|
158
163
|
- lib/booker/v4/models/appointment_treatment.rb
|