| @@ 96-112 (lines=17) @@ | ||
| 93 | /** |
|
| 94 | * {@inheritdoc} |
|
| 95 | */ |
|
| 96 | public function getClientProjects($clientId, $active = Activity::ACTIVE) |
|
| 97 | { |
|
| 98 | $request = new GetClientProjectsRequest(array( |
|
| 99 | 'clientId' => $clientId, |
|
| 100 | 'active' => $active, |
|
| 101 | ) |
|
| 102 | ); |
|
| 103 | ||
| 104 | $response = $this->delegate($request); |
|
| 105 | ||
| 106 | $projects = array(); |
|
| 107 | foreach ($response->body as $project) { |
|
| 108 | $projects[] = $this->hydrator->hydrate($project, new ProjectValue()); |
|
| 109 | } |
|
| 110 | ||
| 111 | return new ProjectsResponse(array('projects' => $projects)); |
|
| 112 | } |
|
| 113 | ||
| 114 | /** |
|
| 115 | * {@inheritdoc} |
|
| @@ 149-170 (lines=22) @@ | ||
| 146 | /** |
|
| 147 | * @inheritDoc |
|
| 148 | */ |
|
| 149 | public function getTimeEntriesStartedInDateRange(\DateTime $startDate, \DateTime $endDate) |
|
| 150 | { |
|
| 151 | $request = new GetTimeEntriesStartedInDateRange( |
|
| 152 | array( |
|
| 153 | 'startDate' => $startDate, |
|
| 154 | 'endDate' => $endDate, |
|
| 155 | ) |
|
| 156 | ); |
|
| 157 | ||
| 158 | $response = $this->delegate($request); |
|
| 159 | ||
| 160 | $entries = array(); |
|
| 161 | foreach ($response->body as $entry) { |
|
| 162 | $entries[] = $this->hydrator->hydrate($entry, new TimeEntry()); |
|
| 163 | } |
|
| 164 | ||
| 165 | return new TimeEntries( |
|
| 166 | array( |
|
| 167 | 'timeEntries' => $entries, |
|
| 168 | ) |
|
| 169 | ); |
|
| 170 | } |
|
| 171 | ||
| 172 | /** |
|
| 173 | * @inheritDoc |
|
| @@ 175-197 (lines=23) @@ | ||
| 172 | /** |
|
| 173 | * @inheritDoc |
|
| 174 | */ |
|
| 175 | public function bulkUpdateTimeEntriesTags(array $timeEntries, array $tags, $tagAction = \Marek\Toggable\API\Toggl\Values\TagAction::ADD) |
|
| 176 | { |
|
| 177 | $request = new BulkUpdateTimeEntriesTags( |
|
| 178 | array( |
|
| 179 | 'timeEntries' => $timeEntries, |
|
| 180 | 'tags' => $tags, |
|
| 181 | 'tagAction' => $tagAction, |
|
| 182 | ) |
|
| 183 | ); |
|
| 184 | ||
| 185 | $response = $this->delegate($request); |
|
| 186 | ||
| 187 | $entries = array(); |
|
| 188 | foreach ($response->body['data'] as $entry) { |
|
| 189 | $entries[] = $this->hydrator->hydrate($entry, new TimeEntry()); |
|
| 190 | } |
|
| 191 | ||
| 192 | return new TimeEntries( |
|
| 193 | array( |
|
| 194 | 'timeEntries' => $entries, |
|
| 195 | ) |
|
| 196 | ); |
|
| 197 | } |
|
| 198 | ||
| 199 | /** |
|
| 200 | * Response helper method |
|