Пример #1
0
 /**
  * @param string $documentId
  * @param string $name
  */
 public function __construct($documentId, $name)
 {
     $postBody = new PostBody();
     $postBody->setField('name', $name);
     $this->request = new PutRequest("documents/{$documentId}");
     $this->request->setRawJsonBody($postBody->getFields());
 }
Пример #2
0
 /**
  * @param string $fileId
  * @param string $folderId
  */
 public function __construct($fileId, $folderId)
 {
     $postBody = new PostBody();
     $postBody->setField('parent', ['id' => $folderId]);
     $this->request = new PostRequest("files/{$fileId}/copy");
     $this->request->setRawJsonBody((array) $postBody->getFields());
 }
 /**
  * @param string $fileId
  * @param int $fileSize
  */
 public function __construct($fileId, $fileSize)
 {
     $postBody = new PostBody();
     $postBody->setField('size', $fileSize);
     $this->request = new OptionsRequest("files/{$fileId}/content");
     $this->request->setRawJsonBody((array) $postBody->getFields());
 }
Пример #4
0
 /**
  * @param string $folderName
  * @param string $parentFolderId
  */
 public function __construct($folderName, $parentFolderId)
 {
     $postBody = new PostBody();
     $postBody->setField('name', $folderName);
     $postBody->setField('parent', ['id' => $parentFolderId]);
     $this->request = new PostRequest('folders');
     $this->request->setRawJsonBody((array) $postBody->getFields());
 }
 /**
  * @param string $fileName
  * @param int $fileSize
  * @param string $parentFolderId
  */
 public function __construct($fileName, $fileSize, $parentFolderId)
 {
     $postBody = new PostBody();
     $postBody->setField('name', $fileName);
     $postBody->setField('size', $fileSize);
     $postBody->setField('parent', ['id' => $parentFolderId]);
     $this->request = new OptionsRequest('files/content');
     $this->request->setRawJsonBody((array) $postBody->getFields());
 }
Пример #6
0
 public function testApplyingWithFieldsAddsMultipartUpload()
 {
     $b = new PostBody();
     $b->setField('foo', 'bar');
     $this->assertEquals(['foo' => 'bar'], $b->getFields());
     $m = new Request('POST', '/');
     $b->applyRequestHeaders($m);
     $this->assertContains('application/x-www-form', (string) $m->getHeader('Content-Type'));
     $this->assertTrue($m->hasHeader('Content-Length'));
 }
Пример #7
0
 /**
  * @param string $url
  * @param ExtendedRequest $extendedRequest
  */
 public function __construct($url, ExtendedRequest $extendedRequest = null)
 {
     $postBody = new PostBody();
     $postBody->setField('url', $url);
     $postFields = $postBody->getFields();
     if (!is_null($extendedRequest)) {
         $postFields = array_merge($postFields, $extendedRequest->getPostBodyFields());
     }
     $this->request = new PostRequest('documents');
     $this->request->setRawJsonBody($postFields);
 }
Пример #8
0
 public function testMultipartWithAmpersandInValue()
 {
     $b = new PostBody();
     $b->setField('a', 'b&c=d');
     $b->forceMultipartUpload(true);
     $this->assertEquals(['a' => 'b&c=d'], $b->getFields());
     $m = new Request('POST', '/');
     $b->applyRequestHeaders($m);
     $this->assertContains('multipart/form-data', $m->getHeader('Content-Type'));
     $this->assertTrue($m->hasHeader('Content-Length'));
     $contents = $b->getContents();
     $this->assertContains('name="a"', $contents);
     $this->assertContains('b&c=d', $contents);
 }
Пример #9
0
 public function testMultipartWithBase64Fields()
 {
     $b = new PostBody();
     $b->setField('foo64', '/xA2JhWEqPcgyLRDdir9WSRi/khpb2Lh3ooqv+5VYoc=');
     $b->forceMultipartUpload(true);
     $this->assertEquals(['foo64' => '/xA2JhWEqPcgyLRDdir9WSRi/khpb2Lh3ooqv+5VYoc='], $b->getFields());
     $m = new Request('POST', '/');
     $b->applyRequestHeaders($m);
     $this->assertContains('multipart/form-data', (string) $m->getHeader('Content-Type'));
     $this->assertTrue($m->hasHeader('Content-Length'));
     $contents = $b->getContents();
     $this->assertContains('name="foo64"', $contents);
     $this->assertContains('/xA2JhWEqPcgyLRDdir9WSRi/khpb2Lh3ooqv+5VYoc=', $contents);
 }
Пример #10
0
 /**
  * @return array
  */
 public function getPostBodyFields()
 {
     return (array) $this->postBody->getFields();
 }