OapiCspaceAuthGenerateRequest.php 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. <?php
  2. /**
  3. * dingtalk API: dingtalk.oapi.cspace.auth.generate request
  4. *
  5. * @author auto create
  6. * @since 1.0, 2019.10.08
  7. */
  8. class OapiCspaceAuthGenerateRequest
  9. {
  10. /**
  11. * 微应用的agentId
  12. **/
  13. private $agentId;
  14. /**
  15. * 被授权的应用appId
  16. **/
  17. private $appId;
  18. /**
  19. * 授权码有效期,单位为日,为空则表示永久授权
  20. **/
  21. private $duration;
  22. /**
  23. * 授权访问的文件id列表,id之间用英文逗号隔开,如"fileId1,fileId2", type=download时必须传递
  24. **/
  25. private $fileIds;
  26. /**
  27. * 授权访问的路径,如授权访问所有文件传"/",授权访问/doc文件夹传"/doc/",需要utf-8 urlEncode, type=add时必须传递
  28. **/
  29. private $path;
  30. /**
  31. * 权限类型,目前支持上传和预览,上传请传add,预览请传download
  32. **/
  33. private $type;
  34. private $apiParas = array();
  35. public function setAgentId($agentId)
  36. {
  37. $this->agentId = $agentId;
  38. $this->apiParas["agent_id"] = $agentId;
  39. }
  40. public function getAgentId()
  41. {
  42. return $this->agentId;
  43. }
  44. public function setAppId($appId)
  45. {
  46. $this->appId = $appId;
  47. $this->apiParas["app_id"] = $appId;
  48. }
  49. public function getAppId()
  50. {
  51. return $this->appId;
  52. }
  53. public function setDuration($duration)
  54. {
  55. $this->duration = $duration;
  56. $this->apiParas["duration"] = $duration;
  57. }
  58. public function getDuration()
  59. {
  60. return $this->duration;
  61. }
  62. public function setFileIds($fileIds)
  63. {
  64. $this->fileIds = $fileIds;
  65. $this->apiParas["file_ids"] = $fileIds;
  66. }
  67. public function getFileIds()
  68. {
  69. return $this->fileIds;
  70. }
  71. public function setPath($path)
  72. {
  73. $this->path = $path;
  74. $this->apiParas["path"] = $path;
  75. }
  76. public function getPath()
  77. {
  78. return $this->path;
  79. }
  80. public function setType($type)
  81. {
  82. $this->type = $type;
  83. $this->apiParas["type"] = $type;
  84. }
  85. public function getType()
  86. {
  87. return $this->type;
  88. }
  89. public function getApiMethodName()
  90. {
  91. return "dingtalk.oapi.cspace.auth.generate";
  92. }
  93. public function getApiParas()
  94. {
  95. return $this->apiParas;
  96. }
  97. public function check()
  98. {
  99. RequestCheckUtil::checkNotNull($this->agentId,"agentId");
  100. RequestCheckUtil::checkNotNull($this->appId,"appId");
  101. RequestCheckUtil::checkMaxListSize($this->fileIds,20,"fileIds");
  102. RequestCheckUtil::checkNotNull($this->type,"type");
  103. }
  104. public function putOtherTextParam($key, $value) {
  105. $this->apiParas[$key] = $value;
  106. $this->$key = $value;
  107. }
  108. }