Skip to content

Commit

Permalink
api update
Browse files Browse the repository at this point in the history
  • Loading branch information
lanlin committed Sep 26, 2021
1 parent 00b12da commit 156075a
Show file tree
Hide file tree
Showing 10 changed files with 14 additions and 851 deletions.
25 changes: 6 additions & 19 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,15 @@
* @property Events\Abs Events
* @property Files\Abs Files
* @property Folders\Abs Folders
* @property JobStatuses\Abs JobStatuses
* @property Labels\Abs Labels
* @property Management\Abs Management
* @property Messages\Abs Messages
* @property Neural\Abs Neural
* @property Outbox\Abs Outbox
* @property Rooms\Abs Rooms
* @property Threads\Abs Threads
* @property Webhooks\Abs Webhooks
* @property JobStatuses\Abs JobStatuses
*
* @author lanlin
* @change 2021/09/22
Expand Down Expand Up @@ -73,21 +76,6 @@ public function __get(string $name): object

// ------------------------------------------------------------------------------

/**
* call nylas apis with __call
*
* @param string $name
* @param array $arguments
*
* @return object
*/
public function __call(string $name, array $arguments): object
{
return $this->callSubClass($name, $arguments);
}

// ------------------------------------------------------------------------------

/**
* get options instance for setting options
*
Expand All @@ -104,11 +92,10 @@ public function Options(): Options
* call sub class
*
* @param string $name
* @param array $arguments
*
* @return object
*/
private function callSubClass(string $name, array $arguments = []): object
private function callSubClass(string $name): object
{
$apiClass = __NAMESPACE__.'\\'.\ucfirst($name).'\\Abs';

Expand All @@ -118,7 +105,7 @@ private function callSubClass(string $name, array $arguments = []): object
throw new NylasException(null, "class {$apiClass} not found!");
}

return new $apiClass($this->options, ...$arguments);
return new $apiClass($this->options);
}

// ------------------------------------------------------------------------------
Expand Down
9 changes: 1 addition & 8 deletions src/Contacts/Contact.php
Original file line number Diff line number Diff line change
Expand Up @@ -202,17 +202,10 @@ public function returnsAContactsPicture(array $params): array

foreach ($downloadArr as $item)
{
$haders = $this->options->getAuthorizationHeader();

if (!empty($item['auth']))
{
$haders['authorization'] = $item['auth'];
}

$request = $this->options
->getAsync()
->setPath($item['id'])
->setHeaderParams($haders);
->setHeaderParams($this->options->getAuthorizationHeader());

$queues[] = static function () use ($request, $item)
{
Expand Down
13 changes: 5 additions & 8 deletions src/Contacts/Validation.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,13 @@ class Validation
*/
public static function pictureRules(): V
{
$path = V::oneOf(
V::resourceType(),
V::stringType()->notEmpty(),
V::instance(StreamInterface::class)
);

return V::simpleArray(V::keySet(
V::key('id', V::stringType()->notEmpty()),
V::key('path', $path),
V::keyOptional('auth', V::stringType()->notEmpty())
V::key('path', V::oneOf(
V::resourceType(),
V::stringType()->notEmpty(),
V::instance(StreamInterface::class)
))
));
}

Expand Down
1 change: 0 additions & 1 deletion src/Messages/Abs.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
* Nylas Abs
* ----------------------------------------------------------------------------------
*
* @property Smart Smart
* @property Search Search
* @property Message Message
* @property Sending Sending
Expand Down
Loading

0 comments on commit 156075a

Please sign in to comment.