Skip to content

Commit

Permalink
Removing calendar.edit and calendar.delete
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
ChrisThompsonTLDR committed Nov 13, 2020
1 parent bea216e commit 91fccda
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 114 deletions.
73 changes: 0 additions & 73 deletions src/Calendars/Calendar.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand Down Expand Up @@ -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
*
Expand Down
41 changes: 0 additions & 41 deletions tests/CalendarTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down

0 comments on commit 91fccda

Please sign in to comment.