'required|int', 'answer' => 'required|string|max:255' ]; public function __construct(array $properties = []) { parent::__construct(); $this->fill($properties); return $this; } // PUBLIC METHODS /** * Set unanswered question for a specific customer * * @param string $hashcode The customer hashcode * @param integer $questionId The question id * @param array $answersId An array with answers id * @return bool true if succeeded * * @throws \LDC\LDCCRM\Exceptions\CrmException * if an error occurs on server side or on getting response * @throws \LDC\LDCCRM\Exceptions\ApiErrorException * If any error or \LDC\LDCCRM\Enums\ApiError occurs */ public static function setQuestionAnswers(string $hashcode, int $questionId, array $answersId): bool { self::assertValidHascode($hashcode); self::assertValidPrimaryKey($questionId); if (!count($answersId)) { return true; } foreach ($answersId as $answerId) { self::assertValidPrimaryKey($answerId); } static::setUpApiInterface(); // set apiInterface $request = Utils::getResquest( 'apiV2.customers.answers.store', [ 'customer' => $hashcode ], [ 'question' => $questionId, 'answers' => $answersId ] ); $response = static::$apiInterface->call($request); return $response->status->equals(ApiStatus::OK()); } /** * Serialize this object to an array * * @return array */ public function jsonSerialize() { return [ 'id' => $this->id, 'answer' => $this->answer ]; } }