public function testGetLibraryFiles()
 {
     $response = self::$client->get('/')->json();
     $result = new ResultSet($response['results'], $response['meta']);
     $files = array();
     foreach ($result->results as $file) {
         $files[] = File::create($file);
     }
     $this->assertInstanceOf('Ctct\\Components\\ResultSet', $result);
     $this->assertEquals('c023cmNlPUFsbCUiUmZzZXQ9MTgyIcV5cGU9QWxsJmxpbWl0PTE', $result->next);
     $this->assertInstanceOf('Ctct\\Components\\Library\\File', $files[0]);
     $this->assertEquals("Test_card.png", $files[0]->name);
     $this->assertEquals("182", $files[0]->id);
     $this->assertEquals("descriptionssss", $files[0]->description);
     $this->assertEquals("Images", $files[0]->folder);
     $this->assertEquals(360, $files[0]->height);
     $this->assertEquals(640, $files[0]->width);
     $this->assertEquals(26271, $files[0]->size);
     $this->assertEquals("https://mlsvc01-prod.s3.amazonaws.com/489270ef001/d738eefc-8e8e-4a69-8e7d-8e7217d22a0a.png", $files[0]->url);
     $this->assertEquals("MyComputer", $files[0]->source);
     $this->assertEquals("Active", $files[0]->status);
     $this->assertInstanceOf('Ctct\\Components\\Library\\Thumbnail', $files[0]->thumbnail);
     $this->assertEquals("https://mlsvc01-prod.s3.amazonaws.com/489270ef001/d738eefc-8e8e-4a69-8e7d-8e7217d22a0a.png", $files[0]->thumbnail->url);
     $this->assertEquals(112, $files[0]->thumbnail->height);
     $this->assertEquals(200, $files[0]->thumbnail->width);
     $this->assertEquals("2015-01-09T00:14:08.000-05:00", $files[0]->created_date);
     $this->assertEquals("2015-01-09T00:14:08.000-05:00", $files[0]->modified_date);
     $this->assertEquals(null, $files[0]->folder_id);
     $this->assertEquals(true, $files[0]->is_image);
     $this->assertEquals("PNG", $files[0]->file_type);
 }
 /**
  * Get File by Id
  * @param string $accessToken - Constant Contact OAuth2 Access Token
  * @param string $fileId - Specified File Id
  * @return File
  */
 public function getLibraryFile($accessToken, $fileId)
 {
     $baseUrl = Config::get('endpoints.base_url') . sprintf(Config::get('endpoints.library_file'), $fileId);
     $url = $this->buildUrl($baseUrl);
     $response = parent::getRestClient()->get($url, parent::getHeaders($accessToken));
     return File::create(json_decode($response->body, true));
 }
Exemplo n.º 3
0
 /**
  * Get File by Id
  * @param string $accessToken - Constant Contact OAuth2 Access Token
  * @param string $fileId - Specified File Id
  * @return File
  * @throws CtctException
  */
 public function getLibraryFile($accessToken, $fileId)
 {
     $baseUrl = Config::get('endpoints.base_url') . sprintf(Config::get('endpoints.library_file'), $fileId);
     $request = parent::createBaseRequest($accessToken, 'GET', $baseUrl);
     try {
         $response = parent::getClient()->send($request);
     } catch (ClientException $e) {
         throw parent::convertException($e);
     }
     return File::create($response->json());
 }