src/SecucardConnect/Client/ProductService.php
public function save(BaseModel $model)
    {
        if ($this->resourceMetadata->resourceClass != get_class($model)) {
            throw new Exception('Unable save data, data type and service must match.');
        }

        // default add new object
        $method = RequestOps::CREATE;

        if (!empty($model->id)) {
            // update the existing record
            $method = RequestOps::UPDATE;
        }

        $params = new RequestParams($method, $this->resourceMetadata, $model->id, null, null, null,
            MapperUtil::jsonEncode($model, $model->jsonFilterProperties(), $model->jsonFilterNullProperties()));
        $jsonResponse = $this->request($params);

        if ($jsonResponse === false) {
            throw new Exception('Error updating model');
        }

        $inst = $this->createResourceInst($jsonResponse, $this->resourceMetadata->resourceClass);

        $this->postProcess($inst);

        return $inst;
    }
public function save(BaseModel $model)
    {
        if ($this->resourceMetadata->resourceClass != get_class($model)) {
            throw new Exception('Unable save data, data type and service must match.');
        }

        // default add new object
        $method = RequestOps::CREATE;

        if (!empty($model->id)) {
            // update the existing record
            $method = RequestOps::UPDATE;
        }

        $params = new RequestParams($method, $this->resourceMetadata, $model->id, null, null, null,
            MapperUtil::jsonEncode($model, $model->jsonFilterProperties(), $model->jsonFilterNullProperties()));
        $jsonResponse = $this->request($params);

        if ($jsonResponse === false) {
            throw new Exception('Error updating model');
        }

        $inst = $this->createResourceInst($jsonResponse, $this->resourceMetadata->resourceClass);

        $this->postProcess($inst);

        return $inst;
    }
public function save ( BaseModel $ model ) { if ( $ this -> resourceMetadata -> resourceClass != get_class ( $ model ) ) { throw new Exception ( 'Unable save data, data type and service must match.' ) ; } // default add new object $ method = RequestOps :: CREATE ; if ( ! empty ( $ model -> id ) ) { // update the existing record $ method = RequestOps :: UPDATE ; } $ params = new RequestParams ( $ method , $ this -> resourceMetadata , $ model -> id , null , null , null , MapperUtil :: jsonEncode ( $ model , $ model -> jsonFilterProperties ( ) , $ model -> jsonFilterNullProperties ( ) ) ) ; $ jsonResponse = $ this -> request ( $ params ) ; if ( $ jsonResponse === false ) { throw new Exception ( 'Error updating model' ) ; } $ inst = $ this -> createResourceInst ( $ jsonResponse , $ this -> resourceMetadata -> resourceClass ) ; $ this -> postProcess ( $ inst ) ; return $ inst ; }
Function to save object
It can update existing or create new object, if the given object has an id with value null ist will create a
new object.

@param BaseModel $model The object to save.
@return BaseModel The created object, has same type as the given input.
@throws ApiError
@throws AuthError
@throws ClientError
@throws GuzzleException
@throws Exception
Function to save object It can update existing or create new object if the given object has an id with value null ist will create a new object .