| @@ 13-50 (lines=38) @@ | ||
| 10 | /** | |
| 11 | * Class CallTrackingService | |
| 12 | */ | |
| 13 | class CallTrackingService extends AbstractService implements ServiceInterface | |
| 14 | { | |
| 15 | /** | |
| 16 | * @param CallTrackingPostMessage $message | |
| 17 | * | |
| 18 | * @return CallTracking | |
| 19 | */ | |
| 20 | public function postCallTracking(CallTrackingPostMessage $message): CallTracking | |
| 21 |     { | |
| 22 |         $path = sprintf('sites/%d/call_trackings', $message->getSiteId()); | |
| 23 | $data = ['api_call_tracking' => $message->build()]; | |
| 24 | ||
| 25 |         $response = $this->getClient()->sendRequest('POST', $path, $data); | |
| 26 | ||
| 27 | /** @var CallTracking $model */ | |
| 28 | $model = $this->getModelFactory()->create(CallTracking::class, $response); | |
| 29 | ||
| 30 | return $model; | |
| 31 | } | |
| 32 | ||
| 33 | /** | |
| 34 | * @param CallTrackingPatchMessage $message | |
| 35 | * | |
| 36 | * @return CallTracking | |
| 37 | */ | |
| 38 | public function patchCallTracking(CallTrackingPatchMessage $message): CallTracking | |
| 39 |     { | |
| 40 |         $path = sprintf('sites/%d/call_trackings/update', $message->getSiteId()); | |
| 41 | $data = ['api_call_tracking_edit' => $message->build()]; | |
| 42 | ||
| 43 |         $response = $this->getClient()->sendRequest('PATCH', $path, $data); | |
| 44 | ||
| 45 | /** @var CallTracking $model */ | |
| 46 | $model = $this->getModelFactory()->create(CallTracking::class, $response); | |
| 47 | ||
| 48 | return $model; | |
| 49 | } | |
| 50 | } | |
| 51 | ||
| @@ 13-50 (lines=38) @@ | ||
| 10 | /** | |
| 11 | * Class CompanyService | |
| 12 | */ | |
| 13 | class CompanyService extends AbstractService implements ServiceInterface | |
| 14 | { | |
| 15 | /** | |
| 16 | * @param CompanyPostMessage $message | |
| 17 | * | |
| 18 | * @return Company | |
| 19 | */ | |
| 20 | public function postCompany(CompanyPostMessage $message): Company | |
| 21 |     { | |
| 22 | $path = 'companies'; | |
| 23 | $data = ['api_company' => $message->build()]; | |
| 24 | ||
| 25 |         $response = $this->getClient()->sendRequest('POST', $path, $data); | |
| 26 | ||
| 27 | /** @var Company $model */ | |
| 28 | $model = $this->getModelFactory()->create(Company::class, $response); | |
| 29 | ||
| 30 | return $model; | |
| 31 | } | |
| 32 | ||
| 33 | /** | |
| 34 | * @param CompanyPatchMessage $message | |
| 35 | * | |
| 36 | * @return Company | |
| 37 | */ | |
| 38 | public function patchCompany(CompanyPatchMessage $message): Company | |
| 39 |     { | |
| 40 |         $path = sprintf('companies/%d', $message->getId()); | |
| 41 | $data = ['api_company' => $message->build()]; | |
| 42 | ||
| 43 |         $response = $this->getClient()->sendRequest('PATCH', $path, $data); | |
| 44 | ||
| 45 | /** @var Company $model */ | |
| 46 | $model = $this->getModelFactory()->create(Company::class, $response); | |
| 47 | ||
| 48 | return $model; | |
| 49 | } | |
| 50 | } | |
| 51 | ||
| @@ 13-50 (lines=38) @@ | ||
| 10 | /** | |
| 11 | * Class TeamWorkerService | |
| 12 | */ | |
| 13 | class TeamWorkerService extends AbstractService implements ServiceInterface | |
| 14 | { | |
| 15 | /** | |
| 16 | * @param TeamWorkerPostMessage $message | |
| 17 | * | |
| 18 | * @return TeamWorker | |
| 19 | */ | |
| 20 | public function postTeamWorker(TeamWorkerPostMessage $message): TeamWorker | |
| 21 |     { | |
| 22 |         $path = sprintf('sites/%d/teams/workers', $message->getSiteId()); | |
| 23 | $data = ['api_team_worker' => $message->build()]; | |
| 24 | ||
| 25 |         $response = $this->getClient()->sendRequest('POST', $path, $data); | |
| 26 | ||
| 27 | /** @var TeamWorker $model */ | |
| 28 | $model = $this->getModelFactory()->create(TeamWorker::class, $response); | |
| 29 | ||
| 30 | return $model; | |
| 31 | } | |
| 32 | ||
| 33 | /** | |
| 34 | * @param TeamWorkerPatchMessage $message | |
| 35 | * | |
| 36 | * @return TeamWorker | |
| 37 | */ | |
| 38 | public function patchTeamWorker(TeamWorkerPatchMessage $message): TeamWorker | |
| 39 |     { | |
| 40 |         $path = sprintf('sites/%d/teams/%d/worker', $message->getSiteId(), $message->getId()); | |
| 41 | $data = ['api_team_worker' => $message->build()]; | |
| 42 | ||
| 43 |         $response = $this->getClient()->sendRequest('PATCH', $path, $data); | |
| 44 | ||
| 45 | /** @var TeamWorker $model */ | |
| 46 | $model = $this->getModelFactory()->create(TeamWorker::class, $response); | |
| 47 | ||
| 48 | return $model; | |
| 49 | } | |
| 50 | } | |
| 51 | ||
| @@ 13-50 (lines=38) @@ | ||
| 10 | /** | |
| 11 | * Class UserService | |
| 12 | */ | |
| 13 | class UserService extends AbstractService implements ServiceInterface | |
| 14 | { | |
| 15 | /** | |
| 16 | * @param UserPostMessage $message | |
| 17 | * | |
| 18 | * @return User | |
| 19 | */ | |
| 20 | public function postUser(UserPostMessage $message): User | |
| 21 |     { | |
| 22 |         $path = sprintf('companies/%d/users', $message->getCompanyId()); | |
| 23 | $data = ['api_user' => $message->build()]; | |
| 24 | ||
| 25 |         $response = $this->getClient()->sendRequest('POST', $path, $data); | |
| 26 | ||
| 27 | /** @var User $model */ | |
| 28 | $model = $this->getModelFactory()->create(User::class, $response); | |
| 29 | ||
| 30 | return $model; | |
| 31 | } | |
| 32 | ||
| 33 | /** | |
| 34 | * @param UserPatchMessage $message | |
| 35 | * | |
| 36 | * @return User | |
| 37 | */ | |
| 38 | public function patchUser(UserPatchMessage $message): User | |
| 39 |     { | |
| 40 |         $path = sprintf('companies/%d/users/%d', $message->getCompanyId(), $message->getId()); | |
| 41 | $data = ['api_user' => $message->build()]; | |
| 42 | ||
| 43 |         $response = $this->getClient()->sendRequest('PATCH', $path, $data); | |
| 44 | ||
| 45 | /** @var User $model */ | |
| 46 | $model = $this->getModelFactory()->create(User::class, $response); | |
| 47 | ||
| 48 | return $model; | |
| 49 | } | |
| 50 | } | |
| 51 | ||