Several cool features

- replace vars from collection by default
- replace vars from environment file with -e
- bearer auth header
This commit is contained in:
2023-08-13 10:26:22 +08:00
parent c630af8795
commit c4961b1238
6 changed files with 257 additions and 36 deletions

View File

@@ -127,6 +127,30 @@ abstract class AbstractRequest implements RequestContract
return $this;
}
/**
* Sets authorization headers
*
* @param object|null $auth
* @return $this
*/
public function setAuth(?object $auth): static
{
if (!empty($auth)) {
switch ($auth->type) {
case 'bearer':
$this->headers['Authorization'] = [
'value' => 'Bearer ' . $auth->{$auth->type}[0]->value,
'disabled' => false,
];
break;
default:
break;
}
}
return $this;
}
/**
* Sets body mode from collection item to request object
*