Skip to content

Commit

Permalink
Update to API documentation as of May 9, 2023.
Browse files Browse the repository at this point in the history
  • Loading branch information
kloor committed May 9, 2023
1 parent 0bd96eb commit 324ecb4
Show file tree
Hide file tree
Showing 9 changed files with 148 additions and 0 deletions.
60 changes: 60 additions & 0 deletions src/Action/Space/BookingsSpaceAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,18 @@ final class BookingsSpaceAction extends Action
*/
public ?int $page = null;

/** Flag to include tentative bookings. */
public ?bool $include_tentative = null;

/** Flag to include canceled bookings. */
public ?bool $include_cancel = null;

/**
* Flag to include integration bookings such as Outlook & Google Sync
* bookings.
*/
public ?bool $include_remote = null;

/**
* Send request to the LibCal API.
*
Expand All @@ -82,6 +94,15 @@ public function send(): array
$uri = self::addQuery($uri, 'page', $this->page);
$uri = $this->addFormAnswers($uri);

$uri = self::addQuery(
$uri,
'include_tentative',
$this->include_tentative
);

$uri = self::addQuery($uri, 'include_cancel', $this->include_cancel);
$uri = self::addQuery($uri, 'include_remote', $this->include_remote);

/** @var BookingSpaceData[] $result */
$result = $this->memoize(
$uri,
Expand Down Expand Up @@ -247,6 +268,45 @@ public function setPage(int $page = 1): self
return $this;
}

/**
* Set to include tentative bookings.
*
* @param bool $include_tentative Value to set, enabling by default.
* @return self A reference to this object for method chaining.
*/
public function setIncludeTentative(bool $include_tentative = true): self
{
$this->include_tentative = $include_tentative;

return $this;
}

/**
* Set to include canceled bookings.
*
* @param bool $include_cancel Value to set, enabling by default.
* @return self A reference to this object for method chaining.
*/
public function setIncludeCancel(bool $include_cancel = true): self
{
$this->include_cancel = $include_cancel;

return $this;
}

/**
* Set to include remote bookings.
*
* @param bool $include_remote Value to set, enabling by default.
* @return self A reference to this object for method chaining.
*/
public function setIncludeRemote(bool $include_remote = true): self
{
$this->include_remote = $include_remote;

return $this;
}

/**
* Convert an array of integers to a string separated by commas.
*
Expand Down
3 changes: 3 additions & 0 deletions src/Action/Space/CategoriesSpaceAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Lits\LibCal\Action;
use Lits\LibCal\Action\TraitAdminOnly;
use Lits\LibCal\Action\TraitCache;
use Lits\LibCal\Action\TraitDetails;
use Lits\LibCal\Action\TraitIdMultiple;
use Lits\LibCal\Client;
use Lits\LibCal\Data\Space\CategoriesSpaceData;
Expand All @@ -19,6 +20,7 @@ final class CategoriesSpaceAction extends Action
{
use TraitAdminOnly;
use TraitCache;
use TraitDetails;
use TraitIdMultiple;

/**
Expand All @@ -34,6 +36,7 @@ public function send(): array
$uri = '/' . Client::VERSION . '/space/categories';
$uri = $this->addId($uri);
$uri = $this->addAdminOnly($uri);
$uri = $this->addDetails($uri);

/** @var CategoriesSpaceData[] $result */
$result = $this->memoize(
Expand Down
3 changes: 3 additions & 0 deletions src/Action/Space/CategorySpaceAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace Lits\LibCal\Action\Space;

use Lits\LibCal\Action;
use Lits\LibCal\Action\TraitAdminOnly;
use Lits\LibCal\Action\TraitAvailability;
use Lits\LibCal\Action\TraitCache;
use Lits\LibCal\Action\TraitDetails;
Expand All @@ -18,6 +19,7 @@
/** Action to get information about space/seat categories in your system. */
final class CategorySpaceAction extends Action
{
use TraitAdminOnly;
use TraitAvailability;
use TraitCache;
use TraitDetails;
Expand All @@ -35,6 +37,7 @@ public function send(): array
{
$uri = '/' . Client::VERSION . '/space/category';
$uri = $this->addId($uri);
$uri = $this->addAdminOnly($uri);
$uri = $this->addAvailability($uri);
$uri = $this->addDetails($uri);

Expand Down
36 changes: 36 additions & 0 deletions src/Action/Space/ItemsSpaceAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use Lits\LibCal\Action\TraitZoneId;
use Lits\LibCal\Client;
use Lits\LibCal\Data\Space\ItemSpaceData;
use Lits\LibCal\Exception\ActionException;
use Lits\LibCal\Exception\ClientException;
use Lits\LibCal\Exception\DataException;
use Lits\LibCal\Exception\NotFoundException;
Expand All @@ -34,6 +35,12 @@ final class ItemsSpaceAction extends Action
use TraitPowered;
use TraitZoneId;

/**
* Sets which items to be returned: "public", "private" or "admin_only".
* Default: "public".
*/
public ?string $visibility = null;

/** A flag to only return Bookable As Whole spaces. */
public ?bool $bookable = null;

Expand All @@ -57,6 +64,7 @@ public function send(): array
$uri = $this->addAvailability($uri);
$uri = $this->addPageIndex($uri);
$uri = $this->addPageSize($uri);
$uri = self::addQuery($uri, 'visibility', $this->visibility);

/** @var ItemSpaceData[] $result */
$result = $this->memoize(
Expand All @@ -69,6 +77,34 @@ public function send(): array
return $result;
}

/**
* Sets which items to be returned.
*
* @param string $visibility Can be "public", "private" or "admin_only".
* If you provide a "categoryId" then this option is ignored and all
* items for the "categoryId" will be returned.
* If you provide "private" for this option then items from both public
* and private categories will be returned.
* If you provide "admin_only" for this option then all items for the
* location will be returned.
* @return self A reference to this object for method chaining.
* @throws ActionException If an invalid value is specified.
*/
public function setVisibility(string $visibility = 'public'): self
{
$options = ['public', 'private', 'admin_only'];

if (!\in_array($visibility, $options, true)) {
throw new ActionException(
'Visibility must be one of: ' . \implode(', ', $options)
);
}

$this->visibility = $visibility;

return $this;
}

/**
* Set to only return Bookable As Whole spaces.
*
Expand Down
35 changes: 35 additions & 0 deletions src/Action/Space/SeatsSpaceAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ final class SeatsSpaceAction extends Action
use TraitPowered;
use TraitZoneId;

/** A space id to only show details for this space. */
public ?int $spaceId = null;

/** A seat id to only show details for this seat. */
public ?int $seatId = null;

/**
* Send request to the LibCal API.
*
Expand All @@ -52,6 +58,8 @@ public function send(): array
$uri = $this->addPowered($uri);
$uri = $this->addPageIndex($uri);
$uri = $this->addPageSize($uri);
$uri = self::addQuery($uri, 'spaceId', $this->spaceId);
$uri = self::addQuery($uri, 'seatId', $this->seatId);

/** @var SeatSpaceData[] $result */
$result = $this->memoize(
Expand All @@ -64,6 +72,33 @@ public function send(): array
return $result;
}

/**
* Set a space ID to only show details for this space.
*
* @param int $spaceId Value to set. If used with a seatId, the spaceId
* will be ignored.
* @return self A reference to this object for method chaining.
*/
public function setSpaceId(int $spaceId): self
{
$this->spaceId = $spaceId;

return $this;
}

/**
* Set a seat ID to only show details for this seat.
*
* @param int $seatId Value to set.
* @return self A reference to this object for method chaining.
*/
public function setSeatId(int $seatId): self
{
$this->seatId = $seatId;

return $this;
}

/**
* Do not allow for the string "next" as part of the availability.
*
Expand Down
1 change: 1 addition & 0 deletions src/Data/Space/BookingSpaceData.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ final class BookingSpaceData extends Data
use TraitQuestions;

public string $bookId;
public int $id;
public int $eid;
public int $cid;
public int $lid;
Expand Down
3 changes: 3 additions & 0 deletions src/Data/Space/CategorySpaceData.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ final class CategorySpaceData extends Data
public ?int $formid = null;
public ?bool $public = null;
public ?bool $admin_only = null;
public ?bool $google = null;
public ?string $termsAndConditions = null;
public ?string $description = null;

/** @var ItemSpaceData[] $items */
public ?array $items = null;
Expand Down
6 changes: 6 additions & 0 deletions src/Data/Space/ItemSpaceData.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,23 @@ final class ItemSpaceData extends Data
public int $id;
public ?string $name = null;
public ?string $description = null;
public ?string $termsAndConditions = null;
public ?string $image = null;
public ?int $capacity = null;
public ?int $formid = null;
public ?bool $isBookableAsWhole = null;
public ?bool $isAccessible = null;
public ?bool $isPowered = null;
public ?bool $isEventLocation = null;
public ?bool $google = null;
public ?bool $exchange = null;
public ?string $exchangeResource = null;
public ?int $zoneId = null;
public ?string $zoneName = null;
public ?int $groupId = null;
public ?string $groupName = null;
public ?string $groupTermsAndConditions = null;
public ?string $locationTermsAndConditions = null;

/** @var AvailabilitySpaceData[] $availability */
public ?array $availability = null;
Expand Down
1 change: 1 addition & 0 deletions src/Data/Space/Reserve/PayloadReserveSpaceData.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ final class PayloadReserveSpaceData extends Data
public array $bookings;

public ?string $nickname = null;
public ?float $cost = null;
public ?bool $adminbooking = null;
public ?bool $test = null;

Expand Down

0 comments on commit 324ecb4

Please sign in to comment.