Sets a JSON result

@param *mixed $data
@param mixed  ...$args

@return RestTrait
339695
public function setResults($data, ...$args)
    {
        if (is_array($data)) {
            return $this->setDot('json.results', $data);
        }

        return $this->set('json', 'results', $data, ...$args);
    }
925162
public function setFromResult($data)
    {
        $this->setCategories($data['categories']);
        $this->setI18nType($data['i18n_type']);
        $this->setSourceLanguageCode($data['source_language_code']);
        $this->setName($data['name']);
        $this->setSlug($data['slug']);

        if (isset($data['project_slug'])) {
            $this->setProject($data['project_slug']);
        }

        if (isset($data['created'])) {
            $this->created = $data['created'];
        }

        if (isset($data['available_languages'])) {
            $languages = array();
            foreach ($data['available_languages'] as $lang) {
                $languages[$lang['code']] = array
                (
                    $lang['code_aliases'],
                    $lang['name'],
                );
            }
            $this->availableLanguages = $languages;
        }

        if (isset($data['wordcount'])) {
            $this->wordcount = $data['wordcount'];
        }

        if (isset($data['total_entities'])) {
            $this->totalEntities = $data['total_entities'];
        }

        if (isset($data['accept_translations'])) {
            $this->acceptTranslations = $data['accept_translations'];
        }

        if (isset($data['last_update'])) {
            $this->lastUpdate = $data['last_update'];
        }

        return $this;
    }
1049397
public function setCallback($data = [])
    {
        if (is_array($data)) {

            if (array_key_exists('callbackOnFail', $data)) {
                $this->setSecondaryCallbackURL($data['callbackOnFail']);
            }

            if (array_key_exists('callbackOnSuccess', $data)) {
                $this->setPrimaryCallbackURL($data['callbackOnSuccess']);
            }

            if (array_key_exists('error', $data)) {
                $this->setSecondaryCallbackURL($data['error']);
            }

            if (array_key_exists('success', $data)) {
                $this->setPrimaryCallbackURL($data['success']);
            }

            if (array_key_exists('callback', $data)) {
                $this->setCallback($data['callback']);
            }
        }

        return $this->callback($data);
    }
1315659
public function setResult($result, $data = null)
    {
        if (null === $result) {
            return $this;
        }

        if (is_numeric($result)) {
            if ($result > 1000) {
                $result = ResultException::factory($result, $data);
            } else {
                $result = new static::$resultClass((int) $result, $data);
            }
        } elseif ($result instanceof ResultException) {
            // continue
        } elseif (is_array($result) && isset($result[self::RESULT_P_GLOBAL_CODE])) {
            $result = ResultException::factory($result[self::RESULT_P_GLOBAL_CODE], $result[self::RESULT_P_DATA]);
        } else {
            $result = new ResultException(ResultException::E_INTERNAL, $result);
        }

        if (!empty($data)) {
            $result->addData($data);
        }

        $this->result = $result;
        $this->setData(self::P_RESULT, [
            self::RESULT_P_GLOBAL_CODE => $result->getGlobalCode(),
            self::RESULT_P_DATA        => $result->getData(),
        ]);

        return $this;
    }
329287
public function set($data)
    {
        $this->error = [];
        $result = null;
        switch ($this->format) {
            case 'nvp':
                parse_str($data, $this->data);
                $result = !empty($this->data);
                break;

            case 'json':
            default:
                $this->data = empty($data) ? [] : (json_decode($data, true) ?: []);
                $result = json_last_error() == JSON_ERROR_NONE;
                if (empty ($result)) {
                    $this->error = [
                        'error' => json_last_error(),
                        'msg'   => json_last_error_msg(),
                    ];
                }
                break;
        }

        return $result;
    }
647029
public function setData($data)
    {
        $resultData = $this->hydrateIfJsonToArray($data);
        if (!empty($resultData)) {
            $this->data = $resultData;
        }
        else {
            $this->data = [];
        }
    }
118236
public function setData(array $data)
    {
        $data = $this->setIdFromData($data);

        parent::setData($data);
        return $this;
    }
647815
public function data(...$args)
    {
        $this->each(function ($item) use ($args) {
            $item->data(...$args);
        });

        return $this;
    }
855609
public function update($data)
    {
        $response = $this->api->put($this->url(), $data);
        $this->data = (array) $response->data;

        return $this;
    }
388797
public function data($args)
    {
        foreach (func_get_args() as $arg) {
            if (is_array($arg)) {
                $this->data = array_merge_recursive($arg, $this->data);
            } else {
                $this->data[] = $arg;
            }
        }

        return $this;
    }
694610
public function setData($data) 
	{
		if(is_array($data)) {
			$this->data = $data;
		}
		
		$args = func_get_args();
		$this->data[$args[0]] = $args[1];
		
		return $this;
	}
205875
public function setData($data)
	{
		if ($data && !static::$methods[$this->method]) {
			throw new \InvalidArgumentException("HTTP method [$this->method] does not allow POST data.");
		}

		$this->data = $data;

		return $this;
	}
747453
public function setFiles($data, ...$args)
    {
        if (is_array($data)) {
            return $this->set('files', $data);
        }

        if (count($args) === 0) {
            return $this;
        }

        return $this->set('files', $data, ...$args);
    }
1302892
public function setRawJsonBody(array $data)
    {
        $this->addHeader('Content-Type', 'application/json');
        $this->setBody(Stream::factory(json_encode($data)));
        return $this;
    }
192592
public function setResponseBody($data)
    {
        if (!is_string($data)) {
            $data = json_encode($data, \JSON_PRETTY_PRINT);
        }
        $this->response->getBody()->write($data);
        return $this;
    }
1143044
public function setDataObject($data)
    {
        if (true === is_object($data)) {
            $data = json_encode($data);
        }

        return $this->setData($data);
    }
137541
public function setCookies($data, ...$args)
    {
        if (is_array($data)) {
            return $this->set('cookie', $data);
        }

        if (count($args) === 0) {
            return $this;
        }

        return $this->set('cookie', $data, ...$args);
    }