protected function tearDown() { $filename = __DIR__ . '/../../_data/delete-users.csv'; $id = $this->api->users()->postByCsv($filename); while (1) { $result = $this->api->csv()->result($id); if (!$result['done']) { continue; } if ($result['success']) { self::assertTrue(true); } else { self::fail($result['errorCode']); } break; } $filename = __DIR__ . '/../../_data/delete-groups.csv'; $id = $this->api->groups()->postByCsv($filename); while (1) { $result = $this->api->csv()->result($id); if (!$result['done']) { continue; } if ($result['success']) { self::assertTrue(true); } else { self::fail($result['errorCode']); } break; } }
public function testPostKey() { try { $this->api->csv()->postKey('aaa', 'key'); self::fail('Not throw InvalidArgumentException.'); } catch (\InvalidArgumentException $e) { self::assertTrue(true); } }
/** * Get users * https://cybozudev.zendesk.com/hc/ja/articles/202363040#step2 * * @param array $ids * @param array $codes * @param integer $offset * @param integer $limit * @return array */ public function get(array $ids = [], array $codes = [], $offset = 0, $limit = self::MAX_GET_USERS) { $options = ['json' => ['ids' => !empty($ids) ? $ids : [], 'codes' => !empty($codes) ? $codes : []]]; $options['json']['size'] = $limit; $options['json']['offset'] = $offset; return $this->client->get(UserApi::generateUrl('users.json'), $options)->getBody()->jsonSerialize()['users']; }
public function testCsv() { $content = $this->api->organizations()->getByCsv(); $path = __DIR__ . '/../../_output/export-organizations.csv'; file_put_contents($path, $content); $filename = __DIR__ . '/../../_data/orgs.csv'; $id = $this->api->organizations()->postByCsv($filename); while (1) { $result = $this->api->csv()->result($id); if (!$result['done']) { continue; } if ($result['success']) { self::assertTrue(true); } else { self::fail($result['errorCode']); } break; } $content = $this->api->organizations()->getByCsv(); $path = __DIR__ . '/../../_output/export-organizations1.csv'; file_put_contents($path, $content); $getCsv = new Reader($path, 'r+', false); $flg1 = $flg2 = false; while ($row = $getCsv->getRow()) { if ("example-org1" == reset($row)) { $flg1 = true; } if ("example-org2" == reset($row)) { $flg2 = true; } } self::assertTrue($flg1 and $flg2); $filename = __DIR__ . '/../../_output/export-organizations.csv'; $id = $this->api->organizations()->postByCsv($filename); while (1) { $result = $this->api->csv()->result($id); if (!$result['done']) { continue; } if ($result['success']) { self::assertTrue(true); } else { self::fail($result['errorCode']); } break; } }
/** * Get post csv result * https://cybozudev.zendesk.com/hc/ja/articles/202361320 * * @param int $id * @return array */ public function result($id) { $options = ['query' => ['id' => $id]]; return $this->client->get(UserApi::generateUrl('csv/result.json'), $options)->getBody()->jsonSerialize(); }
public function testOrganizationUsers() { self::assertTrue($this->api->organizationUsers() instanceof OrganizationUsers); }
public function testGet() { $config = UserTestHelper::getConfig(); $this->api->organizationUsers()->get($config['login']); self::assertTrue(true); }
/** * Get organizations and titles of user * https://cybozudev.zendesk.com/hc/ja/articles/202124774#step2 * * @param string $code * @return array */ public function get($code) { $options = ['json' => ['code' => $code]]; return $this->client->get(UserApi::generateUrl('user/organizations.json'), $options)->getBody()->jsonSerialize()['organizationTitles']; }
/** * Get users and titles of organization * https://cybozudev.zendesk.com/hc/ja/articles/202124774#step2 * * @param string $code * @return array */ public function get($code, $offset = 0, $limit = self::MAX_GET_USERS) { $options = ['json' => ['code' => $code, 'offset' => $offset, 'size' => $limit]]; return $this->client->get(UserApi::generateUrl('organization/users.json'), $options)->getBody()->jsonSerialize()['userTitles']; }