Skip to content

Commit

Permalink
more
Browse files Browse the repository at this point in the history
  • Loading branch information
awallef committed May 18, 2021
1 parent 5a4190c commit 0ddff51
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 2 deletions.
24 changes: 24 additions & 0 deletions src/Model/Endpoint/Schema/TaskSchema.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

namespace Trois\Clickup\Model\Endpoint\Schema;

use Muffin\Webservice\Model\Schema;

class TaskSchema extends Schema
{
/**
* {@inheritDoc}
*/
public function initialize()
{
parent::initialize();

$this->addColumn('id', [
'type' => 'integer',
'primaryKey' => true
]);
$this->addColumn('name', [
'type' => 'string',
]);
}
}
16 changes: 14 additions & 2 deletions src/Webservice/ClickUpWebservice.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,11 @@ protected function _executeReadQuery(Query $query, array $options = [])
/* @var Response $response */
$response = $this->driver()->client()->get($url, $queryParameters);
$results = $response->getJson();
if (!$response->isOk()) throw new \Exception($response->getJson()['err']);
if (!$response->isOk())
{
debug($response->getJson());
throw new \Exception($response->getJson()['err']);
}

// Turn results into resources
$resources = $this->_transformResults($query->endpoint(), $results);
Expand All @@ -106,9 +110,17 @@ protected function _transformResults(Endpoint $endpoint, array $results)
protected function _executeCreateQuery(Query $query, array $options = [])
{
$url = $this->getBaseUrl();
if ($nestedResource = $this->nestedResource($options)) $url = $nestedResource;

debug($url);

$response = $this->driver()->client()->post($url, $query->set());

if (!$response->isOk()) throw new \Exception($response->getJson()['err']);
if (!$response->isOk())
{
debug($response);
throw new \Exception($response->getJson()['err']);
}

return $this->_transformResource($query->endpoint(), $response->getJson());
}
Expand Down

0 comments on commit 0ddff51

Please sign in to comment.