Client.php 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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\Payment\Coupon;
  11. use EasyWeChat\Payment\Kernel\BaseClient;
  12. /**
  13. * Class Client.
  14. *
  15. * @author tianyong90 <412039588@qq.com>
  16. */
  17. class Client extends BaseClient
  18. {
  19. /**
  20. * send a cash coupon.
  21. *
  22. * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
  23. *
  24. * @throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException
  25. * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
  26. * @throws \GuzzleHttp\Exception\GuzzleException
  27. */
  28. public function send(array $params)
  29. {
  30. $params['appid'] = $this->app['config']->app_id;
  31. $params['openid_count'] = 1;
  32. return $this->safeRequest('mmpaymkttransfers/send_coupon', $params);
  33. }
  34. /**
  35. * query a coupon stock.
  36. *
  37. * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
  38. *
  39. * @throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException
  40. * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
  41. * @throws \GuzzleHttp\Exception\GuzzleException
  42. */
  43. public function stock(array $params)
  44. {
  45. $params['appid'] = $this->app['config']->app_id;
  46. return $this->request('mmpaymkttransfers/query_coupon_stock', $params);
  47. }
  48. /**
  49. * query a info of coupon.
  50. *
  51. * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
  52. *
  53. * @throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException
  54. * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
  55. * @throws \GuzzleHttp\Exception\GuzzleException
  56. */
  57. public function info(array $params)
  58. {
  59. $params['appid'] = $this->app['config']->app_id;
  60. return $this->request('mmpaymkttransfers/querycouponsinfo', $params);
  61. }
  62. }