Ejemplo n.º 1
0
 public function get($id = null)
 {
     if (!empty($id)) {
         $this->byId($id);
     }
     $this->getPath();
     $this->request->setVerb('GET');
     $userJsonString = $this->config->getRestClient()->execute($this->request);
     $this->setup();
     $userJsonObject = json_decode($userJsonString);
     return UserFactory::generate($userJsonObject->user);
 }
Ejemplo n.º 2
0
 public static function generate($photoJsonObject)
 {
     if (is_object($photoJsonObject)) {
         $photo = new Photo();
         $photo->setSmallUrl($photoJsonObject->small_url);
         $photo->setMediumUrl($photoJsonObject->medium_url);
         $photo->setLargeUrl($photoJsonObject->large_url);
         $photo->setCreated(new \DateTime($photoJsonObject->created->timestamp));
         $photo->setAuthor(UserFactory::generate($photoJsonObject->created->user));
         return $photo;
     } else {
         throw new ChegamosException("Parâmetro passado não é um objeto.");
     }
 }
Ejemplo n.º 3
0
 public static function generate($userListJsonObject)
 {
     if (is_object($userListJsonObject)) {
         $userList = new UserList();
         $userList->setNumFound($userListJsonObject->result_count);
         $userList->setCurrentPage($userListJsonObject->current_page);
         foreach ($userListJsonObject->users as $user) {
             $userList->add(UserFactory::generate($user->user));
         }
         return $userList;
     } else {
         throw new ChegamosException("Parâmetro passado não é um objeto.");
     }
 }
Ejemplo n.º 4
0
 public static function generate($reviewJsonObject)
 {
     if (is_object($reviewJsonObject)) {
         $review = new Review();
         $review->setId($reviewJsonObject->id);
         $review->setRating($reviewJsonObject->rating);
         $review->setContent($reviewJsonObject->content);
         $review->setCreated(new \DateTime($reviewJsonObject->created->timestamp));
         $review->setAuthor(UserFactory::generate($reviewJsonObject->created->user));
         return $review;
     } else {
         throw new ChegamosException("Parâmetro passado não é um objeto.");
     }
 }
Ejemplo n.º 5
0
 public function testGenerateReviewList()
 {
     $userJson = json_decode($this->jsonStringReviewList);
     $user = UserFactory::generate($userJson->user);
     $this->assertEquals("8972911185", $user->getId());
     $this->assertEquals("Eher", $user->getName());
     $this->assertEquals("http://aptuser.s3.amazonaws.com/8972911185_11409941208494478_b.jpg", $user->getPhotoUrl());
     $this->assertEquals("http://aptuser.s3.amazonaws.com/8972911185_11409941208494478_m.jpg", $user->getPhotoMediumUrl());
     $this->assertEquals("http://aptuser.s3.amazonaws.com/8972911185_11409941208494478_s.jpg", $user->getPhotoSmallUrl());
     $this->assertEquals("99", $user->getReviews()->getNumFound());
     $this->assertEquals("2", $user->getReviews()->getCurrentPage());
     $this->assertTrue($user->getReviews() instanceof ReviewList);
     $this->assertTrue($user->getReviews()->getItem() instanceof Review);
     $this->assertEquals("Agora também tem o http://m.apontador.com.br/ para vc acessar do seu celular.... :D", $user->getReviews()->getItem(5)->getContent());
 }