ContactWayClient.php 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <?php
  2. /*
  3. * This file is part of the overtrue/wechat.
  4. *
  5. * (c) overtrue <i@overtrue.me>
  6. *
  7. * This source file is subject to the MIT license that is bundled
  8. * with this source code in the file LICENSE.
  9. */
  10. namespace EasyWeChat\Work\ExternalContact;
  11. use EasyWeChat\Kernel\BaseClient;
  12. /**
  13. * Class ContactWayClient.
  14. *
  15. * @author milkmeowo <milkmeowo@gmail.com>
  16. */
  17. class ContactWayClient extends BaseClient
  18. {
  19. /**
  20. * 配置客户联系「联系我」方式.
  21. *
  22. * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
  23. *
  24. * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
  25. * @throws \GuzzleHttp\Exception\GuzzleException
  26. */
  27. public function create(int $type, int $scene, array $config = [])
  28. {
  29. $params = array_merge([
  30. 'type' => $type,
  31. 'scene' => $scene,
  32. ], $config);
  33. return $this->httpPostJson('cgi-bin/externalcontact/add_contact_way', $params);
  34. }
  35. /**
  36. * 获取企业已配置的「联系我」方式.
  37. *
  38. * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
  39. *
  40. * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
  41. * @throws \GuzzleHttp\Exception\GuzzleException
  42. */
  43. public function get(string $configId)
  44. {
  45. return $this->httpPostJson('cgi-bin/externalcontact/get_contact_way', [
  46. 'config_id' => $configId,
  47. ]);
  48. }
  49. /**
  50. * 更新企业已配置的「联系我」方式.
  51. *
  52. * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
  53. *
  54. * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
  55. * @throws \GuzzleHttp\Exception\GuzzleException
  56. */
  57. public function update(string $configId, array $config = [])
  58. {
  59. $params = array_merge([
  60. 'config_id' => $configId,
  61. ], $config);
  62. return $this->httpPostJson('cgi-bin/externalcontact/update_contact_way', $params);
  63. }
  64. /**
  65. * 删除企业已配置的「联系我」方式.
  66. *
  67. * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
  68. *
  69. * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
  70. * @throws \GuzzleHttp\Exception\GuzzleException
  71. */
  72. public function delete(string $configId)
  73. {
  74. return $this->httpPostJson('cgi-bin/externalcontact/del_contact_way', [
  75. 'config_id' => $configId,
  76. ]);
  77. }
  78. }