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;
    }