Execute a POST request against CouchDB inserting a new document, leaving the server to generate a uuid.

@param array $data

@throws HTTPException

@return array<id, rev>
354593
public function postDocument(array $data)
    {
        $path = '/'.$this->databaseName;
        $response = $this->httpClient->request('POST', $path, json_encode($data));

        if ($response->status != 201) {
            throw HTTPException::fromResponse($path, $response);
        }

        return [$response->body['id'], $response->body['rev']];
    }
317124
public function create($data)
    {
        $data = $this->retrieveData($data);
        $insertData = [
            'role_id'=> $this->getRoleId(),
            'resource' => $data['resource'],
            'methods'=> implode(',', $data['methods']),
        ];
        $this->table->insert($insertData);

        return $data;
    }
27758
public function create($api, array $data)
    {
        return $this->checkException($this->callHttpMethod($this->normalizeUri($api), Request::METHOD_POST, $data));
    }
1161241
public function insert(array $data)
    {
        if (false === $this->trigger('before_insert', $this)) {
            return false;
        }

        if($this->dateFormat && $this->updateTime && $this->createTime){
            $time = date('Y-m-d H:i:s', time());
            $data[$this->updateTime] = $time;
            $data[$this->createTime] = $time;
        } else {
            $time =  time();
            $data[$this->updateTime] =  $time;
            $data[$this->createTime] =  $time;
        }

        $response = $this->getQuery()->insert($data);

        if (false === $this->trigger('after_insert', $this)) {
            return false;
        }
        return $response;
    }
180885
public static function createFromData(array $data)
    {
        if (!isset($data['type'])) {
            throw new DomainException(self::MSG_REQUIRED_TYPE);
        }

        if (!in_array($data['type'], self::allowedRejectionTypes(), true)) {
            throw new DomainException(self::MSG_UNSUPPORTED_TYPE);
        }

        return new self($data);
    }
40085
public function update(array $data)
    {
        $project_id = (int) (empty($data['project_id']) ? 0: $data['project_id']);
        $person_id = (int) (empty($data['person_id']) ? 0: $data['person_id']);
        if ($project_id <= 0) {
            throw new Exception("Required field project_id");
        }
        if ($person_id <= 0) {
            throw new Exception("Required field person_id");
        }
        return $this->rest->put("projects/$project_id/people/$person_id", $data);
    }
1224736
public function create(array $data)
    {
        if (is_null($this->schema)) {
            throw SystemException::forNoSchema();
        }

        $table = $this->schema->getName();
        $created = $this->schema->getCreatedFieldName();
        $updated = $this->schema->getUpdatedFieldName();
        $ipaddress = $this->schema->getIPAddressFieldName();

        if ($created) {
            $data[$created] = date('Y-m-d H:i:s');
        }

        if ($updated) {
            $data[$updated] = date('Y-m-d H:i:s');
        }

        if ($ipaddress && isset($_SERVER['REMOTE_ADDR'])) {
            $data[$ipaddress] = $_SERVER['REMOTE_ADDR'];
        }

        $uuids = $this->schema->getUuidFieldNames();

        foreach($uuids as $uuid) {
            $data[$uuid] = sha1(uniqid());
        }

        return $this
            ->resource
            ->model($data)
            ->save($table)
            ->get();
    }
1151235
public function sendData($data)
    {
        try {
            $response = $this->httpClient->post(
                $this->getEndpoint(),
                $this->getRequestHeaders(),
                json_encode($data)
            )->send();

            return new TokenPurchaseResponse($this, $response->json());
        } catch (BadResponseException $e) {
            $response = $e->getResponse();

            return new TokenPurchaseResponse($this, $response->json());
        }
    }
1346732
public static function insert($data)
    {
        $self  = self::getInstance();
        $table = $self->table_name;

        if (isset($data[0])) {
            $make      = $self->makeMultipleInsert($table, $data);
            $statement = $make[0];
            $value     = $make[1];
        } else {
            $newData    = $self->makeInsertParameter($data);
            $column     = implode(",", array_keys($data));
            $paramValue = implode(",", array_keys($newData));
            $statement  = "INSERT INTO {$table} ({$column}) VALUES({$paramValue});";
            $value      = $newData;
        }

        $execute   = $self->exec($statement, $value);

        return $execute;
    }
409696
public function create(array $data)
    {
        if (array_key_exists("image", $data)) {
            if (class_exists('\CURLFile')) {
                $data["image"] = new \CURLFile($data['image']);
            } else {
                $data["image"] = '@' . $data['image'];
            }
        }

        $response = $this->request->post("pins", $data);
        return new Pin($this->master, $response);
    }
176072
public function sendData($data)
    {
        // enforce TLS >= v1.2 (https://www.payway.com.au/rest-docs/index.html#basics)
        $config = $this->httpClient->getConfig();
        $curlOptions = $config->get('curl.options');
        $curlOptions[CURLOPT_SSLVERSION] = 6;
        $config->set('curl.options', $curlOptions);
        $this->httpClient->setConfig($config);

        // don't throw exceptions for 4xx errors
        $this->httpClient->getEventDispatcher()->addListener(
            'request.error',
            function ($event) {
                if ($event['response']->isClientError()) {
                    $event->stopPropagation();
                }
            }
        );

        if ($this->getSSLCertificatePath()) {
            $this->httpClient->setSslVerification($this->getSSLCertificatePath());
        }

        $request = $this->httpClient->createRequest(
            $this->getHttpMethod(),
            $this->getEndpoint(),
            $this->getRequestHeaders(),
            $data
        );

        // get the appropriate API key
        $apikey = ($this->getUseSecretKey()) ? $this->getApiKeySecret() : $this->getApiKeyPublic();
        $request->setHeader('Authorization', 'Basic ' . base64_encode($apikey . ':'));

        // send the request
        $response = $request->send();

        $this->response = new Response($this, $response->json());

        // save additional info
        $this->response->setHttpResponseCode($response->getStatusCode());
        $this->response->setTransactionType($this->getTransactionType());

        return $this->response;
    }
226611
public function post ($data)
		{
			$this->_options[ CURLOPT_POST ] = 1;
			$this->_options[ CURLOPT_POSTFIELDS ] = is_array($data) ? http_build_query($data) : $data;

			return $this->send();
		}
1023732
public function save(array $data)
    {
        if (!isset($data['id']) || !$data['id']) {
            $entity = $this->provider->createEntity();
        } else {
            $entity = $this->read((int) $data['id']);
            if (!$entity) {
                throw new AppException('No record found', 404);
            }
        }

        return $this->provider->save($entity);
    }
1143745
protected function insert($data)
    {
        try {

            if ($this->creationTouch) {
                $data[$this->creationTouchName] = date('Y-m-d H:i:s');
            }

            $this->db->insert($this->table, $this->fromArray($data));

            $id = $this->db->lastInsertId($this->sequence ? $this->sequence : $this->primaryKey);

        } catch (\Exception $e) {
            throw $e;
        }

        return $id;
    }
1374610
public function createRequestToken(array $data = [])
    {
        $token = new RequestToken();

        if (array_key_exists('expires_at', $data)) {
            $token->setExpiresAt(new \DateTime($data['expires_at']));
        }

        if (array_key_exists('request_token', $data)) {
            $token->setToken($data['request_token']);
        }

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

        return $token;
    }
969096
private function createResponse($curl, $data, InternalRequestInterface $internalRequest)
    {
        if (empty($data)) {
            throw HttpAdapterException::cannotFetchUri(
                (string) $internalRequest->getUri(),
                $this->getName(),
                curl_error($curl)
            );
        }

        $headers = substr($data, 0, $headersSize = curl_getinfo($curl, CURLINFO_HEADER_SIZE));

        return $this->getConfiguration()->getMessageFactory()->createResponse(
            StatusCodeExtractor::extract($headers),
            ProtocolVersionExtractor::extract($headers),
            HeadersNormalizer::normalize($headers),
            BodyNormalizer::normalize(substr($data, $headersSize), $internalRequest->getMethod())
        );
    }
480539
protected function __create(array $data, $index, $type, $id = null, array $parameters = []) {
        $parameters+=["api" => "create"];
        $api = strtolower($parameters["api"]) == "index" ? "index" : "create";
        unset($parameters["api"]);
        $result = $this->client->$api([
            'index' => $index,
            'type' => $type,
            'body' => $data] + ($id ? ['id' => $id] : []) + $parameters);
        if (array_key_exists('_shards', $result) && array_key_exists('failed', $result['_shards']) && $result['_shards']['failed'] > 0) {
            throw new Exception('Failed to create the document. Serialized results: ' + json_encode($result));
        } else {
            $result = $this->__find($result['_index'], $result['_type'], $result['_id']);
        }
        return $result;
    }