getIdentity(); $data['client_id'] = $client->id; $per_page = $data['per_page'] ?? $this->di['pager']->getPer_page(); [$sql, $params] = $this->getService()->getSearchQuery($data); $pager = $this->di['pager']->getSimpleResultSet($sql, $params, $per_page); foreach ($pager['list'] as $key => $item) { $pager['list'][$key] = [ 'id' => $item['id'], 'client_id' => $item['client_id'], 'sender' => $item['sender'], 'recipients' => $item['recipients'], 'subject' => $item['subject'], 'content_html' => $item['content_html'], 'content_text' => $item['content_text'], 'created_at' => $item['created_at'], 'updated_at' => $item['updated_at'], ]; } return $pager; } /** * Get email details. * * @param int $id - Email id * * @return array * * @throws \Box_Exception * @throws LogicException */ public function get($data) { $required = [ 'id' => 'Email ID is required', ]; $this->di['validator']->checkRequiredParamsForArray($required, $data); $model = $this->getService()->findOneForClientById($this->getIdentity(), $data['id']); if (!$model instanceof \Model_ActivityClientEmail) { throw new \Box_Exception('Email not found'); } return $this->getService()->toApiArray($model); } /** * Resend email to client once again. * * @param int $id - Email id * * @return type * * @throws \Box_Exception * @throws LogicException */ public function resend($data) { $required = [ 'id' => 'Email ID is required', ]; $this->di['validator']->checkRequiredParamsForArray($required, $data); $model = $this->getService()->findOneForClientById($this->getIdentity(), $data['id']); if (!$model instanceof \Model_ActivityClientEmail) { throw new \Box_Exception('Email not found'); } return $this->getService()->resend($model); } /** * Remove email from system. * * @param int $id - Email id * * @return type * * @throws \Box_Exception * @throws LogicException */ public function delete($data) { $required = [ 'id' => 'Email ID is required', ]; $this->di['validator']->checkRequiredParamsForArray($required, $data); $model = $this->getService()->findOneForClientById($this->getIdentity(), $data['id']); if (!$model instanceof \Model_ActivityClientEmail) { throw new \Box_Exception('Email not found'); } return $this->getService()->rm($model); } }