| @@ 55-69 (lines=15) @@ | ||
| 52 | * |
|
| 53 | * @return mixed |
|
| 54 | */ |
|
| 55 | public function saveNewTask(Task $task) |
|
| 56 | { |
|
| 57 | $data = $this->serializer->serialize($task, 'json'); |
|
| 58 | ||
| 59 | $res = $this->client->request('POST', self::VERSION . '/tasks', [ |
|
| 60 | 'body' => $data, |
|
| 61 | 'headers' => [ |
|
| 62 | 'Content-Type' => 'application/json', |
|
| 63 | 'X-Ninja-Token' => $this->api_token, |
|
| 64 | 'X-Requested-With' => 'XMLHttpRequest', |
|
| 65 | ] |
|
| 66 | ]); |
|
| 67 | ||
| 68 | return $this->serializer->deserialize($res->getBody(), Task::class, 'json'); |
|
| 69 | } |
|
| 70 | ||
| 71 | /** |
|
| 72 | * @param Project $project |
|
| @@ 76-90 (lines=15) @@ | ||
| 73 | * |
|
| 74 | * @return mixed |
|
| 75 | */ |
|
| 76 | public function saveNewProject(Project $project) |
|
| 77 | { |
|
| 78 | $data = $this->serializer->serialize($project, 'json'); |
|
| 79 | ||
| 80 | $res = $this->client->request('POST', self::VERSION . '/projects', [ |
|
| 81 | 'body' => $data, |
|
| 82 | 'headers' => [ |
|
| 83 | 'Content-Type' => 'application/json', |
|
| 84 | 'X-Ninja-Token' => $this->api_token, |
|
| 85 | 'X-Requested-With' => 'XMLHttpRequest', |
|
| 86 | ] |
|
| 87 | ]); |
|
| 88 | ||
| 89 | return $this->serializer->deserialize($res->getBody(), 'Syncer\Dto\InvoiceNinja\ProjectWrapper', 'json')->getData(); |
|
| 90 | } |
|
| 91 | ||
| 92 | /** |
|
| 93 | * @param Project $project |
|
| @@ 97-111 (lines=15) @@ | ||
| 94 | * |
|
| 95 | * @return mixed |
|
| 96 | */ |
|
| 97 | public function saveNewClient(Client $client) |
|
| 98 | { |
|
| 99 | $data = $this->serializer->serialize($client, 'json'); |
|
| 100 | ||
| 101 | $res = $this->client->request('POST', self::VERSION . '/clients', [ |
|
| 102 | 'body' => $data, |
|
| 103 | 'headers' => [ |
|
| 104 | 'Content-Type' => 'application/json', |
|
| 105 | 'X-Ninja-Token' => $this->api_token, |
|
| 106 | 'X-Requested-With' => 'XMLHttpRequest', |
|
| 107 | ] |
|
| 108 | ]); |
|
| 109 | ||
| 110 | return $this->serializer->deserialize($res->getBody(), 'Syncer\Dto\InvoiceNinja\ClientWrapper', 'json')->getData(); |
|
| 111 | } |
|
| 112 | ||
| 113 | /** |
|
| 114 | * @return array|Project[] |
|