src/Resource/AbstractResource.php
protected function create()
    {
        if ( !empty( $this->getID() ) ) {
            throw new \Exception('Object already has an ID, create() not possible');
        }

        if ( !$this->isDirty() ) {
            return $this;
        }

        $url      = $this->getURL('create');
        $response = $this->getClient()->post(
            $url,
            $this->getUnsavedValues(),
            [
                'expand' => true,
            ]
         );
        if ( $response->hasError() ) {
            $this->setError( $response->getError() );
            return $this;
        }

        $this->clearError();
        $this->setRemoteData( $response->getData() );
        $this->clearUnsavedValues();

        return $this;
    }
protected function create()
    {
        if ( !empty( $this->getID() ) ) {
            throw new \Exception('Object already has an ID, create() not possible');
        }

        if ( !$this->isDirty() ) {
            return $this;
        }

        $url      = $this->getURL('create');
        $response = $this->getClient()->post(
            $url,
            $this->getUnsavedValues(),
            [
                'expand' => true,
            ]
         );
        if ( $response->hasError() ) {
            $this->setError( $response->getError() );
            return $this;
        }

        $this->clearError();
        $this->setRemoteData( $response->getData() );
        $this->clearUnsavedValues();

        return $this;
    }
Creates a new object with the current data.

@return object      This object