class Booker::V41::Merchant
Constants
- API_METHODS
- V41_APPOINTMENTS_PREFIX
- V41_LOCATION_PREFIX
- V41_PREFIX
Public Instance Methods
appointments(location_id:, start_date:, end_date:, fetch_all: true, params: {})
click to toggle source
# File lib/booker/v4.1/merchant.rb, line 94 def appointments(location_id:, start_date:, end_date:, fetch_all: true, params: {}) additional_params = { LocationID: location_id, FromStartDate: start_date.to_date, ToStartDate: end_date.to_date } paginated_request( method: :post, path: API_METHODS[:appointments], params: build_params(additional_params, params, true), model: Booker::V4::Models::Appointment, fetch_all: fetch_all ) end
appointments_partial(location_id:, start_date:, end_date:, fetch_all: true, params: {})
click to toggle source
# File lib/booker/v4.1/merchant.rb, line 49 def appointments_partial(location_id:, start_date:, end_date:, fetch_all: true, params: {}) additional_params = { LocationID: location_id, FromStartDate: start_date.to_date, ToStartDate: end_date.to_date } paginated_request( method: :post, path: API_METHODS[:appointments_partial], params: build_params(additional_params, params, true), model: Booker::V4::Models::Appointment, fetch_all: fetch_all ) end
confirm_appointment(appointment_id:)
click to toggle source
# File lib/booker/v4.1/merchant.rb, line 45 def confirm_appointment(appointment_id:) put API_METHODS[:appointment_confirm], build_params(ID: appointment_id), Booker::V4::Models::Appointment end
create_special(location_id:, start_date:, end_date:, coupon_code:, name:, params: {})
click to toggle source
# File lib/booker/v4.1/merchant.rb, line 152 def create_special(location_id:, start_date:, end_date:, coupon_code:, name:, params: {}) post(API_METHODS[:create_special], build_params({ LocationID: location_id, ApplicableStartDate: start_date.in_time_zone, ApplicableEndDate: end_date.in_time_zone, CouponCode: coupon_code, Name: name }, params)) end
customer(id:, params: {}, model: Booker::V4::Models::Customer)
click to toggle source
# File lib/booker/v4.1/merchant.rb, line 126 def customer(id:, params: {}, model: Booker::V4::Models::Customer) additional_params = { LoadUnpaidAppointments: false, includeFieldValues: false } get("#{V41_PREFIX}/customer/#{id}", build_params(additional_params, params), model) end
customers(location_id:, fetch_all: true, params: {})
click to toggle source
# File lib/booker/v4.1/merchant.rb, line 110 def customers(location_id:, fetch_all: true, params: {}) additional_params = { FilterByExactLocationID: true, LocationID: location_id, CustomerRecordType: 1, } paginated_request( method: :post, path: API_METHODS[:customers], params: build_params(additional_params, params, true), model: Booker::V4::Models::Customer, fetch_all: fetch_all ) end
employee(id:, params: {}, model: Booker::V4::Models::Employee)
click to toggle source
# File lib/booker/v4.1/merchant.rb, line 65 def employee(id:, params: {}, model: Booker::V4::Models::Employee) get("#{V41_PREFIX}/employee/#{id}", build_params({}, params), model) end
employees(location_id:, fetch_all: true, params: {})
click to toggle source
# File lib/booker/v4.1/merchant.rb, line 69 def employees(location_id:, fetch_all: true, params: {}) paginated_request( method: :post, path: API_METHODS[:employees], params: build_params({LocationID: location_id}, params, true), model: Booker::V4::Models::Employee, fetch_all: fetch_all ) end
extract_default_customer_fields(customer_attributes)
click to toggle source
# File lib/booker/v4.1/merchant.rb, line 148 def extract_default_customer_fields(customer_attributes) customer_attributes.slice("Email", "FirstName", "LastName", "HomePhone", "WorkPhone", "CellPhone") end
location(id:)
click to toggle source
# File lib/booker/v4.1/merchant.rb, line 89 def location(id:) response = get("#{V41_LOCATION_PREFIX}/#{id}", build_params) Booker::V4::Models::Location.from_hash(response) end
location_day_schedules(location_id:, params: {})
click to toggle source
# File lib/booker/v4.1/merchant.rb, line 30 def location_day_schedules(location_id:, params: {}) # Booker requires fromDate and toDate for JSON API, but does not use them when getDefaultDaySchedule is true # So datetime used for these fields does not matter random_datetime = Booker::V4::Models::Model.time_to_booker_datetime(Time.now) additional_params = {getDefaultDaySchedule: true, fromDate: random_datetime, toDate: random_datetime} response = get("#{V41_LOCATION_PREFIX}/#{location_id}/schedule", build_params(additional_params, params)) response['LocationDaySchedules'].map { |sched| Booker::V4::Models::LocationDaySchedule.from_hash(sched) } end
location_feature_settings(location_id:)
click to toggle source
# File lib/booker/v4.1/merchant.rb, line 25 def location_feature_settings(location_id:) response = get "#{V41_LOCATION_PREFIX}/#{location_id}/feature_settings", build_params Booker::V4::Models::FeatureSettings.from_hash response['FeatureSettings'] end
online_booking_settings(location_id:)
click to toggle source
# File lib/booker/v4.1/merchant.rb, line 19 def online_booking_settings(location_id:) path = "#{V41_LOCATION_PREFIX}/#{location_id}/online_booking_settings" response = get path, build_params Booker::V4::Models::OnlineBookingSettings.from_hash(response['OnlineBookingSettings']) end
treatments(location_id:, fetch_all: true, params: {})
click to toggle source
# File lib/booker/v4.1/merchant.rb, line 79 def treatments(location_id:, fetch_all: true, params: {}) paginated_request( method: :post, path: API_METHODS[:treatments], params: build_params({ LocationID: location_id }, params, true), model: Booker::V4::Models::Treatment, fetch_all: fetch_all ) end
update_customer(id:, update_params: {})
click to toggle source
# File lib/booker/v4.1/merchant.rb, line 134 def update_customer(id:, update_params: {}) # get a raw json response because we need to send all fields back with modifications customer_response = customer(id: id, model: nil) if customer_response.present? && customer = customer_response["Customer"] # extract the minimum required fields to send back customer["Customer"] = extract_default_customer_fields(customer["Customer"]) customer["Customer"].merge!(update_params) customer["LocationID"] = self.location_id put("#{V41_PREFIX}/customer/#{id}", build_params(customer)) end end
update_location_notification_settings(location_id:, send_appointment_reminders:)
click to toggle source
# File lib/booker/v4.1/merchant.rb, line 40 def update_location_notification_settings(location_id:, send_appointment_reminders:) params = build_params({NotificationSettings: { SendAppointmentReminders: send_appointment_reminders } }) put "#{V41_LOCATION_PREFIX}/#{location_id}/notification_settings", params end