22
33namespace VerifyMy \SDK \Business ;
44
5+ use VerifyMy \SDK \Commons \Security \HMAC ;
56use VerifyMy \SDK \Commons \Transport \HTTP ;
67use VerifyMy \SDK \Business \BusinessClient ;
78use VerifyMy \SDK \Business \Entity \Requests \AllowedRedirectUrlsRequest ;
@@ -18,18 +19,24 @@ final class BusinessClientV1 implements BusinessClient
1819 */
1920 private $ transport ;
2021
22+ /**
23+ * @var HMAC $hmac
24+ */
25+ private HMAC $ hmac ;
26+
2127
2228 /**
2329 * @var string $baseURL
2430 * @var string $nucleusApiKey
2531 */
2632 private $ nucleusApiKey ;
2733
28- public function __construct (string $ baseURL , string $ nucleusApiKey )
34+ public function __construct (string $ baseURL , string $ nucleusApiKey, string $ apiSecret )
2935 {
3036 $ uri = BusinessClient::URI ;
3137 $ this ->transport = new HTTP ("$ baseURL/ $ uri " );
3238 $ this ->nucleusApiKey = $ nucleusApiKey ;
39+ $ this ->hmac = new HMAC ($ nucleusApiKey , $ apiSecret );
3340 }
3441
3542 /**
@@ -45,7 +52,7 @@ public function addAllowedRedirectUrls(AllowedRedirectUrlsRequest $request): voi
4552 self ::ENDPOINT_ALLOWED_REDIRECT_URLS ,
4653 $ data ["urls " ],
4754 [
48- 'Authorization ' => $ this ->nucleusApiKey ,
55+ 'Authorization ' => $ this ->hmac -> sign ( $ data [ " urls " ]) ,
4956 ],
5057 [204 ]
5158 );
@@ -64,8 +71,9 @@ public function removeAllowedRedirectUrls(AllowedRedirectUrlsRequest $request):
6471 self ::ENDPOINT_ALLOWED_REDIRECT_URLS ,
6572 $ data ["urls " ],
6673 [
67- 'Authorization ' => $ this ->nucleusApiKey ,
74+ 'Authorization ' => $ this ->hmac -> sign ( $ data [ " urls " ]) ,
6875 ],
6976 );
7077 }
71- }
78+ }
79+
0 commit comments