Client.php 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  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\MiniProgram\Express;
  11. use EasyWeChat\Kernel\BaseClient;
  12. /**
  13. * Class Client.
  14. *
  15. * @author kehuanhuan <1152018701@qq.com>
  16. */
  17. class Client extends BaseClient
  18. {
  19. /**
  20. * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
  21. *
  22. * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
  23. */
  24. public function listProviders()
  25. {
  26. return $this->httpGet('cgi-bin/express/business/delivery/getall');
  27. }
  28. /**
  29. * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
  30. *
  31. * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
  32. * @throws \GuzzleHttp\Exception\GuzzleException
  33. */
  34. public function createWaybill(array $params = [])
  35. {
  36. return $this->httpPostJson('cgi-bin/express/business/order/add', $params);
  37. }
  38. /**
  39. * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
  40. *
  41. * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
  42. * @throws \GuzzleHttp\Exception\GuzzleException
  43. */
  44. public function deleteWaybill(array $params = [])
  45. {
  46. return $this->httpPostJson('cgi-bin/express/business/order/cancel', $params);
  47. }
  48. /**
  49. * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
  50. *
  51. * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
  52. * @throws \GuzzleHttp\Exception\GuzzleException
  53. */
  54. public function getWaybill(array $params = [])
  55. {
  56. return $this->httpPostJson('cgi-bin/express/business/order/get', $params);
  57. }
  58. /**
  59. * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
  60. *
  61. * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
  62. * @throws \GuzzleHttp\Exception\GuzzleException
  63. */
  64. public function getWaybillTrack(array $params = [])
  65. {
  66. return $this->httpPostJson('cgi-bin/express/business/path/get', $params);
  67. }
  68. /**
  69. * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
  70. *
  71. * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
  72. * @throws \GuzzleHttp\Exception\GuzzleException
  73. */
  74. public function getBalance(string $deliveryId, string $bizId)
  75. {
  76. return $this->httpPostJson('cgi-bin/express/business/quota/get', [
  77. 'delivery_id' => $deliveryId,
  78. 'biz_id' => $bizId,
  79. ]);
  80. }
  81. /**
  82. * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
  83. *
  84. * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
  85. * @throws \GuzzleHttp\Exception\GuzzleException
  86. */
  87. public function getPrinter()
  88. {
  89. return $this->httpPostJson('cgi-bin/express/business/printer/getall');
  90. }
  91. /**
  92. * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
  93. *
  94. * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
  95. * @throws \GuzzleHttp\Exception\GuzzleException
  96. */
  97. public function bindPrinter(string $openid)
  98. {
  99. return $this->httpPostJson('cgi-bin/express/business/printer/update', [
  100. 'update_type' => 'bind',
  101. 'openid' => $openid,
  102. ]);
  103. }
  104. /**
  105. * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
  106. *
  107. * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
  108. * @throws \GuzzleHttp\Exception\GuzzleException
  109. */
  110. public function unbindPrinter(string $openid)
  111. {
  112. return $this->httpPostJson('cgi-bin/express/business/printer/update', [
  113. 'update_type' => 'unbind',
  114. 'openid' => $openid,
  115. ]);
  116. }
  117. }