@param string     $id
@param array|null $params

@throws \Zibios\WrikePhpLibrary\Exception\Api\ApiException
@throws \LogicException
@throws \InvalidArgumentException
@throws \Throwable

@return mixed
548874
public function createForFolder(string $id, array $params = [])
    {
        return $this->executeRequest(
            RequestMethodEnum::POST,
            ResourceMethodEnum::CREATE_FOR_FOLDER,
            $params,
            $id
        );
    }
400770
public static function add($id, $params = null, $apiKey = null)
    {
        $class = get_class();
        return self::_scopedAddBatch($class, $id, $params, $apiKey);
    }
1291795
public function getDMById($id)
    {
        return $this->getDMs()->then(function (array $dms) use ($id) {
            foreach ($dms as $dm) {
                if ($dm->getId() === $id) {
                    return $dm;
                }
            }

            throw new ApiException('DM ' . $id . ' not found.');
        });
    }
94865
public function connect($id, array $params)
    {
        $returnValue = null;
        $this->params = $params;
        $driver = $params['driver'];
        $dbLogin = $params['user'];
        $dbpass = $params['password'];
        //remove pdo to add UpperCase ClassName

    		$connLimit = 3; // Max connection attempts.
            $counter = 0; // Connection attemps counter.
    		
            while (true){
                $dsn = $this->getDSN();
                $options = array(PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_BOTH,
                    PDO::ATTR_PERSISTENT => false,
                    PDO::ATTR_EMULATE_PREPARES => false);
                
                 
                foreach ($this->getExtraConfiguration() as $k => $v){
                    $options[$k] = $v;
                }
                
                try{
                    $this->dbConnector = @new PDO($dsn, $dbLogin, $dbpass, $options);
                    $this->afterConnect();
                   
                   
                    // We are connected. Get out of the loop.
                    break;
                }
                catch (PDOException $e){
                    $this->dbConnector = null;
                    $counter++;
                
                    if ($counter == $connLimit){
                        // Connection attempts exceeded.
                        throw $e;
                    }
                }
            }
            
            $returnValue =  new common_persistence_SqlPersistence($params,$this);;

        return $returnValue;
    }
222560
public static function createById($id, $record, $params = [])
    {
        $m = new static;
        $pk = $m->getPrimaryKey();
        $record[$pk] = $id;

        try {
            $response = static::bulkCreate([$record], $params);

            return current($response);
        } catch (BatchException $ex) {
            $response = $ex->pickResponse(0);
            if ($response instanceof \Exception) {
                throw $response;
            }

            return $response;
        } catch (\Exception $ex) {
            throw new InternalServerErrorException($ex->getMessage());
        }
    }
738057
public static function createSource($id, $params = null, $opts = null)
    {
        return self::_createNestedResource($id, static::PATH_SOURCES, $params, $opts);
    }
1083644
public function select($id = null)
    {
        if (!is_array($id) || !isset($id['service']) || !isset($id['method']) || empty($id['service']) || empty($id['method'])) {
            throw new \InvalidArgumentException('Invalid id argument. Must be array and containing at least service and method property.');
        }

        $serviceName = $id['service'];
        if (!isset($this->services[$serviceName])) {
            throw new \InvalidArgumentException("Service '$serviceName' is not registered in StorageProvider.");
        }

        $method = $id['method'];
        if (!empty($this->services[$serviceName]['methods']) && !in_array($method, $this->services[$serviceName]['methods'])) {
            throw new \InvalidArgumentException("Method '$method' is not registered in StorageProvider for service '$serviceName'.");
        }

        $service = $this->container->get($serviceName);
        $callable_with_arguments = array($service, $method, isset($id['arguments']) ? $id['arguments'] : null);

        return new StorageSelection($callable_with_arguments);
    }
1276846
public function uploadForFolder(string $id, array $params = [])
    {
        return $this->executeRequest(
            RequestMethodEnum::UPLOAD,
            ResourceMethodEnum::UPLOAD_FOR_FOLDER,
            $params,
            $id
        );
    }
680108
public static function deleteInternal($id, $record, $params = [])
    {
        if (empty($record)) {
            throw new BadRequestException('There are no fields in the record to create . ');
        }

        if (empty($id)) {
            //Todo:perform logging below
            //Log::error( 'Update request with no id supplied: ' . print_r( $record, true ) );
            throw new BadRequestException('Identifying field "id" can not be empty for update request . ');
        }

        $model = static::find($id);

        if (!$model instanceof Model) {
            throw new NotFoundException("Record with identifier '$id' not found.");
        }

        try {
            $result = static::buildResult($model, $params);
            $model->delete();

            return $result;
        } catch (\Exception $ex) {
            throw new InternalServerErrorException('Failed to delete resource: ' . $ex->getMessage());
        }
    }
1255623
public function get(int $id, $params = [])
    {
        if ($this->fields) {
            $params['fields'] = implode(',', $this->fields);
        }

        $uriAppend = 'byId/' . $id;
        $response  = $this->handler->handle('GET', false, $uriAppend, $params);

        return $this->make($response, false);
    }
106675
public function create($id, $name, array $params = array())
    {
        $params['idList'] = $id;
        $params['name'] = $name;

        if (!array_key_exists('due', $params)) {
            $params['due'] = null;
        }

        return $this->post($this->getPath($id), $params);
    }
457761
function connect($id, array $params)
    {
        if (!isset($params['sqlPersistence'])) {
            throw new common_exception_Error('Missing underlying sql persistence');
        }
        
        $this->sqlPeristence = common_persistence_SqlPersistence::getPersistence($params['sqlPersistence']);
        $this->garbageCollection = isset($params['gc']) ? $params['gc'] : self::DEFAULT_GC_PROBABILITY;

        
        return new common_persistence_KeyValuePersistence($params, $this);
    }
1159592
public function update(string $id, array $params = [])
    {
        return $this->executeRequest(
            RequestMethodEnum::PUT,
            ResourceMethodEnum::UPDATE,
            $params,
            $id
        );
    }
560488
public function find($id = null, $params = [])
    {
        if (!$id) {
            throw new InvalidArgumentException('We need an id');
        }

        return $this->gateway->commit('get', $this->gateway->buildUrlFromString('notifications/webhooks/'.$id), [], $params);
    }
696744
public Object exec(String id, String ... params) throws PHPException {
		return container.getObjectParser().parse(getCmd(id, params));
	}
668817
public function createForTask(string $id, array $params = [])
    {
        return $this->executeRequest(
            RequestMethodEnum::POST,
            ResourceMethodEnum::CREATE_FOR_TASK,
            $params,
            $id
        );
    }
216864
public static function findOrFail($id, array $params = [])
    {
        $instance = new static([], static::getParentID());

        // Make request
        if (!is_null($result = $instance->request($instance->getEndpoint(), 'find', [$id, $params]))) {
            return $result;
        }

        // Not found
        throw new NotFoundException;
    }