55use ReflectionClass ;
66use Illuminate \Support \Str ;
77use Illuminate \Support \Collection ;
8- use Sammyjo20 \Saloon \Traits \ HasMake ;
8+ use Sammyjo20 \Saloon \Clients \ MockClient ;
99use Sammyjo20 \Saloon \Traits \CollectsData ;
1010use Sammyjo20 \Saloon \Traits \CollectsConfig ;
1111use Sammyjo20 \Saloon \Traits \CollectsHeaders ;
@@ -29,8 +29,7 @@ abstract class SaloonConnector implements SaloonConnectorInterface
2929 CollectsHandlers,
3030 CollectsInterceptors,
3131 AuthenticatesRequests,
32- HasCustomResponses,
33- HasMake;
32+ HasCustomResponses;
3433
3534 /**
3635 * Register Saloon requests that will become methods on the connector.
@@ -47,6 +46,17 @@ abstract class SaloonConnector implements SaloonConnectorInterface
4746 */
4847 private ?array $ registeredRequests = null ;
4948
49+ /**
50+ * Instantiate a new class with the arguments.
51+ *
52+ * @param mixed ...$arguments
53+ * @return SaloonConnector
54+ */
55+ public static function make (...$ arguments ): self
56+ {
57+ return new static (...$ arguments );
58+ }
59+
5060 /**
5161 * Define anything that should be added to any requests
5262 * with this connector before the request is sent.
@@ -127,6 +137,29 @@ public function requestExists(string $method): bool
127137 return method_exists ($ this , $ method ) || array_key_exists ($ method , $ this ->getRegisteredRequests ());
128138 }
129139
140+ /**
141+ * Prepare a new request by providing it the current instance of the connector.
142+ *
143+ * @param SaloonRequest $request
144+ * @return SaloonRequest
145+ */
146+ public function request (SaloonRequest $ request ): SaloonRequest
147+ {
148+ return $ request ->setConnector ($ this );
149+ }
150+
151+ /**
152+ * Send a Saloon request with the current instance of the connector.
153+ *
154+ * @throws \ReflectionException
155+ * @throws \GuzzleHttp\Exception\GuzzleException
156+ * @throws \Sammyjo20\Saloon\Exceptions\SaloonException
157+ */
158+ public function send (SaloonRequest $ request , MockClient $ mockClient = null ): SaloonResponse
159+ {
160+ return $ this ->request ($ request )->send ($ mockClient );
161+ }
162+
130163 /**
131164 * Dynamically proxy other methods to try and call a requests.
132165 *
0 commit comments