Example #1
0
 /**
  * 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'];
 }
Example #2
0
 /**
  * Get apps
  * https://cybozudev.zendesk.com/hc/ja/articles/202931674#step2
  *
  * @param array $ids
  * @param array $codes
  * @param string $name
  * @param array $spaceIds
  * @param integer $limit
  * @param integer $offset
  * @param integer $guestSpaceId
  * @return array
  */
 public function get(array $ids = [], array $codes = [], $name = null, array $spaceIds = [], $limit = self::MAX_GET_APPS, $offset = 0, $guestSpaceId = null)
 {
     $options = ['json' => ['ids' => $ids, 'codes' => $codes, 'name' => $name, 'spaceIds' => $spaceIds]];
     $options['json']['limit'] = $limit;
     $options['json']['offset'] = $offset;
     return $this->client->get(KintoneApi::generateUrl('apps.json', $guestSpaceId), $options)->getBody()->jsonSerialize();
 }
Example #3
0
 /**
  * Put record status
  * https://cybozudev.zendesk.com/hc/ja/articles/204791550#anchor_changeRecordStatus
  *
  * @param integer $appId
  * @param integer $id
  * @param string $action
  * @param string $assignee
  * @param integer $guestSpaceId
  * @param integer $revision
  * @return array
  */
 public function putStatus($appId, $id, $action, $assignee = null, $guestSpaceId = null, $revision = -1)
 {
     $options = ['json' => ['app' => $appId, 'id' => $id, 'action' => $action, 'revision' => $revision]];
     if ($assignee !== null) {
         $options['json']['assignee'] = $assignee;
     }
     return $this->client->put(KintoneApi::generateUrl('record/status.json', $guestSpaceId), $options)->getBody()->jsonSerialize();
 }
Example #4
0
 /**
  * Get app JavaScript and CSS customize
  * https://cybozudev.zendesk.com/hc/ja/articles/204529824
  *
  * @param integer $id
  * @param integer $guestSpaceId
  * @return array
  */
 public function getCustomize($id, $guestSpaceId = null)
 {
     $options = ['json' => ['app' => $id]];
     return $this->client->get(KintoneApi::generateUrl('app/customize.json', $guestSpaceId), $options)->getBody()->jsonSerialize();
 }
Example #5
0
 /**
  * Put space guest users
  * https://cybozudev.zendesk.com/hc/ja/articles/201941904
  *
  * @param integer $id
  * @param array   $guests
  * @return array
  */
 public function putGuests($id, array $guests)
 {
     $options = ['json' => ['id' => $id, 'guests' => $guests]];
     return $this->client->put(KintoneApi::generateUrl('space/guests.json', $id), $options)->getBody()->jsonSerialize();
 }
Example #6
0
 /**
  * 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();
 }
Example #7
0
 /**
  * Get record comments
  * https://cybozudev.zendesk.com/hc/ja/articles/208242326
  *
  * @param int $appId
  * @param int $recordId
  * @param string $order "asc" or "desc"
  * @param int $offset
  * @param int $limit Max = 10
  * @param int $guestSpaceId
  * @return array
  */
 public function get($appId, $recordId, $order = 'desc', $offset = 0, $limit = 10, $guestSpaceId = null)
 {
     $options = ['json' => ['app' => $appId, 'record' => $recordId, 'order' => $order, 'offset' => $offset, 'limit' => $limit]];
     return $this->client->get(KintoneApi::generateUrl('record/comments.json', $guestSpaceId), $options)->getBody()->jsonSerialize()['comments'];
 }
Example #8
0
 /**
  * Post thread comment
  * https://cybozudev.zendesk.com/hc/ja/articles/209732306
  *
  * @param int $spaceId
  * @param int $threadId
  * @param string $comment
  * @param array $mentions
  * @param array $files
  * @param int $guestSpaceId
  * @return array
  */
 public function comment($spaceId, $threadId, $comment, $mentions = [], $files = [], $guestSpaceId = null)
 {
     $options = ['json' => ['space' => $spaceId, 'thread' => $threadId, 'comment' => ['text' => $comment, 'mentions' => $mentions, 'files' => $files]]];
     return $this->client->post(KintoneApi::generateUrl('space/thread/comment.json', $guestSpaceId), $options)->getBody()->jsonSerialize();
 }
Example #9
0
 /**
  * Post file
  * https://cybozudev.zendesk.com/hc/ja/articles/201941824#step1
  *
  * @param string $filename
  * @param int $guestSpaceId
  * @return string
  */
 public function post($filename, $guestSpaceId = null)
 {
     $options = ['multipart' => [['name' => 'file', 'filename' => basename($filename), 'contents' => fopen($filename, 'r')]]];
     return $this->client->post(KintoneApi::generateUrl('file.json', $guestSpaceId), $options)->getBody()->jsonSerialize()["fileKey"];
 }
Example #10
0
 /**
  * Delete guest users
  * https://cybozudev.zendesk.com/hc/ja/articles/202931674#step1
  *
  * @param array $guests
  * @return array
  */
 public function delete(array $guests)
 {
     $options = ['json' => ['guests' => $guests]];
     return $this->client->delete(KintoneApi::generateUrl('guests.json'), $options)->getBody()->jsonSerialize();
 }
Example #11
0
 /**
  * Delete record comment
  * https://cybozudev.zendesk.com/hc/ja/articles/209758703
  *
  * @param integer $appId
  * @param integer $recordId
  * @param integer $id
  * @param integer $guestSpaceId
  * @return array
  */
 public function delete($appId, $recordId, $id, $guestSpaceId = null)
 {
     $options = ['json' => ['app' => $appId, 'record' => $recordId, 'comment' => $id]];
     return $this->client->delete(KintoneApi::generateUrl('record/comment.json', $guestSpaceId), $options)->getBody()->jsonSerialize();
 }
Example #12
0
 /**
  * @param array $config
  * @param integer $pattern
  * @throws NotExistRequiredException
  */
 private function errorConnection(array $config, $pattern = self::NO_CHANGE)
 {
     switch ($pattern) {
         case self::NO_CHANGE:
             break;
         case self::CHANGE_SUB_DOMAIN:
             $config['subdomain'] = 'change_me';
             break;
         case self::CHANGE_LOGIN:
             $config['login'] = '******';
             break;
         case self::CHANGE_PASSWORD:
             $config['password'] = '******';
             break;
         case self::CHANGE_BASIC_LOGIN:
             $config['basic_login'] = '******';
             break;
         case self::CHANGE_BASIC_PASSWORD:
             $config['basic_password'] = '******';
             break;
         case self::CHANGE_CERT_FILE:
             $config['cert_file'] = 'change_me';
             break;
         case self::CHANGE_CERT_PASSWORD:
             $config['cert_password'] = '******';
             break;
     }
     $client = new Client($config);
     try {
         $client->connectionTest();
     } catch (ClientException $e) {
         switch ($pattern) {
             case self::CHANGE_BASIC_LOGIN:
             case self::CHANGE_BASIC_PASSWORD:
                 self::assertTrue(true);
                 break;
             default:
                 file_put_contents(__DIR__ . '/_output/connectionTestError.html', (string) $e->getResponse()->getBody());
                 self::fail("ERROR!! " . get_class($e) . " : " . $e->getMessage());
                 break;
         }
     } catch (ServerException $e) {
         switch ($pattern) {
             case self::CHANGE_LOGIN:
             case self::CHANGE_PASSWORD:
                 self::assertTrue(true);
                 break;
             default:
                 file_put_contents(__DIR__ . '/_output/connectionTestError.html', (string) $e->getResponse()->getBody());
                 self::fail("ERROR!! " . get_class($e) . " : " . $e->getMessage());
                 break;
         }
     } catch (\Exception $e) {
         self::fail("ERROR!! " . get_class($e) . " : " . $e->getMessage());
     }
 }
Example #13
0
 /**
  * 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'];
 }
Example #14
0
 /**
  * Put app JavaScript & CSS customize to preview app
  * https://cybozudev.zendesk.com/hc/ja/articles/204529834
  *
  * @param integer $id
  * @param array   $js
  * @param array   $css
  * @param array   $mobileJs
  * @param integer $guestSpaceId
  * @param string  $scope
  * @param integer $revision
  * @return array
  */
 public function putCustomize($id, array $js = [], array $css = [], array $mobileJs = [], $guestSpaceId = null, $scope = 'ALL', $revision = -1)
 {
     $options = ['json' => ['app' => $id, 'desktop' => ['js' => $js, 'css' => $css], 'mobile' => ['js' => $mobileJs], 'scope' => $scope, 'revision' => $revision]];
     return $this->client->put(KintoneApi::generateUrl('preview/app/customize.json', $guestSpaceId), $options)->getBody()->jsonSerialize();
 }
Example #15
0
 /**
  * Post bulkRequest
  * https://cybozudev.zendesk.com/hc/ja/articles/201941814
  *
  * @param array $requests
  * @param integer $guestSpaceId
  * @return array
  */
 public function postBulkRequest(array $requests, $guestSpaceId = null)
 {
     $options = ['json' => ['requests' => $requests]];
     return $this->client->post(KintoneApi::generateUrl('bulkRequest.json', $guestSpaceId), $options)->getBody()->jsonSerialize()['results'];
 }
Example #16
0
 /**
  * Put records status
  * https://cybozudev.zendesk.com/hc/ja/articles/204791550#anchor_changeRecordStatusBulk
  *
  * @param integer $appId
  * @param array $records
  * @param integer $guestSpaceId
  * @return array
  */
 public function putStatus($appId, array $records, $guestSpaceId = null)
 {
     $options = ['json' => ['app' => $appId, 'records' => $records]];
     return $this->client->put(KintoneApi::generateUrl('records/status.json', $guestSpaceId), $options)->getBody()->jsonSerialize();
 }
Example #17
0
 /**
  * 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'];
 }