File tree Expand file tree Collapse file tree 3 files changed +53
-6
lines changed Expand file tree Collapse file tree 3 files changed +53
-6
lines changed Original file line number Diff line number Diff line change @@ -14,26 +14,26 @@ final class Email extends BaseResource
1414 /**
1515 * Validate an email address.
1616 *
17- * @param string $email Email address to validate
17+ * @param string|array $query Email address to validate
1818 *
1919 * @return Response The response from the validation request
2020 */
21- public function validate ($ email ): Response
21+ public function validate ($ query ): Response
2222 {
23- $ query = ["email " => $ email ];
23+ $ query = is_array ( $ query ) ? $ query : ["email " => $ query ];
2424 return $ this ->sendRequest ($ query );
2525 }
2626
2727 /**
2828 * Search for information related to an email address.
2929 *
30- * @param string $email Email address to search for
30+ * @param string|array $query Email address to search for
3131 *
3232 * @return Response The response from the search request
3333 */
34- public function search (string $ email ): Response
34+ public function search ($ query ): Response
3535 {
36- $ query = ["value " => $ email ];
36+ $ query = is_array ( $ query ) ? $ query : ["value " => $ query ];
3737 return $ this ->sendRequest ($ query );
3838 }
3939
Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ public function testSearchResults()
2020 // Input string for email search.
2121 $ input = 'info@ ' ;
2222
23+ // Options that will be sent within the request.
2324 $ options = [
2425 "resultsLimit " => 5
2526 ];
@@ -35,4 +36,27 @@ public function testSearchResults()
3536 $ this ->assertGreaterThan (0 , $ response ->getResponse ()->resultsCount );
3637 $ this ->assertNotEmpty ($ result );
3738 }
39+
40+ /**
41+ * Test email search when the input parameter is specified as the entire query.
42+ */
43+ public function testQueryInput ()
44+ {
45+ // Query that will be sent to the API for validation.
46+ $ query = [
47+ "value " => "info@ "
48+ ];
49+
50+ // Options that will be sent within the request.
51+ $ options = [
52+ "resultsLimit " => 5
53+ ];
54+
55+ // Perform email validation.
56+ $ response = $ this ->api ->email ->setOptions ($ options )->search ($ query );
57+
58+ // Assertions.
59+ $ this ->assertInstanceOf (Response::class, $ response );
60+ $ this ->assertEquals (200 , $ response ->getStatus ());
61+ }
3862}
Original file line number Diff line number Diff line change @@ -233,4 +233,27 @@ public function testWithClient()
233233 $ this ->assertEquals (200 , $ response ->getStatus ());
234234 $ this ->assertTrue ($ result ->isValid );
235235 }
236+
237+ /**
238+ * Test email validation when the input parameter is specified as the entire query.
239+ */
240+ public function testQueryInput ()
241+ {
242+ // Query that will be sent to the API for validation.
243+ $ query = [
244+ 245+ ];
246+
247+ // Options that will be sent within the request.
248+ $ options = [
249+ "validationType " => "extended "
250+ ];
251+
252+ // Perform email validation.
253+ $ response = $ this ->api ->email ->setOptions ($ options )->validate ($ query );
254+
255+ // Assertions.
256+ $ this ->assertInstanceOf (Response::class, $ response );
257+ $ this ->assertEquals (200 , $ response ->getStatus ());
258+ }
236259}
You can’t perform that action at this time.
0 commit comments