Skip to content

Commit 43d4b91

Browse files
author
Edoardo Soloperto
committed
fix: namespace traits
1 parent 39f8ece commit 43d4b91

File tree

4 files changed

+54
-22
lines changed

4 files changed

+54
-22
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
composer.lock
2+
vendor/*

src/Client.php

+44-18
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
class Client
99
{
1010
private $guzzleClient;
11-
private const MODELS_NAMESPACE = __NAMESPACE__ . "\\Models\\";
11+
private const MODELS_NAMESPACE = __NAMESPACE__.'\\Models\\';
1212
private $models_match = [
13-
'TaskList' => 'list'
13+
'TaskList' => 'list',
1414
];
1515

1616
public function __construct($apiToken)
@@ -24,7 +24,7 @@ public function __construct($apiToken)
2424
}
2525

2626
/**
27-
* client
27+
* client.
2828
*
2929
* @return Client
3030
*/
@@ -34,65 +34,91 @@ public function client()
3434
}
3535

3636
/**
37-
* __call
37+
* __call.
38+
*
39+
* @param mixed $name
40+
* @param mixed $arguments
3841
*
39-
* @param mixed $name
40-
* @param mixed $arguments
4142
* @return void
4243
*/
4344
public function __call(string $name, array $arguments)
4445
{
45-
if (class_exists(self::MODELS_NAMESPACE . ucfirst($name)) === false) {
46+
if (class_exists(self::MODELS_NAMESPACE.ucfirst($name)) === false) {
4647
throw new \Exception("`$name` is not a method or object", 1);
4748
}
4849
$model = ucfirst($name);
49-
$model_namespaced = self::MODELS_NAMESPACE . $model;
50+
$model_namespaced = self::MODELS_NAMESPACE.$model;
5051

5152
if (array_key_exists($model, $this->models_match)) {
5253
$model = $this->models_match[$model];
5354
}
5455

5556
$object = new $model_namespaced($this, $arguments[0] ?? null);
57+
5658
return $object;
5759
}
5860

5961
/**
60-
* @param string $method
61-
* @param array $params
6262
* @return mixed
6363
*/
64-
public function get($method, $params = [])
64+
public function get(string $method, array $params = [])
6565
{
6666
$response = $this->guzzleClient->request('GET', $method, ['query' => $params]);
67+
6768
return json_decode($response->getBody(), true);
6869
}
6970

7071
/**
71-
* @param string $method
72-
* @param array $body
7372
* @return mixed
7473
*/
75-
public function post($method, $body = [])
74+
public function post(string $method, array $body = [])
7675
{
7776
$response = $this->guzzleClient->request('POST', $method, ['json' => $body]);
77+
7878
return json_decode($response->getBody(), true);
7979
}
8080

8181
/**
82-
* delete
82+
* delete.
83+
*
84+
* @param mixed $method
8385
*
84-
* @param mixed $method
8586
* @return int
8687
*/
87-
public function delete($method)
88+
public function delete(string $method)
8889
{
8990
$response = $this->guzzleClient->request('DELETE', $method);
91+
9092
return $response->getStatusCode();
9193
}
9294

93-
public function put($method, $body = [])
95+
/**
96+
* put.
97+
*
98+
* @param mixed $method
99+
* @param mixed $body
100+
*
101+
* @return void
102+
*/
103+
public function put(string $method, array $body = [])
94104
{
95105
$response = $this->guzzleClient->request('PUT', $method, ['json' => $body]);
106+
107+
return json_decode($response->getBody(), true);
108+
}
109+
110+
/**
111+
* multipart.
112+
*
113+
* @param mixed $method
114+
* @param mixed $attachment
115+
*
116+
* @return void
117+
*/
118+
public function multipart(string $method, $attachment)
119+
{
120+
$response = $this->guzzleClient->request('POST', $method, $attachment);
121+
96122
return json_decode($response->getBody(), true);
97123
}
98124
}

src/Models/Task.php

+6-2
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,17 @@
22

33
namespace ClickUpClient\Models;
44

5-
use \ClickUpClient\CommentTrait;
6-
use \ClickUpClient\MemberTrait;
5+
use ClickUpClient\Traits\CommentTrait;
6+
use ClickUpClient\Traits\MemberTrait;
77

88
class Task extends AbstractModel
99
{
1010
use CommentTrait;
1111
use MemberTrait;
1212

1313
public $model = 'task';
14+
15+
public function addAttachment()
16+
{
17+
}
1418
}

src/Models/TaskList.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
namespace ClickUpClient\Models;
44

5-
use \ClickUpClient\CommentTrait;
6-
use \ClickUpClient\MemberTrait;
5+
use ClickUpClient\Traits\CommentTrait;
6+
use ClickUpClient\Traits\MemberTrait;
77

88
class TaskList extends AbstractModel
99
{

0 commit comments

Comments
 (0)