diff --git a/CHANGELOG.md b/CHANGELOG.md index d764c92..40c0a13 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,14 @@ # Change Log All notable changes to this project will be documented in this file. +## [0.1.3] - 2017-06-18 ## +### Added +- [#34](https://github.com/gonebusy/gonebusy-php-client/pull/34) - Booking creation/update now accept optional :name and :description +- [#34](https://github.com/gonebusy/gonebusy-php-client/pull/34) - Booking item response now contains :name, :description, :external_link, :collaborative_link + +### Changed +- [#34](https://github.com/gonebusy/gonebusy-php-client/pull/34) - Booking :user_message has been replaced by separate :name and :description + ## [0.1.2] - 2017-06-14 ## ### Changed - [#33](https://github.com/gonebusy/gonebusy-php-client/pull/33) - Booking item response now includes :resource_id and :service_id corresponding to Resource providing the Booking and the Service being performed. diff --git a/src/Models/CreateBookingBody.php b/src/Models/CreateBookingBody.php index 66b05e9..1badb64 100644 --- a/src/Models/CreateBookingBody.php +++ b/src/Models/CreateBookingBody.php @@ -14,13 +14,6 @@ */ class CreateBookingBody implements JsonSerializable { - /** - * Desired date of booking. Several formats are supported: "2014-10-31", "October 31, 2014" - * @required - * @var string $date public property - */ - public $date; - /** * ID of Service being booked * @required @@ -29,6 +22,13 @@ class CreateBookingBody implements JsonSerializable */ public $serviceId; + /** + * Desired date of booking. Several formats are supported: "2014-10-31", "October 31, 2014" + * @required + * @var string $date public property + */ + public $date; + /** * Desired time of booking. Several formats are supported: '9am', '09:00', '9:00', '0900' * @required @@ -45,17 +45,11 @@ class CreateBookingBody implements JsonSerializable public $userId; /** - * Required only when :recurs_by is 'monthly' or 'yearly' to differentiate between exact date or 'day in month/year'. See Recurring Booking examples. - * @maps date_recurs_by - * @var string|null $dateRecursBy public property - */ - public $dateRecursBy; - - /** - * List of comma-separated days of the week this Booking falls on. Useful for recurring Bookings. If provided, at least one must be specified. - * @var string|null $days public property + * ID of a Resource to be booked. If not provided, the first available Resource will be booked. + * @maps resource_id + * @var integer|null $resourceId public property */ - public $days; + public $resourceId; /** * Length of time, in minutes, for the desired booking - if Service allows requesting a variable amount of time @@ -70,12 +64,25 @@ class CreateBookingBody implements JsonSerializable */ public $endDate; + /** + * One of the possible recurrence values. If not provided, assumed to be :once to indicate a single Booking. + * @maps recurs_by + * @var string|null $recursBy public property + */ + public $recursBy; + /** * Optional frequency of recurrence as specified by :recurs_by. E.g, :single, :every, :every_other, etc. If not provided, assumed to be :once * @var string|null $frequency public property */ public $frequency; + /** + * List of comma-separated days of the week this Booking falls on. Useful for recurring Bookings. If provided, at least one must be specified. + * @var string|null $days public property + */ + public $days; + /** * Optional occurrence of frequency. E.g, :first, :2nd, :last, :2nd_to_last, etc. If not provided, assumed to be :every * @var string|null $occurrence public property @@ -83,49 +90,58 @@ class CreateBookingBody implements JsonSerializable public $occurrence; /** - * One of the possible recurrence values. If not provided, assumed to be :once to indicate a single Booking. - * @maps recurs_by - * @var string|null $recursBy public property + * Required only when :recurs_by is 'monthly' or 'yearly' to differentiate between exact date or 'day in month/year'. See Recurring Booking examples. + * @maps date_recurs_by + * @var string|null $dateRecursBy public property */ - public $recursBy; + public $dateRecursBy; /** - * ID of a Resource to be booked. If not provided, the first available Resource will be booked. - * @maps resource_id - * @var integer|null $resourceId public property + * Optional name for Booking, otherwise will take name of Service. + * @var string|null $name public property */ - public $resourceId; + public $name; + + /** + * Optional description for Booking. + * @var string|null $description public property + */ + public $description; /** * Constructor to set initial or default values of member properties - * @param string $date Initialization value for $this->date * @param integer $serviceId Initialization value for $this->serviceId + * @param string $date Initialization value for $this->date * @param string $time Initialization value for $this->time * @param integer $userId Initialization value for $this->userId - * @param string $dateRecursBy Initialization value for $this->dateRecursBy - * @param string $days Initialization value for $this->days + * @param integer $resourceId Initialization value for $this->resourceId * @param integer $duration Initialization value for $this->duration * @param string $endDate Initialization value for $this->endDate + * @param string $recursBy Initialization value for $this->recursBy * @param string $frequency Initialization value for $this->frequency + * @param string $days Initialization value for $this->days * @param string $occurrence Initialization value for $this->occurrence - * @param string $recursBy Initialization value for $this->recursBy - * @param integer $resourceId Initialization value for $this->resourceId + * @param string $dateRecursBy Initialization value for $this->dateRecursBy + * @param string $name Initialization value for $this->name + * @param string $description Initialization value for $this->description */ public function __construct() { - if (12 == func_num_args()) { - $this->date = func_get_arg(0); - $this->serviceId = func_get_arg(1); + if (14 == func_num_args()) { + $this->serviceId = func_get_arg(0); + $this->date = func_get_arg(1); $this->time = func_get_arg(2); $this->userId = func_get_arg(3); - $this->dateRecursBy = func_get_arg(4); - $this->days = func_get_arg(5); - $this->duration = func_get_arg(6); - $this->endDate = func_get_arg(7); + $this->resourceId = func_get_arg(4); + $this->duration = func_get_arg(5); + $this->endDate = func_get_arg(6); + $this->recursBy = func_get_arg(7); $this->frequency = func_get_arg(8); - $this->occurrence = func_get_arg(9); - $this->recursBy = func_get_arg(10); - $this->resourceId = func_get_arg(11); + $this->days = func_get_arg(9); + $this->occurrence = func_get_arg(10); + $this->dateRecursBy = func_get_arg(11); + $this->name = func_get_arg(12); + $this->description = func_get_arg(13); } } @@ -136,18 +152,20 @@ public function __construct() public function jsonSerialize() { $json = array(); - $json['date'] = $this->date; $json['service_id'] = $this->serviceId; + $json['date'] = $this->date; $json['time'] = $this->time; $json['user_id'] = $this->userId; - $json['date_recurs_by'] = $this->dateRecursBy; - $json['days'] = $this->days; + $json['resource_id'] = $this->resourceId; $json['duration'] = $this->duration; $json['end_date'] = $this->endDate; + $json['recurs_by'] = $this->recursBy; $json['frequency'] = $this->frequency; + $json['days'] = $this->days; $json['occurrence'] = $this->occurrence; - $json['recurs_by'] = $this->recursBy; - $json['resource_id'] = $this->resourceId; + $json['date_recurs_by'] = $this->dateRecursBy; + $json['name'] = $this->name; + $json['description'] = $this->description; return $json; } diff --git a/src/Models/EntitiesBookingResponse.php b/src/Models/EntitiesBookingResponse.php index 602dbb5..eaa05df 100644 --- a/src/Models/EntitiesBookingResponse.php +++ b/src/Models/EntitiesBookingResponse.php @@ -35,11 +35,10 @@ class EntitiesBookingResponse implements JsonSerializable public $workflowState; /** - * user requesting Booking may include a message - * @maps user_message - * @var string|null $userMessage public property + * name of Booking, if any + * @var string|null $name public property */ - public $userMessage; + public $name; /** * TimeWindow corresponding to Booking @@ -62,26 +61,52 @@ class EntitiesBookingResponse implements JsonSerializable */ public $serviceId; + /** + * description for Booking, if any + * @var string|null $description public property + */ + public $description; + + /** + * external management link for Booking, if any + * @maps external_link + * @var string|null $externalLink public property + */ + public $externalLink; + + /** + * video chat or other link associated with Booking, if any + * @maps collaborative_link + * @var string|null $collaborativeLink public property + */ + public $collaborativeLink; + /** * Constructor to set initial or default values of member properties - * @param integer $id Initialization value for $this->id - * @param integer $ownerId Initialization value for $this->ownerId - * @param string $workflowState Initialization value for $this->workflowState - * @param string $userMessage Initialization value for $this->userMessage - * @param EntitiesTimeWindowResponse $timeWindow Initialization value for $this->timeWindow - * @param integer $resourceId Initialization value for $this->resourceId - * @param integer $serviceId Initialization value for $this->serviceId + * @param integer $id Initialization value for $this->id + * @param integer $ownerId Initialization value for $this->ownerId + * @param string $workflowState Initialization value for $this->workflowState + * @param string $name Initialization value for $this->name + * @param EntitiesTimeWindowResponse $timeWindow Initialization value for $this->timeWindow + * @param integer $resourceId Initialization value for $this->resourceId + * @param integer $serviceId Initialization value for $this->serviceId + * @param string $description Initialization value for $this->description + * @param string $externalLink Initialization value for $this->externalLink + * @param string $collaborativeLink Initialization value for $this->collaborativeLink */ public function __construct() { - if (7 == func_num_args()) { - $this->id = func_get_arg(0); - $this->ownerId = func_get_arg(1); - $this->workflowState = func_get_arg(2); - $this->userMessage = func_get_arg(3); - $this->timeWindow = func_get_arg(4); - $this->resourceId = func_get_arg(5); - $this->serviceId = func_get_arg(6); + if (10 == func_num_args()) { + $this->id = func_get_arg(0); + $this->ownerId = func_get_arg(1); + $this->workflowState = func_get_arg(2); + $this->name = func_get_arg(3); + $this->timeWindow = func_get_arg(4); + $this->resourceId = func_get_arg(5); + $this->serviceId = func_get_arg(6); + $this->description = func_get_arg(7); + $this->externalLink = func_get_arg(8); + $this->collaborativeLink = func_get_arg(9); } } @@ -92,13 +117,16 @@ public function __construct() public function jsonSerialize() { $json = array(); - $json['id'] = $this->id; - $json['owner_id'] = $this->ownerId; - $json['workflow_state'] = $this->workflowState; - $json['user_message'] = $this->userMessage; - $json['time_window'] = $this->timeWindow; - $json['resource_id'] = $this->resourceId; - $json['service_id'] = $this->serviceId; + $json['id'] = $this->id; + $json['owner_id'] = $this->ownerId; + $json['workflow_state'] = $this->workflowState; + $json['name'] = $this->name; + $json['time_window'] = $this->timeWindow; + $json['resource_id'] = $this->resourceId; + $json['service_id'] = $this->serviceId; + $json['description'] = $this->description; + $json['external_link'] = $this->externalLink; + $json['collaborative_link'] = $this->collaborativeLink; return $json; } diff --git a/src/Models/UpdateBookingByIdBody.php b/src/Models/UpdateBookingByIdBody.php index 86f048a..00bbe92 100644 --- a/src/Models/UpdateBookingByIdBody.php +++ b/src/Models/UpdateBookingByIdBody.php @@ -21,17 +21,10 @@ class UpdateBookingByIdBody implements JsonSerializable public $date; /** - * Required only when :recurs_by is 'monthly' or 'yearly' to differentiate between exact date or 'day in month/year'. See Recurring Booking examples. - * @maps date_recurs_by - * @var string|null $dateRecursBy public property - */ - public $dateRecursBy; - - /** - * List of comma-separated days of the week this Booking falls on. Useful for recurring Bookings. If provided, at least one must be specified. - * @var string|null $days public property + * New time of booking. Several formats are supported: '9am', '09:00', '9:00', '0900' + * @var string|null $time public property */ - public $days; + public $time; /** * New length of time, in minutes, for the desired booking - if Service allows requesting a variable amount of time @@ -46,6 +39,13 @@ class UpdateBookingByIdBody implements JsonSerializable */ public $endDate; + /** + * One of the possible recurrence values. + * @maps recurs_by + * @var string|null $recursBy public property + */ + public $recursBy; + /** * Optional frequency of recurrence as specified by :recurs_by. E.g, :single, :every, :every_other, etc. * @var string|null $frequency public property @@ -53,23 +53,23 @@ class UpdateBookingByIdBody implements JsonSerializable public $frequency; /** - * Optional occurrence of frequency. E.g, :first, :2nd, :last, :2nd_to_last, etc. - * @var string|null $occurrence public property + * List of comma-separated days of the week this Booking falls on. Useful for recurring Bookings. If provided, at least one must be specified. + * @var string|null $days public property */ - public $occurrence; + public $days; /** - * One of the possible recurrence values. - * @maps recurs_by - * @var string|null $recursBy public property + * Optional occurrence of frequency. E.g, :first, :2nd, :last, :2nd_to_last, etc. + * @var string|null $occurrence public property */ - public $recursBy; + public $occurrence; /** - * New time of booking. Several formats are supported: '9am', '09:00', '9:00', '0900' - * @var string|null $time public property + * Required only when :recurs_by is 'monthly' or 'yearly' to differentiate between exact date or 'day in month/year'. See Recurring Booking examples. + * @maps date_recurs_by + * @var string|null $dateRecursBy public property */ - public $time; + public $dateRecursBy; /** * When a recurring booking, one of: ['instance', 'all', 'infinite'] @@ -78,32 +78,48 @@ class UpdateBookingByIdBody implements JsonSerializable */ public $updateRecurring; + /** + * New name for Booking. + * @var string|null $name public property + */ + public $name; + + /** + * New description for Booking. + * @var string|null $description public property + */ + public $description; + /** * Constructor to set initial or default values of member properties * @param string $date Initialization value for $this->date - * @param string $dateRecursBy Initialization value for $this->dateRecursBy - * @param string $days Initialization value for $this->days + * @param string $time Initialization value for $this->time * @param integer $duration Initialization value for $this->duration * @param string $endDate Initialization value for $this->endDate + * @param string $recursBy Initialization value for $this->recursBy * @param string $frequency Initialization value for $this->frequency + * @param string $days Initialization value for $this->days * @param string $occurrence Initialization value for $this->occurrence - * @param string $recursBy Initialization value for $this->recursBy - * @param string $time Initialization value for $this->time + * @param string $dateRecursBy Initialization value for $this->dateRecursBy * @param string $updateRecurring Initialization value for $this->updateRecurring + * @param string $name Initialization value for $this->name + * @param string $description Initialization value for $this->description */ public function __construct() { - if (10 == func_num_args()) { + if (12 == func_num_args()) { $this->date = func_get_arg(0); - $this->dateRecursBy = func_get_arg(1); - $this->days = func_get_arg(2); - $this->duration = func_get_arg(3); - $this->endDate = func_get_arg(4); + $this->time = func_get_arg(1); + $this->duration = func_get_arg(2); + $this->endDate = func_get_arg(3); + $this->recursBy = func_get_arg(4); $this->frequency = func_get_arg(5); - $this->occurrence = func_get_arg(6); - $this->recursBy = func_get_arg(7); - $this->time = func_get_arg(8); + $this->days = func_get_arg(6); + $this->occurrence = func_get_arg(7); + $this->dateRecursBy = func_get_arg(8); $this->updateRecurring = func_get_arg(9); + $this->name = func_get_arg(10); + $this->description = func_get_arg(11); } } @@ -115,15 +131,17 @@ public function jsonSerialize() { $json = array(); $json['date'] = $this->date; - $json['date_recurs_by'] = $this->dateRecursBy; - $json['days'] = $this->days; + $json['time'] = $this->time; $json['duration'] = $this->duration; $json['end_date'] = $this->endDate; + $json['recurs_by'] = $this->recursBy; $json['frequency'] = $this->frequency; + $json['days'] = $this->days; $json['occurrence'] = $this->occurrence; - $json['recurs_by'] = $this->recursBy; - $json['time'] = $this->time; + $json['date_recurs_by'] = $this->dateRecursBy; $json['update_recurring'] = $this->updateRecurring; + $json['name'] = $this->name; + $json['description'] = $this->description; return $json; } diff --git a/test/Controllers/BookingsTest.php b/test/Controllers/BookingsTest.php index 2b5bdb5..8c471a1 100644 --- a/test/Controllers/BookingsTest.php +++ b/test/Controllers/BookingsTest.php @@ -119,33 +119,37 @@ private function bookingBody($action, $sId=NULL, $rId=NULL) { switch($action) { case 'create': return new CreateBookingBody( - date('Y-m-d', strtotime('tomorrow')), // date (within schedule start_date and end_date) $sId, // service_id + date('Y-m-d', strtotime('tomorrow')), // date (within schedule start_date and end_date) "13:00", // time (within schedule start_time and end_date) 8552697701, // sample user_id - NULL, // date_recurs_by - strtolower(date('l', strtotime('tomorrow'))), // days + $rId, // resource_id 30, // duration (>= service durations) NULL, // end_date + NULL, // recurs_by NULL, // frequency + strtolower(date('l', strtotime('tomorrow'))), // days NULL, // occurrence - NULL, // recurs_by - $rId // resource_id + NULL, // date_recurs_by + "my booking", // name + "my description" // description ); case 'update': return new CreateBookingBody( - date('Y-m-d', strtotime('tomorrow')), // date (within schedule start_date and end_date) $sId, // service_id + date('Y-m-d', strtotime('tomorrow')), // date (within schedule start_date and end_date) "13:45", // another time (within schedule start_time and end_date) 8552697701, // sample user_id - NULL, // date_recurs_by - strtolower(date('l', strtotime('tomorrow'))), // days + $rId, // resource_id 15, // another duration (>= service durations) NULL, // end_date + NULL, // recurs_by NULL, // frequency + strtolower(date('l', strtotime('tomorrow'))), // days NULL, // occurrence - NULL, // recurs_by - $rId // resource_id + NULL, // date_recurs_by + "another name", // name + "another description" // description ); } } @@ -159,18 +163,20 @@ private function bookingBody($action, $sId=NULL, $rId=NULL) { */ private function bodyFromResponse($response, $sId, $rId) { return new CreateBookingBody( + $response->booking->serviceId, // service $response->booking->timeWindow->startDate, // date - $sId, // service_id $response->booking->timeWindow->startTime, // time $response->booking->ownerId, // booking owner is CreateBookingBody userId - $response->booking->timeWindow->dateRecursBy, // date_recurs_by - strtolower(date('l', strtotime($response->booking->timeWindow->startDate))), // days + $response->booking->resourceId, // resource $response->booking->timeWindow->totalMinutes, // duration NULL, // end_date + NULL, // recurs_by NULL, // frequency + strtolower(date('l', strtotime($response->booking->timeWindow->startDate))), // days NULL, // occurrence - NULL, // recurs_by - $rId // resource_id + NULL, // date_recurs_by + $response->booking->name, // name + $response->booking->description // description ); }