I need to sent parameters for the function
Cloudflare\API\Endpoints\AccessRules::createRule()
public function createRule(
string $zoneID,
string $mode,
Configurations $configuration,
string $notes = null
): bool {
$options = [
'mode' => $mode,
'configuration' => $configuration->getArray()
];
if ($notes !== null) {
$options['notes'] = $notes;
}
$query = $this->adapter->post('zones/' . $zoneID . '/firewall/access_rules/rules', $options);
$this->body = json_decode($query->getBody());
if (isset($this->body->result->id)) {
return true;
}
return false;
}
My code:
$key = new Cloudflare\API\Auth\APIKey($userEmail, $api_key);
$adapter = new Cloudflare\API\Adapter\Guzzle($key);
$fw = new Cloudflare\API\Endpoints\AccessRules($adapter);
$configData= [
'target' => 'ip',
'value' => '1.2.3.4',
];
$result=$fw->createRule($zoneID,'block',$configData,"Auto block");
And my error:
Uncaught TypeError: Argument 3 passed to Cloudflare\API\Endpoints\AccessRules::createRule() must be an instance of Cloudflare\API\Configurations\Configurations, array given
I do $configData as a object - the same.
Could you tell me - how I should create instance in $configData