From 91fccdadd4aa9f685a5c5db33f8acd06f77d33cb Mon Sep 17 00:00:00 2001 From: Chris Thompson Date: Fri, 13 Nov 2020 12:17:14 -0500 Subject: [PATCH] Removing calendar.edit and calendar.delete These are Nylas API endpoints, but they aren't supported by the official Nylas SDKs and Nylas engineers told me they really shouldn't be documented endpoints. --- src/Calendars/Calendar.php | 73 -------------------------------------- tests/CalendarTest.php | 41 --------------------- 2 files changed, 114 deletions(-) diff --git a/src/Calendars/Calendar.php b/src/Calendars/Calendar.php index a353b2a..b7b5313 100644 --- a/src/Calendars/Calendar.php +++ b/src/Calendars/Calendar.php @@ -97,38 +97,6 @@ public function addCalendar(array $params): array // ------------------------------------------------------------------------------ - /** - * update calendar - * - * @param array $params - * - * @return array - */ - public function updateCalendar(array $params): array - { - $rules = $this->addCalendarRules(); - $rules[] = V::key('id', V::stringType()->notEmpty()); - - $accessToken = $this->options->getAccessToken(); - - V::doValidate(V::keySet(...$rules), $params); - V::doValidate(V::stringType()->notEmpty(), $accessToken); - - $path = $params['id']; - $header = ['Authorization' => $accessToken]; - - unset($params['id']); - - return $this->options - ->getSync() - ->setPath($path) - ->setFormParams($params) - ->setHeaderParams($header) - ->put(API::LIST['oneCalendar']); - } - - // ------------------------------------------------------------------------------ - /** * get calendar * @@ -170,47 +138,6 @@ public function getCalendar($calendarId): array // ------------------------------------------------------------------------------ - /** - * delete calendar - * - * @param mixed $contactId string|string[] - * - * @return array - */ - public function deleteCalendar($contactId): array - { - $calendarId = Helper::fooToArray($contactId); - $accessToken = $this->options->getAccessToken(); - - $rule = V::simpleArray(V::stringType()->notEmpty()); - - V::doValidate($rule, $calendarId); - V::doValidate(V::stringType()->notEmpty(), $accessToken); - - $queues = []; - $target = API::LIST['oneCalendar']; - $header = ['Authorization' => $accessToken]; - - foreach ($calendarId as $id) - { - $request = $this->options - ->getAsync() - ->setPath($id) - ->setHeaderParams($header); - - $queues[] = static function () use ($request, $target) - { - return $request->delete($target); - }; - } - - $pools = $this->options->getAsync()->pool($queues, false); - - return Helper::concatPoolInfos($calendarId, $pools); - } - - // ------------------------------------------------------------------------------ - /** * rules for add calendar * diff --git a/tests/CalendarTest.php b/tests/CalendarTest.php index e582f03..b5f1f14 100644 --- a/tests/CalendarTest.php +++ b/tests/CalendarTest.php @@ -52,47 +52,6 @@ public function testAddCalendar(): void // ------------------------------------------------------------------------------ - public function testUpdateCalendar(): void - { - $data = $this->client->Calendars()->Calendar()->addCalendar($this->getCalendarInfo()); - - $params = - [ - 'id' => $data['id'], - 'name' => 'Different Calendar', - 'description' => 'This is now a different calendar.', - 'timezone' => 'America/Los_Angeles', - ]; - - $data = $this->client->Calendars()->Calendar()->updateContact($params); - - $this->assertEquals($data['id'], $params['id']); - $this->assertEquals($data['name'], $params['name']); - $this->assertEquals($data['description'], $params['description']); - $this->assertEquals($data['timezone'], $params['timezone']); - } - - // ------------------------------------------------------------------------------ - - public function testDeleteCalendar(): void - { - $data = $this->client->Calendars()->Calendar()->addCalendar($this->getCalendarInfo()); - - try - { - $back = true; - $this->client->Calendars()->Calendar()->deleteCalendar($data['id']); - } - catch (Exception $e) - { - $back = false; - } - - $this->assertTrue($back); - } - - // ------------------------------------------------------------------------------ - /** * @return array */