Allow API clients to filter appointments by service, provider and customer ID (#1296, #1325)

This commit is contained in:
Alex Tselegidis 2023-01-14 10:25:25 +01:00
parent dfacdc901a
commit 50ec06b29c
2 changed files with 41 additions and 2 deletions

View file

@ -87,6 +87,33 @@ class Appointments_api_v1 extends EA_Controller {
$where['DATE(end_datetime) <='] = (new DateTime($till))->format('Y-m-d');
}
// Service ID query param.
$service_id = request('serviceId');
if ( ! empty($service_id))
{
$where['id_services'] = $service_id;
}
// Provider ID query param.
$provider_id = request('providerId');
if ( ! empty($provider_id))
{
$where['id_users_provider'] = $provider_id;
}
// Customer ID query param.
$customer_id = request('customerId');
if ( ! empty($customer_id))
{
$where['id_users_customer'] = $customer_id;
}
$appointments = empty($keyword)
? $this->appointments_model->get($where, $limit, $offset, $order_by)
: $this->appointments_model->search($keyword, $limit, $offset, $order_by);

View file

@ -104,14 +104,26 @@ paths:
in: query
schema:
type: string
- name: start
- name: from
in: query
schema:
type: string
- name: end
- name: till
in: query
schema:
type: string
- name: serviceId
in: query
schema:
type: integer
- name: providerId
in: query
schema:
type: integer
- name: customerId
in: query
schema:
type: integer
responses:
'200':
description: OK