Module: Booker::V4::BusinessREST
Constant Summary
RequestHelper::DEFAULT_PAGINATION_PARAMS
Instance Method Summary
collapse
-
#create_special(booker_location_id:, start_date:, end_date:, coupon_code:, name:, params: {}) ⇒ Object
-
#find_appointments_partial(booker_location_id:, start_date:, end_date:, fetch_all: true, params: {}) ⇒ Object
-
#find_customers(booker_location_id:, fetch_all: true, params: {}) ⇒ Object
-
#find_employees(booker_location_id:, fetch_all: true, params: {}) ⇒ Object
-
#find_locations(params: {}) ⇒ Object
-
#find_orders(booker_location_id:, fetch_all: true, params: {}) ⇒ Object
-
#find_orders_partial(booker_location_id:, fetch_all: true, params: {}) ⇒ Object
-
#find_treatments(booker_location_id:, fetch_all: true, params: {}) ⇒ Object
-
#get_customer(id:, params: {}) ⇒ Object
-
#get_location_day_schedules(booker_location_id:, params: {}) ⇒ Object
-
#get_location_feature_settings(booker_location_id:) ⇒ Object
-
#get_location_notification_settings(booker_location_id:) ⇒ Object
-
#get_logged_in_user ⇒ Object
-
#update_location_notification_settings(booker_location_id:, send_appointment_reminders:) ⇒ Object
#build_params
Methods included from CommonREST
#confirm_appointment, #get_location, #get_online_booking_settings
Instance Method Details
#create_special(booker_location_id:, start_date:, end_date:, coupon_code:, name:, params: {}) ⇒ Object
114
115
116
117
118
119
120
121
122
|
# File 'lib/booker/v4/business_rest.rb', line 114
def create_special(booker_location_id:, start_date:, end_date:, coupon_code:, name:, params: {})
post('/special', build_params({
'LocationID' => booker_location_id,
'ApplicableStartDate' => start_date.in_time_zone,
'ApplicableEndDate' => end_date.in_time_zone,
'CouponCode' => coupon_code,
'Name' => name
}, params))
end
|
#find_appointments_partial(booker_location_id:, start_date:, end_date:, fetch_all: true, params: {}) ⇒ Object
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
|
# File 'lib/booker/v4/business_rest.rb', line 98
def find_appointments_partial(booker_location_id:, start_date:, end_date:, fetch_all: true, params: {})
additional_params = {
LocationID: booker_location_id,
FromStartDate: start_date.to_date,
ToStartDate: end_date.to_date
}
paginated_request(
method: :post,
path: '/appointments/partial',
params: build_params(additional_params, params, true),
model: Booker::V4::Models::Appointment,
fetch_all: fetch_all
)
end
|
#find_customers(booker_location_id:, fetch_all: true, params: {}) ⇒ Object
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
# File 'lib/booker/v4/business_rest.rb', line 74
def find_customers(booker_location_id:, fetch_all: true, params: {})
additional_params = {
'FilterByExactLocationID' => true,
'LocationID' => booker_location_id,
'CustomerRecordType' => 1,
}
paginated_request(
method: :post,
path: '/customers',
params: build_params(additional_params, params, true),
model: Booker::V4::Models::Customer,
fetch_all: fetch_all
)
end
|
#find_employees(booker_location_id:, fetch_all: true, params: {}) ⇒ Object
34
35
36
37
38
39
40
41
42
|
# File 'lib/booker/v4/business_rest.rb', line 34
def find_employees(booker_location_id:, fetch_all: true, params: {})
paginated_request(
method: :post,
path: '/employees',
params: build_params({LocationID: booker_location_id}, params, true),
model: Booker::V4::Models::Employee,
fetch_all: fetch_all
)
end
|
#find_locations(params: {}) ⇒ Object
25
26
27
28
29
30
31
32
|
# File 'lib/booker/v4/business_rest.rb', line 25
def find_locations(params: {})
paginated_request(
method: :post,
path: '/locations',
params: build_params({}, params, true),
model: Booker::V4::Models::Location
)
end
|
#find_orders(booker_location_id:, fetch_all: true, params: {}) ⇒ Object
44
45
46
47
48
49
50
51
52
|
# File 'lib/booker/v4/business_rest.rb', line 44
def find_orders(booker_location_id:, fetch_all: true, params: {})
paginated_request(
method: :post,
path: '/orders',
params: build_params({LocationID: booker_location_id}, params, true),
model: Booker::V4::Models::Order,
fetch_all: fetch_all
)
end
|
#find_orders_partial(booker_location_id:, fetch_all: true, params: {}) ⇒ Object
54
55
56
57
58
59
60
61
62
|
# File 'lib/booker/v4/business_rest.rb', line 54
def find_orders_partial(booker_location_id:, fetch_all: true, params: {})
paginated_request(
method: :post,
path: '/orders/partial',
params: build_params({LocationID: booker_location_id}, params, true),
model: Booker::V4::Models::Order,
fetch_all: fetch_all
)
end
|
#find_treatments(booker_location_id:, fetch_all: true, params: {}) ⇒ Object
64
65
66
67
68
69
70
71
72
|
# File 'lib/booker/v4/business_rest.rb', line 64
def find_treatments(booker_location_id:, fetch_all: true, params: {})
paginated_request(
method: :post,
path: '/treatments',
params: build_params({LocationID: booker_location_id}, params, true),
model: Booker::V4::Models::Treatment,
fetch_all: fetch_all
)
end
|
#get_customer(id:, params: {}) ⇒ Object
90
91
92
93
94
95
96
|
# File 'lib/booker/v4/business_rest.rb', line 90
def get_customer(id:, params: {})
additional_params = {
LoadUnpaidAppointments: false,
includeFieldValues: false
}
get("/customer/#{id}", build_params(additional_params, params), Booker::V4::Models::Customer)
end
|
#get_location_day_schedules(booker_location_id:, params: {}) ⇒ Object
15
16
17
18
19
20
21
22
23
|
# File 'lib/booker/v4/business_rest.rb', line 15
def get_location_day_schedules(booker_location_id:, params: {})
random_datetime = Booker::V4::Models::Model.time_to_booker_datetime(Time.now)
additional_params = {getDefaultDaySchedule: true, fromDate: random_datetime, toDate: random_datetime}
response = get("/location/#{booker_location_id}/schedule", build_params(additional_params, params))
response['LocationDaySchedules'].map { |sched| Booker::V4::Models::LocationDaySchedule.from_hash(sched) }
end
|
#get_location_feature_settings(booker_location_id:) ⇒ Object
137
138
139
140
|
# File 'lib/booker/v4/business_rest.rb', line 137
def get_location_feature_settings(booker_location_id:)
response = get "/location/#{booker_location_id}/feature_settings", build_params
Booker::V4::Models::FeatureSettings.from_hash response['FeatureSettings']
end
|
#get_location_notification_settings(booker_location_id:) ⇒ Object
124
125
126
127
|
# File 'lib/booker/v4/business_rest.rb', line 124
def get_location_notification_settings(booker_location_id:)
response = get "/location/#{booker_location_id}/notification_settings", build_params
Booker::V4::Models::NotificationSettings.from_hash response['NotificationSettings']
end
|
#get_logged_in_user ⇒ Object
7
8
9
10
11
12
13
|
# File 'lib/booker/v4/business_rest.rb', line 7
def get_logged_in_user
response = get('/user', build_params)
result = Booker::V4::Models::User.from_hash(response['User'])
result.LocationID = response['LocationID']
result.BrandID = response['BrandID']
result
end
|
#update_location_notification_settings(booker_location_id:, send_appointment_reminders:) ⇒ Object
129
130
131
132
133
134
135
|
# File 'lib/booker/v4/business_rest.rb', line 129
def update_location_notification_settings(booker_location_id:, send_appointment_reminders:)
put "/location/#{booker_location_id}/notification_settings", build_params({
NotificationSettings: {
SendAppointmentReminders: send_appointment_reminders
}
})
end
|