function it_serializes_to_array_for_put()
 {
     $this->setId('123556')->setName('Test name')->setArchived(false)->setPrivacy('private')->setGuestAccessible(false)->setTopic('Testing');
     $user = new User();
     $user->setId('1222');
     $this->setOwner($user);
     $this->toJson()->shouldHaveCount(6);
 }
 function it_updates_user(Client $client, User $user)
 {
     $request = array('id' => '123456', 'name' => 'Test', 'title' => 'Tester', 'mention_name' => 'test', 'is_group_admin' => false, 'email' => '*****@*****.**');
     $user->toJson()->shouldBeCalled()->willReturn($request);
     $user->getId()->shouldBeCalled()->willReturn('123456');
     $client->put('/v2/user/123456', $request)->shouldBeCalled();
     $this->updateUser($user, 'test1234');
 }
 /**
  * Upload a new photo for a user
  * More info: https://www.hipchat.com/docs/apiv2/method/update_photo
  *
  * @param User $user User whose photo will be updated
  * @param string $photoPath
  */
 public function updateUserPhoto(User $user, $photoPath)
 {
     if (empty($photoPath) || !is_string($photoPath)) {
         throw new \InvalidArgumentException('The user photo is invalid.');
     }
     if (null != $photoPath) {
         if (!file_exists($photoPath) || !is_readable($photoPath)) {
             throw new \UnexpectedValueException($photoPath . ' does not exist or is not readable');
         }
         $request = array('photo' => base64_encode(file_get_contents($photoPath)));
         $this->client->put(sprintf('/v2/user/%s/photo', $user->getId()), $request);
     }
 }
Exemple #4
0
 /**
  * Update a user
  * More info: https://www.hipchat.com/docs/apiv2/method/update_user
  *
  * @param User $user User to be updated
  *
  * @return void
  */
 public function updateUser(User $user)
 {
     $request = $user->toJson();
     $this->client->put(sprintf('/v2/user/%s', $user->getId()), $request);
 }