_data = $response; // This is only for child classes if (get_class($this) == Base::class) { Log::debug(sprintf('%s:Slack RESPONSE Initialised [%s]',static::LOGKEY,get_class($this)),['m'=>__METHOD__]); if (App::environment() == 'dev') file_put_contents('/tmp/response',print_r($this,TRUE),FILE_APPEND); } } /** * Enable getting values for keys in the response * * @note: This method is limited to certain values to ensure integrity reasons * @note: Classes should return: * + channel_id, * + team_id, * + ts, * + user_id */ public function __get($key) { switch ($key) { case 'channel_id': // For interactive post responses, the channel ID is "channel" return object_get($this->_data,$key) ?: object_get($this->_data,'channel'); case 'messages': // Used by getMessageHistory() return collect(object_get($this->_data,$key)); case 'team_id': case 'ts': case 'user_id': case 'type': // Needed by URL verification return object_get($this->_data,$key); } } /** * When we json_encode this object, this is the data that will be returned */ public function jsonSerialize() { return $this->_data ? $this->_data : new \stdClass; } }