BaseRequest.php 999 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. namespace ThirdParty\Urs\Request;
  3. use ThirdParty\Urs\Dto\Config;
  4. abstract class BaseRequest extends \App\Module\ThirdParty\Services\BaseRequest
  5. {
  6. /**
  7. * 构造函数
  8. */
  9. public function __construct()
  10. {
  11. // 使用'urs'作为服务代码,需要在thirdparty_services表中注册
  12. parent::__construct('urs');
  13. }
  14. /**
  15. * 获取URS配置对象
  16. *
  17. * @return \ThirdParty\Urs\Dto\Config
  18. */
  19. protected function getUrsConfig(): \ThirdParty\Urs\Dto\Config
  20. {
  21. return Config::fromArray($this->service->config);
  22. }
  23. /**
  24. * 获取URS凭证对象
  25. *
  26. * @return \ThirdParty\Urs\Dto\Credential
  27. */
  28. protected function getUrsCredential(): \ThirdParty\Urs\Dto\Credential
  29. {
  30. // 从认证凭证中获取凭证信息,而不是从服务配置
  31. $credentials = $this->getCredential()->getDecryptedCredentials();
  32. return \ThirdParty\Urs\Dto\Credential::fromArray($credentials);
  33. }
  34. }