Beispiel #1
0
 public function testGet()
 {
     $graph = KintoneTestHelper::getGraph();
     $res = $this->api->graph()->get($graph['appId'], $graph['reportId']);
     file_put_contents(__DIR__ . '/../../_output/graph.html', $res);
     self::assertTrue(true);
 }
Beispiel #2
0
 public function testPostBulkRequest()
 {
     $spaceId = KintoneTestHelper::createTestSpace();
     $space = $this->api->space()->get($spaceId);
     $appId = KintoneTestHelper::createTestApp($spaceId, $space['defaultThread']);
     $recordId = KintoneTestHelper::postTestRecord($appId);
     $requests = [["method" => "DELETE", "api" => KintoneApi::generateUrl('records.json'), "payload" => ["app" => $appId, "ids" => [$recordId]]]];
     $result = $this->api->postBulkRequest($requests);
     self::assertArrayNotHasKey('message', $result);
 }
Beispiel #3
0
 public function testPostAndDelete()
 {
     $guests = [['code' => '*****@*****.**', 'password' => 'password', 'timezone' => 'Asia/Tokyo', 'name' => 'test guest user1'], ['code' => '*****@*****.**', 'password' => 'password', 'timezone' => 'Asia/Tokyo', 'name' => 'test guest user2']];
     try {
         $this->api->guests()->delete(['*****@*****.**', '*****@*****.**']);
         sleep(1);
     } catch (RequestException $e) {
         // If not exist test guest users, no problem
     }
     $this->api->guests()->post($guests);
     // kintone does not have the get guest users api.
     self::assertTrue(true);
     $this->api->guests()->delete(['*****@*****.**', '*****@*****.**']);
     // kintone does not have the get guest users api.
     self::assertTrue(true);
 }
Beispiel #4
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();
 }
Beispiel #5
0
 protected function tearDown()
 {
     $this->api->space()->delete($this->spaceId);
     $this->api->space()->delete($this->guestSpaceId, $this->guestSpaceId);
 }
Beispiel #6
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();
 }
Beispiel #7
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();
 }
Beispiel #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();
 }
Beispiel #9
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'];
 }
Beispiel #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();
 }
Beispiel #11
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"];
 }
Beispiel #12
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();
 }
Beispiel #13
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'];
 }
Beispiel #14
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();
 }
Beispiel #15
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();
 }
Beispiel #16
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();
 }