| Total Complexity | 4 |
| Total Lines | 67 |
| Duplicated Lines | 0 % |
| Coverage | 0% |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 12 | class Users |
||
| 13 | { |
||
| 14 | public const MAX_GET_USERS = 100; |
||
| 15 | |||
| 16 | /** |
||
| 17 | * @var Client |
||
| 18 | */ |
||
| 19 | private $client; |
||
| 20 | |||
| 21 | /** |
||
| 22 | * @var Csv |
||
| 23 | */ |
||
| 24 | private $csv; |
||
| 25 | |||
| 26 | public function __construct(Client $client, Csv $csv) |
||
| 30 | } |
||
| 31 | |||
| 32 | /** |
||
| 33 | * Get users |
||
| 34 | * https://cybozudev.zendesk.com/hc/ja/articles/202363040#step2 |
||
| 35 | * |
||
| 36 | * @param array $ids |
||
| 37 | * @param array $codes |
||
| 38 | * @param integer $offset |
||
| 39 | * @param integer $limit |
||
| 40 | * @return array |
||
| 41 | */ |
||
| 42 | public function get(array $ids = [], array $codes = [], $offset = 0, $limit = self::MAX_GET_USERS): array |
||
| 43 | { |
||
| 44 | $options = ['json' => compact('ids', 'codes')]; |
||
| 45 | $options['json']['size'] = $limit; |
||
| 46 | $options['json']['offset'] = $offset; |
||
| 47 | |||
| 48 | /** @var JsonStream $stream */ |
||
| 49 | $stream = $this->client |
||
| 50 | ->get(UserApi::generateUrl('users.json'), $options) |
||
| 51 | ->getBody(); |
||
| 52 | |||
| 53 | return $stream->jsonSerialize()['users']; |
||
| 54 | } |
||
| 55 | |||
| 56 | /** |
||
| 57 | * Get users by csv |
||
| 58 | * https://cybozudev.zendesk.com/hc/ja/articles/202363040#step1 |
||
| 59 | * |
||
| 60 | * @return string |
||
| 61 | * @throws \InvalidArgumentException |
||
| 62 | */ |
||
| 63 | public function getByCsv(): string |
||
| 64 | { |
||
| 65 | return $this->csv->get('user'); |
||
| 66 | } |
||
| 67 | |||
| 68 | /** |
||
| 69 | * Post users by csv |
||
| 70 | * https://cybozudev.zendesk.com/hc/ja/articles/202111404 |
||
| 71 | * |
||
| 72 | * @param $filename |
||
| 73 | * @return int |
||
| 74 | * @throws \InvalidArgumentException |
||
| 75 | */ |
||
| 76 | public function postByCsv($filename): int |
||
| 79 | } |
||
| 80 | } |
||
| 81 |