Crmeb.php 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2023 https://www.crmeb.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  8. // +----------------------------------------------------------------------
  9. // | Author: CRMEB Team <admin@crmeb.com>
  10. // +----------------------------------------------------------------------
  11. namespace crmeb\services\serve\storage;
  12. use crmeb\basic\BaseStorage;
  13. use crmeb\exceptions\AdminException;
  14. use crmeb\services\AccessTokenServeService;
  15. /**
  16. * Class Crmeb
  17. * @package crmeb\services\serve\storage
  18. */
  19. class Crmeb extends BaseStorage
  20. {
  21. protected $accessToken;
  22. /**
  23. * Crmeb constructor.
  24. * @param string $name
  25. * @param AccessTokenServeService $service
  26. * @param string|null $configFile
  27. */
  28. public function __construct(string $name, AccessTokenServeService $service, string $configFile = null)
  29. {
  30. $this->accessToken = $service;
  31. }
  32. protected function initialize(array $config)
  33. {
  34. // TODO: Implement initialize() method.
  35. }
  36. /**
  37. * 获取用户信息
  38. * @param string $account
  39. * @param string $secret
  40. * @return array|mixed
  41. */
  42. public function getUser()
  43. {
  44. return $this->accessToken->httpRequest('v2/user/info');
  45. }
  46. /**
  47. * 用量记录
  48. * @param int $page
  49. * @param int $limit
  50. * @param int $type
  51. * @return array|mixed
  52. */
  53. public function record(int $page, int $limit, int $type, $status = '')
  54. {
  55. $typeContent = [1 => 'sms', 2 => 'expr_dump', 3 => 'expr_query', 4 => 'copy'];
  56. if (!isset($typeContent[$type])) {
  57. throw new AdminException(100100);
  58. }
  59. $data = ['page' => $page, 'limit' => $limit, 'type' => $typeContent[$type]];
  60. if ($type == 1 && $status != '') {
  61. $data['status'] = $status;
  62. }
  63. return $this->accessToken->httpRequest('user/record', $data);
  64. }
  65. }